├── .github └── workflows │ └── easyp_build.yml ├── .gitignore ├── .gitmodules ├── .golangci.yml ├── Dockerfile ├── LICENSE ├── README.md ├── api ├── buf.work.yaml └── proto │ ├── .gitignore │ ├── buf.gen.yaml │ └── generate.go ├── cmd └── easyp │ ├── internal │ └── config │ │ ├── cachetype │ │ └── cachetype.go │ │ ├── config.go │ │ ├── read.go │ │ └── url.go │ └── main.go ├── gen └── proto │ └── buf │ └── alpha │ ├── audit │ └── v1alpha1 │ │ ├── event.pb.go │ │ ├── service.pb.go │ │ ├── service_grpc.pb.go │ │ └── v1alpha1connect │ │ └── service.connect.go │ ├── breaking │ └── v1 │ │ └── config.pb.go │ ├── image │ └── v1 │ │ └── image.pb.go │ ├── lint │ └── v1 │ │ └── config.pb.go │ ├── module │ └── v1alpha1 │ │ └── module.pb.go │ ├── registry │ └── v1alpha1 │ │ ├── admin.pb.go │ │ ├── admin_grpc.pb.go │ │ ├── authn.pb.go │ │ ├── authn_grpc.pb.go │ │ ├── authz.pb.go │ │ ├── authz_grpc.pb.go │ │ ├── convert.pb.go │ │ ├── convert_grpc.pb.go │ │ ├── display.pb.go │ │ ├── display_grpc.pb.go │ │ ├── doc.pb.go │ │ ├── doc_grpc.pb.go │ │ ├── download.pb.go │ │ ├── download_grpc.pb.go │ │ ├── git_metadata.pb.go │ │ ├── github.pb.go │ │ ├── github_grpc.pb.go │ │ ├── image.pb.go │ │ ├── image_grpc.pb.go │ │ ├── jsonschema.pb.go │ │ ├── jsonschema_grpc.pb.go │ │ ├── labels.pb.go │ │ ├── labels_grpc.pb.go │ │ ├── module.pb.go │ │ ├── organization.pb.go │ │ ├── organization_grpc.pb.go │ │ ├── owner.pb.go │ │ ├── owner_grpc.pb.go │ │ ├── plugin_curation.pb.go │ │ ├── plugin_curation_grpc.pb.go │ │ ├── push.pb.go │ │ ├── push_grpc.pb.go │ │ ├── recommendation.pb.go │ │ ├── recommendation_grpc.pb.go │ │ ├── reference.pb.go │ │ ├── reference_grpc.pb.go │ │ ├── repository.pb.go │ │ ├── repository_branch.pb.go │ │ ├── repository_branch_grpc.pb.go │ │ ├── repository_commit.pb.go │ │ ├── repository_commit_grpc.pb.go │ │ ├── repository_grpc.pb.go │ │ ├── repository_tag.pb.go │ │ ├── repository_tag_grpc.pb.go │ │ ├── resolve.pb.go │ │ ├── resolve_grpc.pb.go │ │ ├── resource.pb.go │ │ ├── resource_grpc.pb.go │ │ ├── role.pb.go │ │ ├── schema.pb.go │ │ ├── schema_grpc.pb.go │ │ ├── scim_token.pb.go │ │ ├── scim_token_grpc.pb.go │ │ ├── search.pb.go │ │ ├── search_grpc.pb.go │ │ ├── studio.pb.go │ │ ├── studio_grpc.pb.go │ │ ├── studio_request.pb.go │ │ ├── studio_request_grpc.pb.go │ │ ├── sync.pb.go │ │ ├── sync_grpc.pb.go │ │ ├── token.pb.go │ │ ├── token_grpc.pb.go │ │ ├── user.pb.go │ │ ├── user_grpc.pb.go │ │ ├── v1alpha1connect │ │ ├── admin.connect.go │ │ ├── authn.connect.go │ │ ├── authz.connect.go │ │ ├── convert.connect.go │ │ ├── display.connect.go │ │ ├── doc.connect.go │ │ ├── download.connect.go │ │ ├── github.connect.go │ │ ├── image.connect.go │ │ ├── jsonschema.connect.go │ │ ├── labels.connect.go │ │ ├── organization.connect.go │ │ ├── owner.connect.go │ │ ├── plugin_curation.connect.go │ │ ├── push.connect.go │ │ ├── recommendation.connect.go │ │ ├── reference.connect.go │ │ ├── repository.connect.go │ │ ├── repository_branch.connect.go │ │ ├── repository_commit.connect.go │ │ ├── repository_tag.connect.go │ │ ├── resolve.connect.go │ │ ├── resource.connect.go │ │ ├── schema.connect.go │ │ ├── scim_token.connect.go │ │ ├── search.connect.go │ │ ├── studio.connect.go │ │ ├── studio_request.connect.go │ │ ├── sync.connect.go │ │ ├── token.connect.go │ │ ├── user.connect.go │ │ └── webhook.connect.go │ │ ├── verification_status.pb.go │ │ ├── webhook.pb.go │ │ └── webhook_grpc.pb.go │ ├── studio │ └── v1alpha1 │ │ └── invoke.pb.go │ ├── wasmplugin │ └── v1 │ │ └── wasmplugin.pb.go │ └── webhook │ └── v1alpha1 │ ├── event.pb.go │ ├── event_grpc.pb.go │ └── v1alpha1connect │ └── event.connect.go ├── go.mod ├── go.sum ├── internal ├── connect │ ├── api.go │ ├── blobs.go │ ├── bynames.go │ └── modulepins.go ├── https │ └── https.go ├── logger │ └── logger.go ├── providers │ ├── bitbucket │ │ ├── client.go │ │ ├── getfiles.go │ │ ├── getrepo.go │ │ └── repos.go │ ├── cache │ │ ├── artifactory │ │ │ └── artifactory.go │ │ ├── file.go │ │ └── noop.go │ ├── content │ │ └── repo.go │ ├── filter │ │ └── filter.go │ ├── github │ │ ├── client.go │ │ ├── getfiles.go │ │ ├── getrepo.go │ │ └── repos.go │ ├── localgit │ │ ├── localgit.go │ │ └── namedlocks │ │ │ └── lock.go │ ├── multisource │ │ └── repo.go │ └── source │ │ └── source.go └── shake256 │ └── hash.go ├── local.config.yml ├── scripts ├── build.sh ├── clone_repos.sh ├── publish.sh └── push_stage_to_docker.sh └── testdata ├── cert.pem └── key.pem /.github/workflows/easyp_build.yml: -------------------------------------------------------------------------------- 1 | name: build-docker 2 | run-name: ${{ github.actor }} 3 | 4 | on: 5 | push: 6 | branches: 7 | - 'main' 8 | 9 | jobs: 10 | 11 | build-docker: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Set up QEMU 15 | uses: docker/setup-qemu-action@v2 16 | - name: Set up Docker Buildx 17 | uses: docker/setup-buildx-action@v2 18 | - name: Login to Docker Hub 19 | uses: docker/login-action@v2 20 | with: 21 | registry: cr.yandex 22 | username: ${{ secrets.DOCKER_USERNAME }} 23 | password: ${{ secrets.DOCKER_TOKEN }} 24 | - name: Build and push 25 | uses: docker/build-push-action@v3 26 | with: 27 | push: true 28 | tags: cr.yandex/crplga9vcvsvk4uv6541/easyp:stage 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | bin -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "api/_third_party/buf"] 2 | path = api/_third_party/buf 3 | url = https://github.com/bufbuild/buf.git 4 | [submodule "api/_third_party/protobuf"] 5 | path = api/_third_party/protobuf 6 | url = https://github.com/protocolbuffers/protobuf.git 7 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | run: 2 | timeout: 5m 3 | # include test files 4 | tests: true 5 | 6 | linters: 7 | enable-all: true 8 | disable: 9 | - exhaustivestruct # The owner seems to have abandoned the linter. Replaced by exhaustruct. 10 | - ifshort # The repository of the linter has been deprecated by the owner. 11 | - maligned # The repository of the linter has been archived by the owner. Replaced by govet 'fieldalignment'. 12 | - interfacer # The repository of the linter has been archived by the owner. 13 | - deadcode # The owner seems to have abandoned the linter. Replaced by unused. 14 | - golint # The repository of the linter has been archived by the owner. Replaced by revive. 15 | - varcheck # The owner seems to have abandoned the linter. Replaced by unused. 16 | - structcheck # The owner seems to have abandoned the linter. Replaced by unused. 17 | - nosnakecase # The repository of the linter has been deprecated by the owner. Replaced by revive(var-naming). 18 | - scopelint # The repository of the linter has been deprecated by the owner. Replaced by exportloopref. 19 | - varnamelen # useless in the scope of this project 20 | 21 | # Run all the linters from enabled linters set 22 | fast: false 23 | 24 | issues: 25 | # skipping non-go dirs 26 | exclude-dirs: 27 | - bin 28 | - config 29 | - debian 30 | - docs 31 | - scripts 32 | - tests 33 | include: 34 | - EXC0001 # Check return values of os funcs 35 | - EXC0004 # govet 36 | - EXC0005 # C-style breaks 37 | 38 | exclude-rules: 39 | - linters: 40 | - ireturn 41 | text: "returns generic interface" 42 | 43 | - linters: 44 | - lll 45 | source: "^//go:generate " 46 | 47 | - linters: 48 | - errcheck 49 | source: "defer\\s+[^\\s]+.Close()" 50 | 51 | - linters: 52 | - revive 53 | text: "unexported-return: exported func .+ returns unexported type .+, which can be annoying to use" 54 | 55 | - path: cmd/[^/]+/.+\.go 56 | text: exitAfterDefer 57 | 58 | # Exclude some linters from running on tests files. 59 | - path: _test\.go 60 | linters: 61 | - gocyclo 62 | - errcheck 63 | - dupl 64 | - gosec 65 | - gochecknoglobals 66 | - exhaustruct 67 | - ireturn 68 | - funlen 69 | - unparam 70 | - lll 71 | 72 | linters-settings: 73 | gci: 74 | # Section configuration to compare against. 75 | sections: 76 | - standard # Standard section: captures all standard packages. 77 | - default # Default section: contains all imports that could not be matched to another section type. 78 | - prefix(github.com/easyp-tech) # Custom section: groups all imports with the specified Prefix. 79 | skip-generated: false 80 | # Enable custom order of sections. 81 | # If true, make the section order the same as the order of sections. 82 | custom-order: true 83 | depguard: 84 | rules: 85 | main: 86 | files: 87 | - !$test 88 | allow: 89 | - $gostd 90 | cmd: 91 | files: 92 | - "cmd/*/*.go" 93 | allow: 94 | - $gostd 95 | tests: 96 | files: 97 | - $test 98 | allow: 99 | - $gostd 100 | - github.com/stretchr/testify 101 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.21-alpine3.17 AS builder 2 | 3 | RUN apk update && apk add --no-cache ca-certificates 4 | 5 | FROM scratch 6 | 7 | WORKDIR /bin 8 | 9 | COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ 10 | COPY /bin/easyp-server easyp-server 11 | 12 | ENTRYPOINT ["easyp-server"] 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # easyp-server 2 | 3 | 4 | * [easyp-server](#easyp-server) 5 | * [TODO:](#todo) 6 | * [Features](#features) 7 | * [Installation](#installation) 8 | * [Steps](#steps) 9 | * [Repository Setup](#repository-setup) 10 | * [Service Configuration](#service-configuration) 11 | * [`buf` configuration](#buf-configuration-) 12 | 13 | 14 | # TODO: 15 | 16 | * Elaborate on the roadmap 17 | 18 | A backward-compatible server for working with the CLI tool [buf](https://github.com/bufbuild/buf). 19 | 20 | ## Features 21 | 22 | * Support for the package manager with `buf mod update` 23 | 24 | ## Installation 25 | 26 | ### Steps 27 | 28 | #### Repository Setup 29 | 30 | ```bash 31 | wget https://github.com/easyp-tech/server/blob/main/scripts/clone_repos.sh -O clone_repos.sh 32 | 33 | chmod +x clone_repos.sh 34 | 35 | ./clone_repos.sh https://github.com/googleapis/googleapis.git https://github.com/bufbuild/protovalidate.git 36 | ``` 37 | 38 | #### Service Configuration 39 | 40 | Create a service configuration file, replace easyp.tech with your domain: 41 | 42 | ```yaml 43 | # address the service will be listening 44 | listen: 127.0.0.1:8080 45 | 46 | # domain the service will be accessible. 47 | # Note: buf requires TLS, so this is a name your cert is assigned. 48 | domain: easyp.tech:8080 49 | 50 | # Cache configuration 51 | cache: 52 | # Cache type: none | local | artifactory 53 | # none means no cache, local means caching in the local directory 54 | # artifactory - surprise - means cache placed on the artifactory server 55 | # local/artifactory are configured with the corresponding sections below 56 | # Note: googleapis downloading from GitHub take about 40 sec, 57 | # so cache might be considered useful. 58 | type: none 59 | local: 60 | # directory where the cache will be placed. 61 | directory: ./.storage/.cache 62 | artifactory: 63 | token: some_artifactory_access_token 64 | user: some_username 65 | url: https://some.artifactory.url/with/read/write/access 66 | 67 | # TLS config, required by buf. 68 | tls: 69 | cert: cert.pem 70 | key: key.pem 71 | #ca: ca.pem 72 | 73 | # Processing order: 74 | # 1. check if the local mirror exists and use it if so 75 | # 2. pass all the other to the GitHub proxy 76 | 77 | # Locally mirrored git repos settings. 78 | local: 79 | # Path to find the local git mirrors. 80 | # Mirrors must be os owner/repository subdir in this dir. 81 | # Local mirrors have the highest priority: 82 | # the server's response will be based on it if it is detected. 83 | # Note: write access is required as the service will switch commits then needed. 84 | storage: ./.storage/gitlocal 85 | # Settings applied to the locally mirrored repos. 86 | # Mirrors not mentioned are processed as with empty config, 87 | # which is Ok for most cases. 88 | repo: 89 | - owner: googleapis 90 | name: googleapis 91 | path: 92 | - google/type/ 93 | - google/api/ 94 | - google/rpc/ 95 | - owner: bufbuild 96 | name: protovalidate 97 | prefix: 98 | - proto/protovalidate/ 99 | - owner: grpc-ecosystem 100 | name: grpc-gateway 101 | path: 102 | - protoc-gen-openapiv2/ 103 | 104 | # Proxy config 105 | # GitHub API only at the moment 106 | proxy: 107 | # list of the repos will be proxied to BitBucket using API v1. 108 | bitbucket: 109 | # BitBucket API access token, generate your own. 110 | # You can go without token, but access rate will be really limited. 111 | # BitBucket repos are the second priority. 112 | - token: some_bitbucket_access_token 113 | user: some_username 114 | url: https://some.bitbucket.url/repo/is/accessible 115 | # Repository details 116 | repo: 117 | owner: googleapis 118 | name: googleapis 119 | # googleapis is huge. 120 | # Fortunately we do not need to get all the files to make it works. 121 | # So path is a list of prefixes for the files really required. 122 | # Note: trailing slash is essential. Leading slash is prohibited. 123 | path: 124 | - google/type/ 125 | - google/api/ 126 | - google/rpc/ 127 | - token: some_bitbucket_access_token 128 | user: some_username 129 | url: https://some.bitbucket.url/repo/is/accessible 130 | repo: 131 | owner: bufbuild 132 | name: protovalidate 133 | # prefix is similar to path, 134 | # it is used to distinguish the files we really want to get. 135 | # but prefix will be cut off from the proxied file name. 136 | # it might be required for some repos, like bufbuild/protovalidate 137 | # Note: trailing slash is essential. Leading slash is prohibited. 138 | prefix: 139 | - proto/protovalidate/ 140 | - token: some_bitbucket_access_token 141 | user: some_username 142 | url: https://some.bitbucket.url/repo/is/accessible 143 | repo: 144 | owner: grpc-ecosystem 145 | name: grpc-gateway 146 | path: 147 | - protoc-gen-openapiv2/ 148 | 149 | # list of the repos will be proxied to GitHub. 150 | github: 151 | # GitHub API access token, generate your own. 152 | # You can go without token, but access rate will be really limited. 153 | # GitHub repos are the last priority. 154 | - token: some_github_token 155 | # Repository details 156 | repo: 157 | owner: googleapis 158 | name: googleapis 159 | # googleapis is huge. 160 | # Fortunately we do not need to get all the files to make it works. 161 | # So path is a list of prefixes for the files really required. 162 | # Note: trailing slash is essential. Leading slash is prohibited. 163 | path: 164 | - google/type/ 165 | - google/api/ 166 | - google/rpc/ 167 | - token: some_github_token 168 | repo: 169 | owner: bufbuild 170 | name: protovalidate 171 | # prefix is similar to path, 172 | # it is used to distinguish the files we really want to get. 173 | # but prefix will be cut off from the proxied file name. 174 | # it might be required for some repos, like bufbuild/protovalidate 175 | # Note: trailing slash is essential. Leading slash is prohibited. 176 | prefix: 177 | - proto/protovalidate/ 178 | - token: some_github_token 179 | repo: 180 | owner: grpc-ecosystem 181 | name: grpc-gateway 182 | path: 183 | - protoc-gen-openapiv2/ 184 | ``` 185 | 186 | Note that config values can be set to env vars. Easyp will attempt to substitute them with the values from the current environment. If variable is unset, it will be replaced with an empty string. Example: 187 | 188 | ```yaml 189 | # address the service will be listening 190 | listen: ${EASYP_LISTEN} 191 | ``` 192 | 193 | #### `buf` configuration 194 | 195 | Essential part of `buf.yaml`: 196 | 197 | ```yaml 198 | deps: 199 | - easyp.tech:8080/bufbuild/protovalidate 200 | - easyp.tech:8080/grpc-ecosystem/grpc-gateway 201 | - easyp.tech:8080/googleapis/googleapis 202 | ``` -------------------------------------------------------------------------------- /api/buf.work.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | directories: 3 | - proto 4 | - _third_party/protobuf/src 5 | -------------------------------------------------------------------------------- /api/proto/.gitignore: -------------------------------------------------------------------------------- 1 | buf 2 | -------------------------------------------------------------------------------- /api/proto/generate.go: -------------------------------------------------------------------------------- 1 | package proto 2 | 3 | //go:generate rm -rf ./buf 4 | //go:generate cp -r ../_third_party/buf/proto/buf ./ 5 | //go:generate rm -rf ../../gen 6 | //go:generate buf generate 7 | -------------------------------------------------------------------------------- /cmd/easyp/internal/config/cachetype/cachetype.go: -------------------------------------------------------------------------------- 1 | package cachetype 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | type Type string 9 | 10 | const ( 11 | None Type = "none" 12 | Local Type = "local" 13 | Artifactory Type = "artifactory" 14 | ) 15 | 16 | var ErrInvalidType = errors.New("invalid type") 17 | 18 | func (v *Type) UnmarshalText(text []byte) error { 19 | switch Type(text) { 20 | case None: 21 | *v = None 22 | case Local: 23 | *v = Local 24 | case Artifactory: 25 | *v = Artifactory 26 | default: 27 | return fmt.Errorf("%q: %w", text, ErrInvalidType) 28 | } 29 | 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /cmd/easyp/internal/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "net/netip" 5 | 6 | "github.com/easyp-tech/server/cmd/easyp/internal/config/cachetype" 7 | ) 8 | 9 | type Config struct { 10 | Listen netip.AddrPort `json:"listen"` 11 | Domain string `json:"domain"` 12 | TLS TLSConfig `json:"tls"` 13 | Cache Cache `json:"cache"` 14 | Proxy Proxy `json:"proxy"` 15 | Local LocalGit `json:"local"` 16 | } 17 | 18 | type TLSConfig struct { 19 | CertFile string `json:"cert"` 20 | KeyFile string `json:"key"` 21 | CACertFile string `json:"ca"` 22 | } 23 | 24 | type LocalGit struct { 25 | Storage string `json:"storage"` 26 | Repos []Repo `json:"repo"` 27 | } 28 | 29 | type Proxy struct { 30 | Github []GithubRepo `json:"github"` 31 | BitBucket []BitBucketRepo `json:"bitbucket"` 32 | } 33 | 34 | type GithubRepo struct { 35 | Repo Repo `json:"repo"` 36 | AccessToken string `json:"token"` 37 | } 38 | 39 | type BitBucketRepo struct { 40 | Repo Repo `json:"repo"` 41 | User string `json:"user"` 42 | AccessToken string `json:"token"` 43 | BaseURL URL `json:"url"` 44 | } 45 | 46 | type Repo struct { 47 | Owner string `json:"owner"` 48 | Name string `json:"name"` 49 | Prefixes []string `json:"prefix"` 50 | Paths []string `json:"path"` 51 | } 52 | 53 | type Cache struct { 54 | Type cachetype.Type `json:"type"` 55 | Local CacheLocal `json:"local"` 56 | Artifactory Artifactory `json:"artifactory"` 57 | } 58 | 59 | type CacheLocal struct { 60 | Dir string `json:"directory"` 61 | } 62 | 63 | type Artifactory struct { 64 | User string `json:"user"` 65 | AccessToken string `json:"token"` 66 | BaseURL URL `json:"url"` 67 | } 68 | -------------------------------------------------------------------------------- /cmd/easyp/internal/config/read.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/ghodss/yaml" 8 | ) 9 | 10 | func ReadYaml[T any](fileName string) (T, error) { 11 | dst := new(T) 12 | 13 | data, err := os.ReadFile(fileName) 14 | if err != nil { 15 | return *dst, fmt.Errorf("reading %q: %w", fileName, err) 16 | } 17 | 18 | replaced := os.ExpandEnv(string(data)) 19 | if err = yaml.Unmarshal([]byte(replaced), dst); err != nil { 20 | return *dst, fmt.Errorf("parsing %q: %w", fileName, err) 21 | } 22 | 23 | return *dst, nil 24 | } 25 | -------------------------------------------------------------------------------- /cmd/easyp/internal/config/url.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "fmt" 5 | "net/url" 6 | ) 7 | 8 | type URL struct { 9 | url.URL 10 | } 11 | 12 | func (u *URL) UnmarshalText(text []byte) error { 13 | p, err := url.Parse(string(text)) 14 | if err != nil { 15 | return fmt.Errorf("parsing URL: %w", err) 16 | } 17 | 18 | u.URL = *p 19 | 20 | return nil 21 | } 22 | -------------------------------------------------------------------------------- /cmd/easyp/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "net/http" 6 | "os" 7 | 8 | "golang.org/x/exp/slog" 9 | 10 | "github.com/easyp-tech/server/cmd/easyp/internal/config" 11 | "github.com/easyp-tech/server/cmd/easyp/internal/config/cachetype" 12 | "github.com/easyp-tech/server/internal/connect" 13 | "github.com/easyp-tech/server/internal/https" 14 | "github.com/easyp-tech/server/internal/logger" 15 | "github.com/easyp-tech/server/internal/providers/bitbucket" 16 | "github.com/easyp-tech/server/internal/providers/cache" 17 | "github.com/easyp-tech/server/internal/providers/cache/artifactory" 18 | "github.com/easyp-tech/server/internal/providers/filter" 19 | "github.com/easyp-tech/server/internal/providers/github" 20 | "github.com/easyp-tech/server/internal/providers/localgit" 21 | "github.com/easyp-tech/server/internal/providers/localgit/namedlocks" 22 | "github.com/easyp-tech/server/internal/providers/multisource" 23 | ) 24 | 25 | //nolint:gochecknoglobals 26 | var ( 27 | cfgFile = flag.String("cfg", "./local.config.yml", "path to Config file") 28 | debug = flag.Bool("debug", false, "enable debug logging") 29 | ) 30 | 31 | const ( 32 | minNumberOfRepos = 128 33 | ) 34 | 35 | func main() { 36 | flag.Parse() 37 | 38 | var ( 39 | cfg = must(config.ReadYaml[config.Config](*cfgFile)) 40 | log = logger.New(*debug) 41 | nameLock = namedlocks.New(minNumberOfRepos) 42 | cache = buildCache(log, cfg.Cache) 43 | storage = multisource.New( 44 | log, 45 | cache, 46 | localgit.New(cfg.Local.Storage, filterRepos(cfg.Local.Repos), nameLock), 47 | bbProxy(log, cfg.Proxy.BitBucket), 48 | githubProxy(log, cfg.Proxy.Github), 49 | ) 50 | handler = connect.New(log, storage, cfg.Domain) 51 | serve = func() error { return http.ListenAndServe(cfg.Listen.String(), handler) } //nolint:gosec 52 | ) 53 | 54 | log.Debug("started", slog.Any("config", cfg)) 55 | 56 | if cfg.TLS.CertFile != "" { 57 | serve = func() error { 58 | return https.ListenAndServe(cfg.Listen, handler, cfg.TLS.CertFile, cfg.TLS.KeyFile, cfg.TLS.CACertFile) 59 | } 60 | } 61 | 62 | if err := serve(); err != nil { 63 | log.Error("shutdown", slog.String("error", err.Error())) 64 | os.Exit(1) 65 | } 66 | } 67 | 68 | func must[T any](v T, err error) T { 69 | if err != nil { 70 | panic(err) 71 | } 72 | 73 | return v 74 | } 75 | 76 | func githubProxy(log *slog.Logger, defs []config.GithubRepo) multisource.Source { //nolint:ireturn 77 | repos := make([]github.Repo, 0, len(defs)) 78 | for _, def := range defs { 79 | repos = append( 80 | repos, 81 | github.Repo{ 82 | Token: def.AccessToken, 83 | Repo: filter.Repo{ 84 | Owner: def.Repo.Owner, 85 | Name: def.Repo.Name, 86 | Prefixes: def.Repo.Prefixes, 87 | Paths: def.Repo.Paths, 88 | }, 89 | }, 90 | ) 91 | } 92 | 93 | return github.NewMultiRepo(log, repos) 94 | } 95 | 96 | func bbProxy(log *slog.Logger, defs []config.BitBucketRepo) multisource.Source { //nolint:ireturn 97 | repos := make([]bitbucket.Repo, 0, len(defs)) 98 | for _, def := range defs { 99 | repos = append( 100 | repos, 101 | bitbucket.Repo{ 102 | User: bitbucket.User(def.User), 103 | Password: bitbucket.Password(def.AccessToken), 104 | URL: def.BaseURL.URL, 105 | Repo: filter.Repo{ 106 | Owner: def.Repo.Owner, 107 | Name: def.Repo.Name, 108 | Prefixes: def.Repo.Prefixes, 109 | Paths: def.Repo.Paths, 110 | }, 111 | }, 112 | ) 113 | } 114 | 115 | return bitbucket.NewMultiRepo(log, repos) 116 | } 117 | 118 | func filterRepos(defs []config.Repo) []filter.Repo { 119 | repos := make([]filter.Repo, 0, len(defs)) 120 | for _, def := range defs { 121 | repos = append( 122 | repos, 123 | filter.Repo{ 124 | Owner: def.Owner, 125 | Name: def.Name, 126 | Prefixes: def.Prefixes, 127 | Paths: def.Paths, 128 | }, 129 | ) 130 | } 131 | 132 | return repos 133 | } 134 | 135 | func buildCache(log *slog.Logger, cfg config.Cache) multisource.Cache { //nolint:ireturn 136 | switch cfg.Type { 137 | case cachetype.None: 138 | return cache.Noop{} 139 | case cachetype.Local: 140 | return cache.Local{Dir: cfg.Local.Dir} 141 | case cachetype.Artifactory: 142 | return artifactory.New( 143 | log, 144 | cfg.Artifactory.BaseURL.String(), 145 | cfg.Artifactory.User, 146 | cfg.Artifactory.AccessToken, 147 | ) 148 | default: 149 | panic("unreachable reached") 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/audit/v1alpha1/service_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/audit/v1alpha1/service.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | AuditService_ListAuditedEvents_FullMethodName = "/buf.alpha.audit.v1alpha1.AuditService/ListAuditedEvents" 37 | ) 38 | 39 | // AuditServiceClient is the client API for AuditService service. 40 | // 41 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 42 | type AuditServiceClient interface { 43 | // ListAuditedEvents lists audited events recorded in the BSR instance. 44 | ListAuditedEvents(ctx context.Context, in *ListAuditedEventsRequest, opts ...grpc.CallOption) (*ListAuditedEventsResponse, error) 45 | } 46 | 47 | type auditServiceClient struct { 48 | cc grpc.ClientConnInterface 49 | } 50 | 51 | func NewAuditServiceClient(cc grpc.ClientConnInterface) AuditServiceClient { 52 | return &auditServiceClient{cc} 53 | } 54 | 55 | func (c *auditServiceClient) ListAuditedEvents(ctx context.Context, in *ListAuditedEventsRequest, opts ...grpc.CallOption) (*ListAuditedEventsResponse, error) { 56 | out := new(ListAuditedEventsResponse) 57 | err := c.cc.Invoke(ctx, AuditService_ListAuditedEvents_FullMethodName, in, out, opts...) 58 | if err != nil { 59 | return nil, err 60 | } 61 | return out, nil 62 | } 63 | 64 | // AuditServiceServer is the server API for AuditService service. 65 | // All implementations should embed UnimplementedAuditServiceServer 66 | // for forward compatibility 67 | type AuditServiceServer interface { 68 | // ListAuditedEvents lists audited events recorded in the BSR instance. 69 | ListAuditedEvents(context.Context, *ListAuditedEventsRequest) (*ListAuditedEventsResponse, error) 70 | } 71 | 72 | // UnimplementedAuditServiceServer should be embedded to have forward compatible implementations. 73 | type UnimplementedAuditServiceServer struct { 74 | } 75 | 76 | func (UnimplementedAuditServiceServer) ListAuditedEvents(context.Context, *ListAuditedEventsRequest) (*ListAuditedEventsResponse, error) { 77 | return nil, status.Errorf(codes.Unimplemented, "method ListAuditedEvents not implemented") 78 | } 79 | 80 | // UnsafeAuditServiceServer may be embedded to opt out of forward compatibility for this service. 81 | // Use of this interface is not recommended, as added methods to AuditServiceServer will 82 | // result in compilation errors. 83 | type UnsafeAuditServiceServer interface { 84 | mustEmbedUnimplementedAuditServiceServer() 85 | } 86 | 87 | func RegisterAuditServiceServer(s grpc.ServiceRegistrar, srv AuditServiceServer) { 88 | s.RegisterService(&AuditService_ServiceDesc, srv) 89 | } 90 | 91 | func _AuditService_ListAuditedEvents_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 92 | in := new(ListAuditedEventsRequest) 93 | if err := dec(in); err != nil { 94 | return nil, err 95 | } 96 | if interceptor == nil { 97 | return srv.(AuditServiceServer).ListAuditedEvents(ctx, in) 98 | } 99 | info := &grpc.UnaryServerInfo{ 100 | Server: srv, 101 | FullMethod: AuditService_ListAuditedEvents_FullMethodName, 102 | } 103 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 104 | return srv.(AuditServiceServer).ListAuditedEvents(ctx, req.(*ListAuditedEventsRequest)) 105 | } 106 | return interceptor(ctx, in, info, handler) 107 | } 108 | 109 | // AuditService_ServiceDesc is the grpc.ServiceDesc for AuditService service. 110 | // It's only intended for direct use with grpc.RegisterService, 111 | // and not to be introspected or modified (even as a copy) 112 | var AuditService_ServiceDesc = grpc.ServiceDesc{ 113 | ServiceName: "buf.alpha.audit.v1alpha1.AuditService", 114 | HandlerType: (*AuditServiceServer)(nil), 115 | Methods: []grpc.MethodDesc{ 116 | { 117 | MethodName: "ListAuditedEvents", 118 | Handler: _AuditService_ListAuditedEvents_Handler, 119 | }, 120 | }, 121 | Streams: []grpc.StreamDesc{}, 122 | Metadata: "buf/alpha/audit/v1alpha1/service.proto", 123 | } 124 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/audit/v1alpha1/v1alpha1connect/service.connect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-connect-go. DO NOT EDIT. 16 | // 17 | // Source: buf/alpha/audit/v1alpha1/service.proto 18 | 19 | package v1alpha1connect 20 | 21 | import ( 22 | connect "connectrpc.com/connect" 23 | context "context" 24 | errors "errors" 25 | v1alpha1 "github.com/easyp-tech/server/gen/proto/buf/alpha/audit/v1alpha1" 26 | http "net/http" 27 | strings "strings" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file and the connect package are 31 | // compatible. If you get a compiler error that this constant is not defined, this code was 32 | // generated with a version of connect newer than the one compiled into your binary. You can fix the 33 | // problem by either regenerating this code with an older version of connect or updating the connect 34 | // version compiled into your binary. 35 | const _ = connect.IsAtLeastVersion1_7_0 36 | 37 | const ( 38 | // AuditServiceName is the fully-qualified name of the AuditService service. 39 | AuditServiceName = "buf.alpha.audit.v1alpha1.AuditService" 40 | ) 41 | 42 | // These constants are the fully-qualified names of the RPCs defined in this package. They're 43 | // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. 44 | // 45 | // Note that these are different from the fully-qualified method names used by 46 | // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to 47 | // reflection-formatted method names, remove the leading slash and convert the remaining slash to a 48 | // period. 49 | const ( 50 | // AuditServiceListAuditedEventsProcedure is the fully-qualified name of the AuditService's 51 | // ListAuditedEvents RPC. 52 | AuditServiceListAuditedEventsProcedure = "/buf.alpha.audit.v1alpha1.AuditService/ListAuditedEvents" 53 | ) 54 | 55 | // AuditServiceClient is a client for the buf.alpha.audit.v1alpha1.AuditService service. 56 | type AuditServiceClient interface { 57 | // ListAuditedEvents lists audited events recorded in the BSR instance. 58 | ListAuditedEvents(context.Context, *connect.Request[v1alpha1.ListAuditedEventsRequest]) (*connect.Response[v1alpha1.ListAuditedEventsResponse], error) 59 | } 60 | 61 | // NewAuditServiceClient constructs a client for the buf.alpha.audit.v1alpha1.AuditService service. 62 | // By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped 63 | // responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the 64 | // connect.WithGRPC() or connect.WithGRPCWeb() options. 65 | // 66 | // The URL supplied here should be the base URL for the Connect or gRPC server (for example, 67 | // http://api.acme.com or https://acme.com/grpc). 68 | func NewAuditServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) AuditServiceClient { 69 | baseURL = strings.TrimRight(baseURL, "/") 70 | return &auditServiceClient{ 71 | listAuditedEvents: connect.NewClient[v1alpha1.ListAuditedEventsRequest, v1alpha1.ListAuditedEventsResponse]( 72 | httpClient, 73 | baseURL+AuditServiceListAuditedEventsProcedure, 74 | connect.WithIdempotency(connect.IdempotencyNoSideEffects), 75 | connect.WithClientOptions(opts...), 76 | ), 77 | } 78 | } 79 | 80 | // auditServiceClient implements AuditServiceClient. 81 | type auditServiceClient struct { 82 | listAuditedEvents *connect.Client[v1alpha1.ListAuditedEventsRequest, v1alpha1.ListAuditedEventsResponse] 83 | } 84 | 85 | // ListAuditedEvents calls buf.alpha.audit.v1alpha1.AuditService.ListAuditedEvents. 86 | func (c *auditServiceClient) ListAuditedEvents(ctx context.Context, req *connect.Request[v1alpha1.ListAuditedEventsRequest]) (*connect.Response[v1alpha1.ListAuditedEventsResponse], error) { 87 | return c.listAuditedEvents.CallUnary(ctx, req) 88 | } 89 | 90 | // AuditServiceHandler is an implementation of the buf.alpha.audit.v1alpha1.AuditService service. 91 | type AuditServiceHandler interface { 92 | // ListAuditedEvents lists audited events recorded in the BSR instance. 93 | ListAuditedEvents(context.Context, *connect.Request[v1alpha1.ListAuditedEventsRequest]) (*connect.Response[v1alpha1.ListAuditedEventsResponse], error) 94 | } 95 | 96 | // NewAuditServiceHandler builds an HTTP handler from the service implementation. It returns the 97 | // path on which to mount the handler and the handler itself. 98 | // 99 | // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf 100 | // and JSON codecs. They also support gzip compression. 101 | func NewAuditServiceHandler(svc AuditServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { 102 | auditServiceListAuditedEventsHandler := connect.NewUnaryHandler( 103 | AuditServiceListAuditedEventsProcedure, 104 | svc.ListAuditedEvents, 105 | connect.WithIdempotency(connect.IdempotencyNoSideEffects), 106 | connect.WithHandlerOptions(opts...), 107 | ) 108 | return "/buf.alpha.audit.v1alpha1.AuditService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 109 | switch r.URL.Path { 110 | case AuditServiceListAuditedEventsProcedure: 111 | auditServiceListAuditedEventsHandler.ServeHTTP(w, r) 112 | default: 113 | http.NotFound(w, r) 114 | } 115 | }) 116 | } 117 | 118 | // UnimplementedAuditServiceHandler returns CodeUnimplemented from all methods. 119 | type UnimplementedAuditServiceHandler struct{} 120 | 121 | func (UnimplementedAuditServiceHandler) ListAuditedEvents(context.Context, *connect.Request[v1alpha1.ListAuditedEventsRequest]) (*connect.Response[v1alpha1.ListAuditedEventsResponse], error) { 122 | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("buf.alpha.audit.v1alpha1.AuditService.ListAuditedEvents is not implemented")) 123 | } 124 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/authn_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/registry/v1alpha1/authn.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | AuthnService_GetCurrentUser_FullMethodName = "/buf.alpha.registry.v1alpha1.AuthnService/GetCurrentUser" 37 | AuthnService_GetCurrentUserSubject_FullMethodName = "/buf.alpha.registry.v1alpha1.AuthnService/GetCurrentUserSubject" 38 | ) 39 | 40 | // AuthnServiceClient is the client API for AuthnService service. 41 | // 42 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 43 | type AuthnServiceClient interface { 44 | // GetCurrentUser gets information associated with the current user. 45 | // 46 | // The user's ID is retrieved from the request's authentication header. 47 | GetCurrentUser(ctx context.Context, in *GetCurrentUserRequest, opts ...grpc.CallOption) (*GetCurrentUserResponse, error) 48 | // GetCurrentUserSubject gets the currently logged in users subject. 49 | // 50 | // The user's ID is retrieved from the request's authentication header. 51 | GetCurrentUserSubject(ctx context.Context, in *GetCurrentUserSubjectRequest, opts ...grpc.CallOption) (*GetCurrentUserSubjectResponse, error) 52 | } 53 | 54 | type authnServiceClient struct { 55 | cc grpc.ClientConnInterface 56 | } 57 | 58 | func NewAuthnServiceClient(cc grpc.ClientConnInterface) AuthnServiceClient { 59 | return &authnServiceClient{cc} 60 | } 61 | 62 | func (c *authnServiceClient) GetCurrentUser(ctx context.Context, in *GetCurrentUserRequest, opts ...grpc.CallOption) (*GetCurrentUserResponse, error) { 63 | out := new(GetCurrentUserResponse) 64 | err := c.cc.Invoke(ctx, AuthnService_GetCurrentUser_FullMethodName, in, out, opts...) 65 | if err != nil { 66 | return nil, err 67 | } 68 | return out, nil 69 | } 70 | 71 | func (c *authnServiceClient) GetCurrentUserSubject(ctx context.Context, in *GetCurrentUserSubjectRequest, opts ...grpc.CallOption) (*GetCurrentUserSubjectResponse, error) { 72 | out := new(GetCurrentUserSubjectResponse) 73 | err := c.cc.Invoke(ctx, AuthnService_GetCurrentUserSubject_FullMethodName, in, out, opts...) 74 | if err != nil { 75 | return nil, err 76 | } 77 | return out, nil 78 | } 79 | 80 | // AuthnServiceServer is the server API for AuthnService service. 81 | // All implementations should embed UnimplementedAuthnServiceServer 82 | // for forward compatibility 83 | type AuthnServiceServer interface { 84 | // GetCurrentUser gets information associated with the current user. 85 | // 86 | // The user's ID is retrieved from the request's authentication header. 87 | GetCurrentUser(context.Context, *GetCurrentUserRequest) (*GetCurrentUserResponse, error) 88 | // GetCurrentUserSubject gets the currently logged in users subject. 89 | // 90 | // The user's ID is retrieved from the request's authentication header. 91 | GetCurrentUserSubject(context.Context, *GetCurrentUserSubjectRequest) (*GetCurrentUserSubjectResponse, error) 92 | } 93 | 94 | // UnimplementedAuthnServiceServer should be embedded to have forward compatible implementations. 95 | type UnimplementedAuthnServiceServer struct { 96 | } 97 | 98 | func (UnimplementedAuthnServiceServer) GetCurrentUser(context.Context, *GetCurrentUserRequest) (*GetCurrentUserResponse, error) { 99 | return nil, status.Errorf(codes.Unimplemented, "method GetCurrentUser not implemented") 100 | } 101 | func (UnimplementedAuthnServiceServer) GetCurrentUserSubject(context.Context, *GetCurrentUserSubjectRequest) (*GetCurrentUserSubjectResponse, error) { 102 | return nil, status.Errorf(codes.Unimplemented, "method GetCurrentUserSubject not implemented") 103 | } 104 | 105 | // UnsafeAuthnServiceServer may be embedded to opt out of forward compatibility for this service. 106 | // Use of this interface is not recommended, as added methods to AuthnServiceServer will 107 | // result in compilation errors. 108 | type UnsafeAuthnServiceServer interface { 109 | mustEmbedUnimplementedAuthnServiceServer() 110 | } 111 | 112 | func RegisterAuthnServiceServer(s grpc.ServiceRegistrar, srv AuthnServiceServer) { 113 | s.RegisterService(&AuthnService_ServiceDesc, srv) 114 | } 115 | 116 | func _AuthnService_GetCurrentUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 117 | in := new(GetCurrentUserRequest) 118 | if err := dec(in); err != nil { 119 | return nil, err 120 | } 121 | if interceptor == nil { 122 | return srv.(AuthnServiceServer).GetCurrentUser(ctx, in) 123 | } 124 | info := &grpc.UnaryServerInfo{ 125 | Server: srv, 126 | FullMethod: AuthnService_GetCurrentUser_FullMethodName, 127 | } 128 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 129 | return srv.(AuthnServiceServer).GetCurrentUser(ctx, req.(*GetCurrentUserRequest)) 130 | } 131 | return interceptor(ctx, in, info, handler) 132 | } 133 | 134 | func _AuthnService_GetCurrentUserSubject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 135 | in := new(GetCurrentUserSubjectRequest) 136 | if err := dec(in); err != nil { 137 | return nil, err 138 | } 139 | if interceptor == nil { 140 | return srv.(AuthnServiceServer).GetCurrentUserSubject(ctx, in) 141 | } 142 | info := &grpc.UnaryServerInfo{ 143 | Server: srv, 144 | FullMethod: AuthnService_GetCurrentUserSubject_FullMethodName, 145 | } 146 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 147 | return srv.(AuthnServiceServer).GetCurrentUserSubject(ctx, req.(*GetCurrentUserSubjectRequest)) 148 | } 149 | return interceptor(ctx, in, info, handler) 150 | } 151 | 152 | // AuthnService_ServiceDesc is the grpc.ServiceDesc for AuthnService service. 153 | // It's only intended for direct use with grpc.RegisterService, 154 | // and not to be introspected or modified (even as a copy) 155 | var AuthnService_ServiceDesc = grpc.ServiceDesc{ 156 | ServiceName: "buf.alpha.registry.v1alpha1.AuthnService", 157 | HandlerType: (*AuthnServiceServer)(nil), 158 | Methods: []grpc.MethodDesc{ 159 | { 160 | MethodName: "GetCurrentUser", 161 | Handler: _AuthnService_GetCurrentUser_Handler, 162 | }, 163 | { 164 | MethodName: "GetCurrentUserSubject", 165 | Handler: _AuthnService_GetCurrentUserSubject_Handler, 166 | }, 167 | }, 168 | Streams: []grpc.StreamDesc{}, 169 | Metadata: "buf/alpha/registry/v1alpha1/authn.proto", 170 | } 171 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/convert_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/registry/v1alpha1/convert.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | ConvertService_Convert_FullMethodName = "/buf.alpha.registry.v1alpha1.ConvertService/Convert" 37 | ) 38 | 39 | // ConvertServiceClient is the client API for ConvertService service. 40 | // 41 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 42 | type ConvertServiceClient interface { 43 | // Convert converts a serialized message according to 44 | // the provided type name using an image. 45 | Convert(ctx context.Context, in *ConvertRequest, opts ...grpc.CallOption) (*ConvertResponse, error) 46 | } 47 | 48 | type convertServiceClient struct { 49 | cc grpc.ClientConnInterface 50 | } 51 | 52 | func NewConvertServiceClient(cc grpc.ClientConnInterface) ConvertServiceClient { 53 | return &convertServiceClient{cc} 54 | } 55 | 56 | func (c *convertServiceClient) Convert(ctx context.Context, in *ConvertRequest, opts ...grpc.CallOption) (*ConvertResponse, error) { 57 | out := new(ConvertResponse) 58 | err := c.cc.Invoke(ctx, ConvertService_Convert_FullMethodName, in, out, opts...) 59 | if err != nil { 60 | return nil, err 61 | } 62 | return out, nil 63 | } 64 | 65 | // ConvertServiceServer is the server API for ConvertService service. 66 | // All implementations should embed UnimplementedConvertServiceServer 67 | // for forward compatibility 68 | type ConvertServiceServer interface { 69 | // Convert converts a serialized message according to 70 | // the provided type name using an image. 71 | Convert(context.Context, *ConvertRequest) (*ConvertResponse, error) 72 | } 73 | 74 | // UnimplementedConvertServiceServer should be embedded to have forward compatible implementations. 75 | type UnimplementedConvertServiceServer struct { 76 | } 77 | 78 | func (UnimplementedConvertServiceServer) Convert(context.Context, *ConvertRequest) (*ConvertResponse, error) { 79 | return nil, status.Errorf(codes.Unimplemented, "method Convert not implemented") 80 | } 81 | 82 | // UnsafeConvertServiceServer may be embedded to opt out of forward compatibility for this service. 83 | // Use of this interface is not recommended, as added methods to ConvertServiceServer will 84 | // result in compilation errors. 85 | type UnsafeConvertServiceServer interface { 86 | mustEmbedUnimplementedConvertServiceServer() 87 | } 88 | 89 | func RegisterConvertServiceServer(s grpc.ServiceRegistrar, srv ConvertServiceServer) { 90 | s.RegisterService(&ConvertService_ServiceDesc, srv) 91 | } 92 | 93 | func _ConvertService_Convert_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 94 | in := new(ConvertRequest) 95 | if err := dec(in); err != nil { 96 | return nil, err 97 | } 98 | if interceptor == nil { 99 | return srv.(ConvertServiceServer).Convert(ctx, in) 100 | } 101 | info := &grpc.UnaryServerInfo{ 102 | Server: srv, 103 | FullMethod: ConvertService_Convert_FullMethodName, 104 | } 105 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 106 | return srv.(ConvertServiceServer).Convert(ctx, req.(*ConvertRequest)) 107 | } 108 | return interceptor(ctx, in, info, handler) 109 | } 110 | 111 | // ConvertService_ServiceDesc is the grpc.ServiceDesc for ConvertService service. 112 | // It's only intended for direct use with grpc.RegisterService, 113 | // and not to be introspected or modified (even as a copy) 114 | var ConvertService_ServiceDesc = grpc.ServiceDesc{ 115 | ServiceName: "buf.alpha.registry.v1alpha1.ConvertService", 116 | HandlerType: (*ConvertServiceServer)(nil), 117 | Methods: []grpc.MethodDesc{ 118 | { 119 | MethodName: "Convert", 120 | Handler: _ConvertService_Convert_Handler, 121 | }, 122 | }, 123 | Streams: []grpc.StreamDesc{}, 124 | Metadata: "buf/alpha/registry/v1alpha1/convert.proto", 125 | } 126 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/download_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/registry/v1alpha1/download.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | DownloadService_Download_FullMethodName = "/buf.alpha.registry.v1alpha1.DownloadService/Download" 37 | DownloadService_DownloadManifestAndBlobs_FullMethodName = "/buf.alpha.registry.v1alpha1.DownloadService/DownloadManifestAndBlobs" 38 | ) 39 | 40 | // DownloadServiceClient is the client API for DownloadService service. 41 | // 42 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 43 | type DownloadServiceClient interface { 44 | // Download downloads a BSR module. 45 | // NOTE: Newer clients should use DownloadManifestAndBlobs instead. 46 | Download(ctx context.Context, in *DownloadRequest, opts ...grpc.CallOption) (*DownloadResponse, error) 47 | // DownloadManifestAndBlobs downloads a module in the manifest+blobs encoding format. 48 | DownloadManifestAndBlobs(ctx context.Context, in *DownloadManifestAndBlobsRequest, opts ...grpc.CallOption) (*DownloadManifestAndBlobsResponse, error) 49 | } 50 | 51 | type downloadServiceClient struct { 52 | cc grpc.ClientConnInterface 53 | } 54 | 55 | func NewDownloadServiceClient(cc grpc.ClientConnInterface) DownloadServiceClient { 56 | return &downloadServiceClient{cc} 57 | } 58 | 59 | func (c *downloadServiceClient) Download(ctx context.Context, in *DownloadRequest, opts ...grpc.CallOption) (*DownloadResponse, error) { 60 | out := new(DownloadResponse) 61 | err := c.cc.Invoke(ctx, DownloadService_Download_FullMethodName, in, out, opts...) 62 | if err != nil { 63 | return nil, err 64 | } 65 | return out, nil 66 | } 67 | 68 | func (c *downloadServiceClient) DownloadManifestAndBlobs(ctx context.Context, in *DownloadManifestAndBlobsRequest, opts ...grpc.CallOption) (*DownloadManifestAndBlobsResponse, error) { 69 | out := new(DownloadManifestAndBlobsResponse) 70 | err := c.cc.Invoke(ctx, DownloadService_DownloadManifestAndBlobs_FullMethodName, in, out, opts...) 71 | if err != nil { 72 | return nil, err 73 | } 74 | return out, nil 75 | } 76 | 77 | // DownloadServiceServer is the server API for DownloadService service. 78 | // All implementations should embed UnimplementedDownloadServiceServer 79 | // for forward compatibility 80 | type DownloadServiceServer interface { 81 | // Download downloads a BSR module. 82 | // NOTE: Newer clients should use DownloadManifestAndBlobs instead. 83 | Download(context.Context, *DownloadRequest) (*DownloadResponse, error) 84 | // DownloadManifestAndBlobs downloads a module in the manifest+blobs encoding format. 85 | DownloadManifestAndBlobs(context.Context, *DownloadManifestAndBlobsRequest) (*DownloadManifestAndBlobsResponse, error) 86 | } 87 | 88 | // UnimplementedDownloadServiceServer should be embedded to have forward compatible implementations. 89 | type UnimplementedDownloadServiceServer struct { 90 | } 91 | 92 | func (UnimplementedDownloadServiceServer) Download(context.Context, *DownloadRequest) (*DownloadResponse, error) { 93 | return nil, status.Errorf(codes.Unimplemented, "method Download not implemented") 94 | } 95 | func (UnimplementedDownloadServiceServer) DownloadManifestAndBlobs(context.Context, *DownloadManifestAndBlobsRequest) (*DownloadManifestAndBlobsResponse, error) { 96 | return nil, status.Errorf(codes.Unimplemented, "method DownloadManifestAndBlobs not implemented") 97 | } 98 | 99 | // UnsafeDownloadServiceServer may be embedded to opt out of forward compatibility for this service. 100 | // Use of this interface is not recommended, as added methods to DownloadServiceServer will 101 | // result in compilation errors. 102 | type UnsafeDownloadServiceServer interface { 103 | mustEmbedUnimplementedDownloadServiceServer() 104 | } 105 | 106 | func RegisterDownloadServiceServer(s grpc.ServiceRegistrar, srv DownloadServiceServer) { 107 | s.RegisterService(&DownloadService_ServiceDesc, srv) 108 | } 109 | 110 | func _DownloadService_Download_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 111 | in := new(DownloadRequest) 112 | if err := dec(in); err != nil { 113 | return nil, err 114 | } 115 | if interceptor == nil { 116 | return srv.(DownloadServiceServer).Download(ctx, in) 117 | } 118 | info := &grpc.UnaryServerInfo{ 119 | Server: srv, 120 | FullMethod: DownloadService_Download_FullMethodName, 121 | } 122 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 123 | return srv.(DownloadServiceServer).Download(ctx, req.(*DownloadRequest)) 124 | } 125 | return interceptor(ctx, in, info, handler) 126 | } 127 | 128 | func _DownloadService_DownloadManifestAndBlobs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 129 | in := new(DownloadManifestAndBlobsRequest) 130 | if err := dec(in); err != nil { 131 | return nil, err 132 | } 133 | if interceptor == nil { 134 | return srv.(DownloadServiceServer).DownloadManifestAndBlobs(ctx, in) 135 | } 136 | info := &grpc.UnaryServerInfo{ 137 | Server: srv, 138 | FullMethod: DownloadService_DownloadManifestAndBlobs_FullMethodName, 139 | } 140 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 141 | return srv.(DownloadServiceServer).DownloadManifestAndBlobs(ctx, req.(*DownloadManifestAndBlobsRequest)) 142 | } 143 | return interceptor(ctx, in, info, handler) 144 | } 145 | 146 | // DownloadService_ServiceDesc is the grpc.ServiceDesc for DownloadService service. 147 | // It's only intended for direct use with grpc.RegisterService, 148 | // and not to be introspected or modified (even as a copy) 149 | var DownloadService_ServiceDesc = grpc.ServiceDesc{ 150 | ServiceName: "buf.alpha.registry.v1alpha1.DownloadService", 151 | HandlerType: (*DownloadServiceServer)(nil), 152 | Methods: []grpc.MethodDesc{ 153 | { 154 | MethodName: "Download", 155 | Handler: _DownloadService_Download_Handler, 156 | }, 157 | { 158 | MethodName: "DownloadManifestAndBlobs", 159 | Handler: _DownloadService_DownloadManifestAndBlobs_Handler, 160 | }, 161 | }, 162 | Streams: []grpc.StreamDesc{}, 163 | Metadata: "buf/alpha/registry/v1alpha1/download.proto", 164 | } 165 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/github_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/registry/v1alpha1/github.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | GithubService_GetGithubAppConfig_FullMethodName = "/buf.alpha.registry.v1alpha1.GithubService/GetGithubAppConfig" 37 | ) 38 | 39 | // GithubServiceClient is the client API for GithubService service. 40 | // 41 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 42 | type GithubServiceClient interface { 43 | // GetGithubAppConfig returns a Github Application Configuration. 44 | GetGithubAppConfig(ctx context.Context, in *GetGithubAppConfigRequest, opts ...grpc.CallOption) (*GetGithubAppConfigResponse, error) 45 | } 46 | 47 | type githubServiceClient struct { 48 | cc grpc.ClientConnInterface 49 | } 50 | 51 | func NewGithubServiceClient(cc grpc.ClientConnInterface) GithubServiceClient { 52 | return &githubServiceClient{cc} 53 | } 54 | 55 | func (c *githubServiceClient) GetGithubAppConfig(ctx context.Context, in *GetGithubAppConfigRequest, opts ...grpc.CallOption) (*GetGithubAppConfigResponse, error) { 56 | out := new(GetGithubAppConfigResponse) 57 | err := c.cc.Invoke(ctx, GithubService_GetGithubAppConfig_FullMethodName, in, out, opts...) 58 | if err != nil { 59 | return nil, err 60 | } 61 | return out, nil 62 | } 63 | 64 | // GithubServiceServer is the server API for GithubService service. 65 | // All implementations should embed UnimplementedGithubServiceServer 66 | // for forward compatibility 67 | type GithubServiceServer interface { 68 | // GetGithubAppConfig returns a Github Application Configuration. 69 | GetGithubAppConfig(context.Context, *GetGithubAppConfigRequest) (*GetGithubAppConfigResponse, error) 70 | } 71 | 72 | // UnimplementedGithubServiceServer should be embedded to have forward compatible implementations. 73 | type UnimplementedGithubServiceServer struct { 74 | } 75 | 76 | func (UnimplementedGithubServiceServer) GetGithubAppConfig(context.Context, *GetGithubAppConfigRequest) (*GetGithubAppConfigResponse, error) { 77 | return nil, status.Errorf(codes.Unimplemented, "method GetGithubAppConfig not implemented") 78 | } 79 | 80 | // UnsafeGithubServiceServer may be embedded to opt out of forward compatibility for this service. 81 | // Use of this interface is not recommended, as added methods to GithubServiceServer will 82 | // result in compilation errors. 83 | type UnsafeGithubServiceServer interface { 84 | mustEmbedUnimplementedGithubServiceServer() 85 | } 86 | 87 | func RegisterGithubServiceServer(s grpc.ServiceRegistrar, srv GithubServiceServer) { 88 | s.RegisterService(&GithubService_ServiceDesc, srv) 89 | } 90 | 91 | func _GithubService_GetGithubAppConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 92 | in := new(GetGithubAppConfigRequest) 93 | if err := dec(in); err != nil { 94 | return nil, err 95 | } 96 | if interceptor == nil { 97 | return srv.(GithubServiceServer).GetGithubAppConfig(ctx, in) 98 | } 99 | info := &grpc.UnaryServerInfo{ 100 | Server: srv, 101 | FullMethod: GithubService_GetGithubAppConfig_FullMethodName, 102 | } 103 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 104 | return srv.(GithubServiceServer).GetGithubAppConfig(ctx, req.(*GetGithubAppConfigRequest)) 105 | } 106 | return interceptor(ctx, in, info, handler) 107 | } 108 | 109 | // GithubService_ServiceDesc is the grpc.ServiceDesc for GithubService service. 110 | // It's only intended for direct use with grpc.RegisterService, 111 | // and not to be introspected or modified (even as a copy) 112 | var GithubService_ServiceDesc = grpc.ServiceDesc{ 113 | ServiceName: "buf.alpha.registry.v1alpha1.GithubService", 114 | HandlerType: (*GithubServiceServer)(nil), 115 | Methods: []grpc.MethodDesc{ 116 | { 117 | MethodName: "GetGithubAppConfig", 118 | Handler: _GithubService_GetGithubAppConfig_Handler, 119 | }, 120 | }, 121 | Streams: []grpc.StreamDesc{}, 122 | Metadata: "buf/alpha/registry/v1alpha1/github.proto", 123 | } 124 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/image_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/registry/v1alpha1/image.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | ImageService_GetImage_FullMethodName = "/buf.alpha.registry.v1alpha1.ImageService/GetImage" 37 | ) 38 | 39 | // ImageServiceClient is the client API for ImageService service. 40 | // 41 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 42 | type ImageServiceClient interface { 43 | // GetImage serves a compiled image for the local module. It automatically 44 | // downloads dependencies if necessary. 45 | GetImage(ctx context.Context, in *GetImageRequest, opts ...grpc.CallOption) (*GetImageResponse, error) 46 | } 47 | 48 | type imageServiceClient struct { 49 | cc grpc.ClientConnInterface 50 | } 51 | 52 | func NewImageServiceClient(cc grpc.ClientConnInterface) ImageServiceClient { 53 | return &imageServiceClient{cc} 54 | } 55 | 56 | func (c *imageServiceClient) GetImage(ctx context.Context, in *GetImageRequest, opts ...grpc.CallOption) (*GetImageResponse, error) { 57 | out := new(GetImageResponse) 58 | err := c.cc.Invoke(ctx, ImageService_GetImage_FullMethodName, in, out, opts...) 59 | if err != nil { 60 | return nil, err 61 | } 62 | return out, nil 63 | } 64 | 65 | // ImageServiceServer is the server API for ImageService service. 66 | // All implementations should embed UnimplementedImageServiceServer 67 | // for forward compatibility 68 | type ImageServiceServer interface { 69 | // GetImage serves a compiled image for the local module. It automatically 70 | // downloads dependencies if necessary. 71 | GetImage(context.Context, *GetImageRequest) (*GetImageResponse, error) 72 | } 73 | 74 | // UnimplementedImageServiceServer should be embedded to have forward compatible implementations. 75 | type UnimplementedImageServiceServer struct { 76 | } 77 | 78 | func (UnimplementedImageServiceServer) GetImage(context.Context, *GetImageRequest) (*GetImageResponse, error) { 79 | return nil, status.Errorf(codes.Unimplemented, "method GetImage not implemented") 80 | } 81 | 82 | // UnsafeImageServiceServer may be embedded to opt out of forward compatibility for this service. 83 | // Use of this interface is not recommended, as added methods to ImageServiceServer will 84 | // result in compilation errors. 85 | type UnsafeImageServiceServer interface { 86 | mustEmbedUnimplementedImageServiceServer() 87 | } 88 | 89 | func RegisterImageServiceServer(s grpc.ServiceRegistrar, srv ImageServiceServer) { 90 | s.RegisterService(&ImageService_ServiceDesc, srv) 91 | } 92 | 93 | func _ImageService_GetImage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 94 | in := new(GetImageRequest) 95 | if err := dec(in); err != nil { 96 | return nil, err 97 | } 98 | if interceptor == nil { 99 | return srv.(ImageServiceServer).GetImage(ctx, in) 100 | } 101 | info := &grpc.UnaryServerInfo{ 102 | Server: srv, 103 | FullMethod: ImageService_GetImage_FullMethodName, 104 | } 105 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 106 | return srv.(ImageServiceServer).GetImage(ctx, req.(*GetImageRequest)) 107 | } 108 | return interceptor(ctx, in, info, handler) 109 | } 110 | 111 | // ImageService_ServiceDesc is the grpc.ServiceDesc for ImageService service. 112 | // It's only intended for direct use with grpc.RegisterService, 113 | // and not to be introspected or modified (even as a copy) 114 | var ImageService_ServiceDesc = grpc.ServiceDesc{ 115 | ServiceName: "buf.alpha.registry.v1alpha1.ImageService", 116 | HandlerType: (*ImageServiceServer)(nil), 117 | Methods: []grpc.MethodDesc{ 118 | { 119 | MethodName: "GetImage", 120 | Handler: _ImageService_GetImage_Handler, 121 | }, 122 | }, 123 | Streams: []grpc.StreamDesc{}, 124 | Metadata: "buf/alpha/registry/v1alpha1/image.proto", 125 | } 126 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/jsonschema_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/registry/v1alpha1/jsonschema.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | JSONSchemaService_GetJSONSchema_FullMethodName = "/buf.alpha.registry.v1alpha1.JSONSchemaService/GetJSONSchema" 37 | ) 38 | 39 | // JSONSchemaServiceClient is the client API for JSONSchemaService service. 40 | // 41 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 42 | type JSONSchemaServiceClient interface { 43 | // GetJSONSchema allows users to get an (approximate) json schema for a 44 | // protobuf type. 45 | GetJSONSchema(ctx context.Context, in *GetJSONSchemaRequest, opts ...grpc.CallOption) (*GetJSONSchemaResponse, error) 46 | } 47 | 48 | type jSONSchemaServiceClient struct { 49 | cc grpc.ClientConnInterface 50 | } 51 | 52 | func NewJSONSchemaServiceClient(cc grpc.ClientConnInterface) JSONSchemaServiceClient { 53 | return &jSONSchemaServiceClient{cc} 54 | } 55 | 56 | func (c *jSONSchemaServiceClient) GetJSONSchema(ctx context.Context, in *GetJSONSchemaRequest, opts ...grpc.CallOption) (*GetJSONSchemaResponse, error) { 57 | out := new(GetJSONSchemaResponse) 58 | err := c.cc.Invoke(ctx, JSONSchemaService_GetJSONSchema_FullMethodName, in, out, opts...) 59 | if err != nil { 60 | return nil, err 61 | } 62 | return out, nil 63 | } 64 | 65 | // JSONSchemaServiceServer is the server API for JSONSchemaService service. 66 | // All implementations should embed UnimplementedJSONSchemaServiceServer 67 | // for forward compatibility 68 | type JSONSchemaServiceServer interface { 69 | // GetJSONSchema allows users to get an (approximate) json schema for a 70 | // protobuf type. 71 | GetJSONSchema(context.Context, *GetJSONSchemaRequest) (*GetJSONSchemaResponse, error) 72 | } 73 | 74 | // UnimplementedJSONSchemaServiceServer should be embedded to have forward compatible implementations. 75 | type UnimplementedJSONSchemaServiceServer struct { 76 | } 77 | 78 | func (UnimplementedJSONSchemaServiceServer) GetJSONSchema(context.Context, *GetJSONSchemaRequest) (*GetJSONSchemaResponse, error) { 79 | return nil, status.Errorf(codes.Unimplemented, "method GetJSONSchema not implemented") 80 | } 81 | 82 | // UnsafeJSONSchemaServiceServer may be embedded to opt out of forward compatibility for this service. 83 | // Use of this interface is not recommended, as added methods to JSONSchemaServiceServer will 84 | // result in compilation errors. 85 | type UnsafeJSONSchemaServiceServer interface { 86 | mustEmbedUnimplementedJSONSchemaServiceServer() 87 | } 88 | 89 | func RegisterJSONSchemaServiceServer(s grpc.ServiceRegistrar, srv JSONSchemaServiceServer) { 90 | s.RegisterService(&JSONSchemaService_ServiceDesc, srv) 91 | } 92 | 93 | func _JSONSchemaService_GetJSONSchema_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 94 | in := new(GetJSONSchemaRequest) 95 | if err := dec(in); err != nil { 96 | return nil, err 97 | } 98 | if interceptor == nil { 99 | return srv.(JSONSchemaServiceServer).GetJSONSchema(ctx, in) 100 | } 101 | info := &grpc.UnaryServerInfo{ 102 | Server: srv, 103 | FullMethod: JSONSchemaService_GetJSONSchema_FullMethodName, 104 | } 105 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 106 | return srv.(JSONSchemaServiceServer).GetJSONSchema(ctx, req.(*GetJSONSchemaRequest)) 107 | } 108 | return interceptor(ctx, in, info, handler) 109 | } 110 | 111 | // JSONSchemaService_ServiceDesc is the grpc.ServiceDesc for JSONSchemaService service. 112 | // It's only intended for direct use with grpc.RegisterService, 113 | // and not to be introspected or modified (even as a copy) 114 | var JSONSchemaService_ServiceDesc = grpc.ServiceDesc{ 115 | ServiceName: "buf.alpha.registry.v1alpha1.JSONSchemaService", 116 | HandlerType: (*JSONSchemaServiceServer)(nil), 117 | Methods: []grpc.MethodDesc{ 118 | { 119 | MethodName: "GetJSONSchema", 120 | Handler: _JSONSchemaService_GetJSONSchema_Handler, 121 | }, 122 | }, 123 | Streams: []grpc.StreamDesc{}, 124 | Metadata: "buf/alpha/registry/v1alpha1/jsonschema.proto", 125 | } 126 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/owner_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/registry/v1alpha1/owner.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | OwnerService_GetOwnerByName_FullMethodName = "/buf.alpha.registry.v1alpha1.OwnerService/GetOwnerByName" 37 | ) 38 | 39 | // OwnerServiceClient is the client API for OwnerService service. 40 | // 41 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 42 | type OwnerServiceClient interface { 43 | // GetOwnerByName takes an owner name and returns the owner as 44 | // either a user or organization. 45 | GetOwnerByName(ctx context.Context, in *GetOwnerByNameRequest, opts ...grpc.CallOption) (*GetOwnerByNameResponse, error) 46 | } 47 | 48 | type ownerServiceClient struct { 49 | cc grpc.ClientConnInterface 50 | } 51 | 52 | func NewOwnerServiceClient(cc grpc.ClientConnInterface) OwnerServiceClient { 53 | return &ownerServiceClient{cc} 54 | } 55 | 56 | func (c *ownerServiceClient) GetOwnerByName(ctx context.Context, in *GetOwnerByNameRequest, opts ...grpc.CallOption) (*GetOwnerByNameResponse, error) { 57 | out := new(GetOwnerByNameResponse) 58 | err := c.cc.Invoke(ctx, OwnerService_GetOwnerByName_FullMethodName, in, out, opts...) 59 | if err != nil { 60 | return nil, err 61 | } 62 | return out, nil 63 | } 64 | 65 | // OwnerServiceServer is the server API for OwnerService service. 66 | // All implementations should embed UnimplementedOwnerServiceServer 67 | // for forward compatibility 68 | type OwnerServiceServer interface { 69 | // GetOwnerByName takes an owner name and returns the owner as 70 | // either a user or organization. 71 | GetOwnerByName(context.Context, *GetOwnerByNameRequest) (*GetOwnerByNameResponse, error) 72 | } 73 | 74 | // UnimplementedOwnerServiceServer should be embedded to have forward compatible implementations. 75 | type UnimplementedOwnerServiceServer struct { 76 | } 77 | 78 | func (UnimplementedOwnerServiceServer) GetOwnerByName(context.Context, *GetOwnerByNameRequest) (*GetOwnerByNameResponse, error) { 79 | return nil, status.Errorf(codes.Unimplemented, "method GetOwnerByName not implemented") 80 | } 81 | 82 | // UnsafeOwnerServiceServer may be embedded to opt out of forward compatibility for this service. 83 | // Use of this interface is not recommended, as added methods to OwnerServiceServer will 84 | // result in compilation errors. 85 | type UnsafeOwnerServiceServer interface { 86 | mustEmbedUnimplementedOwnerServiceServer() 87 | } 88 | 89 | func RegisterOwnerServiceServer(s grpc.ServiceRegistrar, srv OwnerServiceServer) { 90 | s.RegisterService(&OwnerService_ServiceDesc, srv) 91 | } 92 | 93 | func _OwnerService_GetOwnerByName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 94 | in := new(GetOwnerByNameRequest) 95 | if err := dec(in); err != nil { 96 | return nil, err 97 | } 98 | if interceptor == nil { 99 | return srv.(OwnerServiceServer).GetOwnerByName(ctx, in) 100 | } 101 | info := &grpc.UnaryServerInfo{ 102 | Server: srv, 103 | FullMethod: OwnerService_GetOwnerByName_FullMethodName, 104 | } 105 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 106 | return srv.(OwnerServiceServer).GetOwnerByName(ctx, req.(*GetOwnerByNameRequest)) 107 | } 108 | return interceptor(ctx, in, info, handler) 109 | } 110 | 111 | // OwnerService_ServiceDesc is the grpc.ServiceDesc for OwnerService service. 112 | // It's only intended for direct use with grpc.RegisterService, 113 | // and not to be introspected or modified (even as a copy) 114 | var OwnerService_ServiceDesc = grpc.ServiceDesc{ 115 | ServiceName: "buf.alpha.registry.v1alpha1.OwnerService", 116 | HandlerType: (*OwnerServiceServer)(nil), 117 | Methods: []grpc.MethodDesc{ 118 | { 119 | MethodName: "GetOwnerByName", 120 | Handler: _OwnerService_GetOwnerByName_Handler, 121 | }, 122 | }, 123 | Streams: []grpc.StreamDesc{}, 124 | Metadata: "buf/alpha/registry/v1alpha1/owner.proto", 125 | } 126 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/push_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/registry/v1alpha1/push.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | PushService_Push_FullMethodName = "/buf.alpha.registry.v1alpha1.PushService/Push" 37 | PushService_PushManifestAndBlobs_FullMethodName = "/buf.alpha.registry.v1alpha1.PushService/PushManifestAndBlobs" 38 | ) 39 | 40 | // PushServiceClient is the client API for PushService service. 41 | // 42 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 43 | type PushServiceClient interface { 44 | // Push pushes. 45 | // NOTE: Newer clients should use PushManifestAndBlobs. 46 | Push(ctx context.Context, in *PushRequest, opts ...grpc.CallOption) (*PushResponse, error) 47 | // PushManifestAndBlobs pushes a module by encoding it in a manifest and blobs format. 48 | PushManifestAndBlobs(ctx context.Context, in *PushManifestAndBlobsRequest, opts ...grpc.CallOption) (*PushManifestAndBlobsResponse, error) 49 | } 50 | 51 | type pushServiceClient struct { 52 | cc grpc.ClientConnInterface 53 | } 54 | 55 | func NewPushServiceClient(cc grpc.ClientConnInterface) PushServiceClient { 56 | return &pushServiceClient{cc} 57 | } 58 | 59 | func (c *pushServiceClient) Push(ctx context.Context, in *PushRequest, opts ...grpc.CallOption) (*PushResponse, error) { 60 | out := new(PushResponse) 61 | err := c.cc.Invoke(ctx, PushService_Push_FullMethodName, in, out, opts...) 62 | if err != nil { 63 | return nil, err 64 | } 65 | return out, nil 66 | } 67 | 68 | func (c *pushServiceClient) PushManifestAndBlobs(ctx context.Context, in *PushManifestAndBlobsRequest, opts ...grpc.CallOption) (*PushManifestAndBlobsResponse, error) { 69 | out := new(PushManifestAndBlobsResponse) 70 | err := c.cc.Invoke(ctx, PushService_PushManifestAndBlobs_FullMethodName, in, out, opts...) 71 | if err != nil { 72 | return nil, err 73 | } 74 | return out, nil 75 | } 76 | 77 | // PushServiceServer is the server API for PushService service. 78 | // All implementations should embed UnimplementedPushServiceServer 79 | // for forward compatibility 80 | type PushServiceServer interface { 81 | // Push pushes. 82 | // NOTE: Newer clients should use PushManifestAndBlobs. 83 | Push(context.Context, *PushRequest) (*PushResponse, error) 84 | // PushManifestAndBlobs pushes a module by encoding it in a manifest and blobs format. 85 | PushManifestAndBlobs(context.Context, *PushManifestAndBlobsRequest) (*PushManifestAndBlobsResponse, error) 86 | } 87 | 88 | // UnimplementedPushServiceServer should be embedded to have forward compatible implementations. 89 | type UnimplementedPushServiceServer struct { 90 | } 91 | 92 | func (UnimplementedPushServiceServer) Push(context.Context, *PushRequest) (*PushResponse, error) { 93 | return nil, status.Errorf(codes.Unimplemented, "method Push not implemented") 94 | } 95 | func (UnimplementedPushServiceServer) PushManifestAndBlobs(context.Context, *PushManifestAndBlobsRequest) (*PushManifestAndBlobsResponse, error) { 96 | return nil, status.Errorf(codes.Unimplemented, "method PushManifestAndBlobs not implemented") 97 | } 98 | 99 | // UnsafePushServiceServer may be embedded to opt out of forward compatibility for this service. 100 | // Use of this interface is not recommended, as added methods to PushServiceServer will 101 | // result in compilation errors. 102 | type UnsafePushServiceServer interface { 103 | mustEmbedUnimplementedPushServiceServer() 104 | } 105 | 106 | func RegisterPushServiceServer(s grpc.ServiceRegistrar, srv PushServiceServer) { 107 | s.RegisterService(&PushService_ServiceDesc, srv) 108 | } 109 | 110 | func _PushService_Push_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 111 | in := new(PushRequest) 112 | if err := dec(in); err != nil { 113 | return nil, err 114 | } 115 | if interceptor == nil { 116 | return srv.(PushServiceServer).Push(ctx, in) 117 | } 118 | info := &grpc.UnaryServerInfo{ 119 | Server: srv, 120 | FullMethod: PushService_Push_FullMethodName, 121 | } 122 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 123 | return srv.(PushServiceServer).Push(ctx, req.(*PushRequest)) 124 | } 125 | return interceptor(ctx, in, info, handler) 126 | } 127 | 128 | func _PushService_PushManifestAndBlobs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 129 | in := new(PushManifestAndBlobsRequest) 130 | if err := dec(in); err != nil { 131 | return nil, err 132 | } 133 | if interceptor == nil { 134 | return srv.(PushServiceServer).PushManifestAndBlobs(ctx, in) 135 | } 136 | info := &grpc.UnaryServerInfo{ 137 | Server: srv, 138 | FullMethod: PushService_PushManifestAndBlobs_FullMethodName, 139 | } 140 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 141 | return srv.(PushServiceServer).PushManifestAndBlobs(ctx, req.(*PushManifestAndBlobsRequest)) 142 | } 143 | return interceptor(ctx, in, info, handler) 144 | } 145 | 146 | // PushService_ServiceDesc is the grpc.ServiceDesc for PushService service. 147 | // It's only intended for direct use with grpc.RegisterService, 148 | // and not to be introspected or modified (even as a copy) 149 | var PushService_ServiceDesc = grpc.ServiceDesc{ 150 | ServiceName: "buf.alpha.registry.v1alpha1.PushService", 151 | HandlerType: (*PushServiceServer)(nil), 152 | Methods: []grpc.MethodDesc{ 153 | { 154 | MethodName: "Push", 155 | Handler: _PushService_Push_Handler, 156 | }, 157 | { 158 | MethodName: "PushManifestAndBlobs", 159 | Handler: _PushService_PushManifestAndBlobs_Handler, 160 | }, 161 | }, 162 | Streams: []grpc.StreamDesc{}, 163 | Metadata: "buf/alpha/registry/v1alpha1/push.proto", 164 | } 165 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/reference_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/registry/v1alpha1/reference.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | ReferenceService_GetReferenceByName_FullMethodName = "/buf.alpha.registry.v1alpha1.ReferenceService/GetReferenceByName" 37 | ReferenceService_ListGitCommitsForReference_FullMethodName = "/buf.alpha.registry.v1alpha1.ReferenceService/ListGitCommitsForReference" 38 | ) 39 | 40 | // ReferenceServiceClient is the client API for ReferenceService service. 41 | // 42 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 43 | type ReferenceServiceClient interface { 44 | // GetReferenceByName takes a reference name and returns the 45 | // reference either as 'main', a tag, or commit. 46 | GetReferenceByName(ctx context.Context, in *GetReferenceByNameRequest, opts ...grpc.CallOption) (*GetReferenceByNameResponse, error) 47 | // ListGitCommitsForReference takes a string reference and returns a paginated list of 48 | // git commit information associated with the resolved reference commit. 49 | ListGitCommitsForReference(ctx context.Context, in *ListGitCommitsForReferenceRequest, opts ...grpc.CallOption) (*ListGitCommitsForReferenceResponse, error) 50 | } 51 | 52 | type referenceServiceClient struct { 53 | cc grpc.ClientConnInterface 54 | } 55 | 56 | func NewReferenceServiceClient(cc grpc.ClientConnInterface) ReferenceServiceClient { 57 | return &referenceServiceClient{cc} 58 | } 59 | 60 | func (c *referenceServiceClient) GetReferenceByName(ctx context.Context, in *GetReferenceByNameRequest, opts ...grpc.CallOption) (*GetReferenceByNameResponse, error) { 61 | out := new(GetReferenceByNameResponse) 62 | err := c.cc.Invoke(ctx, ReferenceService_GetReferenceByName_FullMethodName, in, out, opts...) 63 | if err != nil { 64 | return nil, err 65 | } 66 | return out, nil 67 | } 68 | 69 | func (c *referenceServiceClient) ListGitCommitsForReference(ctx context.Context, in *ListGitCommitsForReferenceRequest, opts ...grpc.CallOption) (*ListGitCommitsForReferenceResponse, error) { 70 | out := new(ListGitCommitsForReferenceResponse) 71 | err := c.cc.Invoke(ctx, ReferenceService_ListGitCommitsForReference_FullMethodName, in, out, opts...) 72 | if err != nil { 73 | return nil, err 74 | } 75 | return out, nil 76 | } 77 | 78 | // ReferenceServiceServer is the server API for ReferenceService service. 79 | // All implementations should embed UnimplementedReferenceServiceServer 80 | // for forward compatibility 81 | type ReferenceServiceServer interface { 82 | // GetReferenceByName takes a reference name and returns the 83 | // reference either as 'main', a tag, or commit. 84 | GetReferenceByName(context.Context, *GetReferenceByNameRequest) (*GetReferenceByNameResponse, error) 85 | // ListGitCommitsForReference takes a string reference and returns a paginated list of 86 | // git commit information associated with the resolved reference commit. 87 | ListGitCommitsForReference(context.Context, *ListGitCommitsForReferenceRequest) (*ListGitCommitsForReferenceResponse, error) 88 | } 89 | 90 | // UnimplementedReferenceServiceServer should be embedded to have forward compatible implementations. 91 | type UnimplementedReferenceServiceServer struct { 92 | } 93 | 94 | func (UnimplementedReferenceServiceServer) GetReferenceByName(context.Context, *GetReferenceByNameRequest) (*GetReferenceByNameResponse, error) { 95 | return nil, status.Errorf(codes.Unimplemented, "method GetReferenceByName not implemented") 96 | } 97 | func (UnimplementedReferenceServiceServer) ListGitCommitsForReference(context.Context, *ListGitCommitsForReferenceRequest) (*ListGitCommitsForReferenceResponse, error) { 98 | return nil, status.Errorf(codes.Unimplemented, "method ListGitCommitsForReference not implemented") 99 | } 100 | 101 | // UnsafeReferenceServiceServer may be embedded to opt out of forward compatibility for this service. 102 | // Use of this interface is not recommended, as added methods to ReferenceServiceServer will 103 | // result in compilation errors. 104 | type UnsafeReferenceServiceServer interface { 105 | mustEmbedUnimplementedReferenceServiceServer() 106 | } 107 | 108 | func RegisterReferenceServiceServer(s grpc.ServiceRegistrar, srv ReferenceServiceServer) { 109 | s.RegisterService(&ReferenceService_ServiceDesc, srv) 110 | } 111 | 112 | func _ReferenceService_GetReferenceByName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 113 | in := new(GetReferenceByNameRequest) 114 | if err := dec(in); err != nil { 115 | return nil, err 116 | } 117 | if interceptor == nil { 118 | return srv.(ReferenceServiceServer).GetReferenceByName(ctx, in) 119 | } 120 | info := &grpc.UnaryServerInfo{ 121 | Server: srv, 122 | FullMethod: ReferenceService_GetReferenceByName_FullMethodName, 123 | } 124 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 125 | return srv.(ReferenceServiceServer).GetReferenceByName(ctx, req.(*GetReferenceByNameRequest)) 126 | } 127 | return interceptor(ctx, in, info, handler) 128 | } 129 | 130 | func _ReferenceService_ListGitCommitsForReference_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 131 | in := new(ListGitCommitsForReferenceRequest) 132 | if err := dec(in); err != nil { 133 | return nil, err 134 | } 135 | if interceptor == nil { 136 | return srv.(ReferenceServiceServer).ListGitCommitsForReference(ctx, in) 137 | } 138 | info := &grpc.UnaryServerInfo{ 139 | Server: srv, 140 | FullMethod: ReferenceService_ListGitCommitsForReference_FullMethodName, 141 | } 142 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 143 | return srv.(ReferenceServiceServer).ListGitCommitsForReference(ctx, req.(*ListGitCommitsForReferenceRequest)) 144 | } 145 | return interceptor(ctx, in, info, handler) 146 | } 147 | 148 | // ReferenceService_ServiceDesc is the grpc.ServiceDesc for ReferenceService service. 149 | // It's only intended for direct use with grpc.RegisterService, 150 | // and not to be introspected or modified (even as a copy) 151 | var ReferenceService_ServiceDesc = grpc.ServiceDesc{ 152 | ServiceName: "buf.alpha.registry.v1alpha1.ReferenceService", 153 | HandlerType: (*ReferenceServiceServer)(nil), 154 | Methods: []grpc.MethodDesc{ 155 | { 156 | MethodName: "GetReferenceByName", 157 | Handler: _ReferenceService_GetReferenceByName_Handler, 158 | }, 159 | { 160 | MethodName: "ListGitCommitsForReference", 161 | Handler: _ReferenceService_ListGitCommitsForReference_Handler, 162 | }, 163 | }, 164 | Streams: []grpc.StreamDesc{}, 165 | Metadata: "buf/alpha/registry/v1alpha1/reference.proto", 166 | } 167 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/resource_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/registry/v1alpha1/resource.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | ResourceService_GetResourceByName_FullMethodName = "/buf.alpha.registry.v1alpha1.ResourceService/GetResourceByName" 37 | ) 38 | 39 | // ResourceServiceClient is the client API for ResourceService service. 40 | // 41 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 42 | type ResourceServiceClient interface { 43 | // GetResourceByName takes a resource name and returns the 44 | // resource either as a repository or a plugin. 45 | GetResourceByName(ctx context.Context, in *GetResourceByNameRequest, opts ...grpc.CallOption) (*GetResourceByNameResponse, error) 46 | } 47 | 48 | type resourceServiceClient struct { 49 | cc grpc.ClientConnInterface 50 | } 51 | 52 | func NewResourceServiceClient(cc grpc.ClientConnInterface) ResourceServiceClient { 53 | return &resourceServiceClient{cc} 54 | } 55 | 56 | func (c *resourceServiceClient) GetResourceByName(ctx context.Context, in *GetResourceByNameRequest, opts ...grpc.CallOption) (*GetResourceByNameResponse, error) { 57 | out := new(GetResourceByNameResponse) 58 | err := c.cc.Invoke(ctx, ResourceService_GetResourceByName_FullMethodName, in, out, opts...) 59 | if err != nil { 60 | return nil, err 61 | } 62 | return out, nil 63 | } 64 | 65 | // ResourceServiceServer is the server API for ResourceService service. 66 | // All implementations should embed UnimplementedResourceServiceServer 67 | // for forward compatibility 68 | type ResourceServiceServer interface { 69 | // GetResourceByName takes a resource name and returns the 70 | // resource either as a repository or a plugin. 71 | GetResourceByName(context.Context, *GetResourceByNameRequest) (*GetResourceByNameResponse, error) 72 | } 73 | 74 | // UnimplementedResourceServiceServer should be embedded to have forward compatible implementations. 75 | type UnimplementedResourceServiceServer struct { 76 | } 77 | 78 | func (UnimplementedResourceServiceServer) GetResourceByName(context.Context, *GetResourceByNameRequest) (*GetResourceByNameResponse, error) { 79 | return nil, status.Errorf(codes.Unimplemented, "method GetResourceByName not implemented") 80 | } 81 | 82 | // UnsafeResourceServiceServer may be embedded to opt out of forward compatibility for this service. 83 | // Use of this interface is not recommended, as added methods to ResourceServiceServer will 84 | // result in compilation errors. 85 | type UnsafeResourceServiceServer interface { 86 | mustEmbedUnimplementedResourceServiceServer() 87 | } 88 | 89 | func RegisterResourceServiceServer(s grpc.ServiceRegistrar, srv ResourceServiceServer) { 90 | s.RegisterService(&ResourceService_ServiceDesc, srv) 91 | } 92 | 93 | func _ResourceService_GetResourceByName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 94 | in := new(GetResourceByNameRequest) 95 | if err := dec(in); err != nil { 96 | return nil, err 97 | } 98 | if interceptor == nil { 99 | return srv.(ResourceServiceServer).GetResourceByName(ctx, in) 100 | } 101 | info := &grpc.UnaryServerInfo{ 102 | Server: srv, 103 | FullMethod: ResourceService_GetResourceByName_FullMethodName, 104 | } 105 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 106 | return srv.(ResourceServiceServer).GetResourceByName(ctx, req.(*GetResourceByNameRequest)) 107 | } 108 | return interceptor(ctx, in, info, handler) 109 | } 110 | 111 | // ResourceService_ServiceDesc is the grpc.ServiceDesc for ResourceService service. 112 | // It's only intended for direct use with grpc.RegisterService, 113 | // and not to be introspected or modified (even as a copy) 114 | var ResourceService_ServiceDesc = grpc.ServiceDesc{ 115 | ServiceName: "buf.alpha.registry.v1alpha1.ResourceService", 116 | HandlerType: (*ResourceServiceServer)(nil), 117 | Methods: []grpc.MethodDesc{ 118 | { 119 | MethodName: "GetResourceByName", 120 | Handler: _ResourceService_GetResourceByName_Handler, 121 | }, 122 | }, 123 | Streams: []grpc.StreamDesc{}, 124 | Metadata: "buf/alpha/registry/v1alpha1/resource.proto", 125 | } 126 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/schema_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/registry/v1alpha1/schema.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | SchemaService_GetSchema_FullMethodName = "/buf.alpha.registry.v1alpha1.SchemaService/GetSchema" 37 | SchemaService_ConvertMessage_FullMethodName = "/buf.alpha.registry.v1alpha1.SchemaService/ConvertMessage" 38 | ) 39 | 40 | // SchemaServiceClient is the client API for SchemaService service. 41 | // 42 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 43 | type SchemaServiceClient interface { 44 | // GetSchema allows the caller to download a schema for one or more requested 45 | // types, RPC services, or RPC methods. 46 | GetSchema(ctx context.Context, in *GetSchemaRequest, opts ...grpc.CallOption) (*GetSchemaResponse, error) 47 | // ConvertMessage allows the caller to convert a given message data blob from 48 | // one format to another by referring to a type schema for the blob. 49 | ConvertMessage(ctx context.Context, in *ConvertMessageRequest, opts ...grpc.CallOption) (*ConvertMessageResponse, error) 50 | } 51 | 52 | type schemaServiceClient struct { 53 | cc grpc.ClientConnInterface 54 | } 55 | 56 | func NewSchemaServiceClient(cc grpc.ClientConnInterface) SchemaServiceClient { 57 | return &schemaServiceClient{cc} 58 | } 59 | 60 | func (c *schemaServiceClient) GetSchema(ctx context.Context, in *GetSchemaRequest, opts ...grpc.CallOption) (*GetSchemaResponse, error) { 61 | out := new(GetSchemaResponse) 62 | err := c.cc.Invoke(ctx, SchemaService_GetSchema_FullMethodName, in, out, opts...) 63 | if err != nil { 64 | return nil, err 65 | } 66 | return out, nil 67 | } 68 | 69 | func (c *schemaServiceClient) ConvertMessage(ctx context.Context, in *ConvertMessageRequest, opts ...grpc.CallOption) (*ConvertMessageResponse, error) { 70 | out := new(ConvertMessageResponse) 71 | err := c.cc.Invoke(ctx, SchemaService_ConvertMessage_FullMethodName, in, out, opts...) 72 | if err != nil { 73 | return nil, err 74 | } 75 | return out, nil 76 | } 77 | 78 | // SchemaServiceServer is the server API for SchemaService service. 79 | // All implementations should embed UnimplementedSchemaServiceServer 80 | // for forward compatibility 81 | type SchemaServiceServer interface { 82 | // GetSchema allows the caller to download a schema for one or more requested 83 | // types, RPC services, or RPC methods. 84 | GetSchema(context.Context, *GetSchemaRequest) (*GetSchemaResponse, error) 85 | // ConvertMessage allows the caller to convert a given message data blob from 86 | // one format to another by referring to a type schema for the blob. 87 | ConvertMessage(context.Context, *ConvertMessageRequest) (*ConvertMessageResponse, error) 88 | } 89 | 90 | // UnimplementedSchemaServiceServer should be embedded to have forward compatible implementations. 91 | type UnimplementedSchemaServiceServer struct { 92 | } 93 | 94 | func (UnimplementedSchemaServiceServer) GetSchema(context.Context, *GetSchemaRequest) (*GetSchemaResponse, error) { 95 | return nil, status.Errorf(codes.Unimplemented, "method GetSchema not implemented") 96 | } 97 | func (UnimplementedSchemaServiceServer) ConvertMessage(context.Context, *ConvertMessageRequest) (*ConvertMessageResponse, error) { 98 | return nil, status.Errorf(codes.Unimplemented, "method ConvertMessage not implemented") 99 | } 100 | 101 | // UnsafeSchemaServiceServer may be embedded to opt out of forward compatibility for this service. 102 | // Use of this interface is not recommended, as added methods to SchemaServiceServer will 103 | // result in compilation errors. 104 | type UnsafeSchemaServiceServer interface { 105 | mustEmbedUnimplementedSchemaServiceServer() 106 | } 107 | 108 | func RegisterSchemaServiceServer(s grpc.ServiceRegistrar, srv SchemaServiceServer) { 109 | s.RegisterService(&SchemaService_ServiceDesc, srv) 110 | } 111 | 112 | func _SchemaService_GetSchema_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 113 | in := new(GetSchemaRequest) 114 | if err := dec(in); err != nil { 115 | return nil, err 116 | } 117 | if interceptor == nil { 118 | return srv.(SchemaServiceServer).GetSchema(ctx, in) 119 | } 120 | info := &grpc.UnaryServerInfo{ 121 | Server: srv, 122 | FullMethod: SchemaService_GetSchema_FullMethodName, 123 | } 124 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 125 | return srv.(SchemaServiceServer).GetSchema(ctx, req.(*GetSchemaRequest)) 126 | } 127 | return interceptor(ctx, in, info, handler) 128 | } 129 | 130 | func _SchemaService_ConvertMessage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 131 | in := new(ConvertMessageRequest) 132 | if err := dec(in); err != nil { 133 | return nil, err 134 | } 135 | if interceptor == nil { 136 | return srv.(SchemaServiceServer).ConvertMessage(ctx, in) 137 | } 138 | info := &grpc.UnaryServerInfo{ 139 | Server: srv, 140 | FullMethod: SchemaService_ConvertMessage_FullMethodName, 141 | } 142 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 143 | return srv.(SchemaServiceServer).ConvertMessage(ctx, req.(*ConvertMessageRequest)) 144 | } 145 | return interceptor(ctx, in, info, handler) 146 | } 147 | 148 | // SchemaService_ServiceDesc is the grpc.ServiceDesc for SchemaService service. 149 | // It's only intended for direct use with grpc.RegisterService, 150 | // and not to be introspected or modified (even as a copy) 151 | var SchemaService_ServiceDesc = grpc.ServiceDesc{ 152 | ServiceName: "buf.alpha.registry.v1alpha1.SchemaService", 153 | HandlerType: (*SchemaServiceServer)(nil), 154 | Methods: []grpc.MethodDesc{ 155 | { 156 | MethodName: "GetSchema", 157 | Handler: _SchemaService_GetSchema_Handler, 158 | }, 159 | { 160 | MethodName: "ConvertMessage", 161 | Handler: _SchemaService_ConvertMessage_Handler, 162 | }, 163 | }, 164 | Streams: []grpc.StreamDesc{}, 165 | Metadata: "buf/alpha/registry/v1alpha1/schema.proto", 166 | } 167 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/studio_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/registry/v1alpha1/studio.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | StudioService_ListStudioAgentPresets_FullMethodName = "/buf.alpha.registry.v1alpha1.StudioService/ListStudioAgentPresets" 37 | StudioService_SetStudioAgentPresets_FullMethodName = "/buf.alpha.registry.v1alpha1.StudioService/SetStudioAgentPresets" 38 | ) 39 | 40 | // StudioServiceClient is the client API for StudioService service. 41 | // 42 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 43 | type StudioServiceClient interface { 44 | // ListStudioAgentPresets returns a list of agent presets in the server. 45 | ListStudioAgentPresets(ctx context.Context, in *ListStudioAgentPresetsRequest, opts ...grpc.CallOption) (*ListStudioAgentPresetsResponse, error) 46 | // SetStudioAgentPresets sets the list of agent presets in the server. 47 | SetStudioAgentPresets(ctx context.Context, in *SetStudioAgentPresetsRequest, opts ...grpc.CallOption) (*SetStudioAgentPresetsResponse, error) 48 | } 49 | 50 | type studioServiceClient struct { 51 | cc grpc.ClientConnInterface 52 | } 53 | 54 | func NewStudioServiceClient(cc grpc.ClientConnInterface) StudioServiceClient { 55 | return &studioServiceClient{cc} 56 | } 57 | 58 | func (c *studioServiceClient) ListStudioAgentPresets(ctx context.Context, in *ListStudioAgentPresetsRequest, opts ...grpc.CallOption) (*ListStudioAgentPresetsResponse, error) { 59 | out := new(ListStudioAgentPresetsResponse) 60 | err := c.cc.Invoke(ctx, StudioService_ListStudioAgentPresets_FullMethodName, in, out, opts...) 61 | if err != nil { 62 | return nil, err 63 | } 64 | return out, nil 65 | } 66 | 67 | func (c *studioServiceClient) SetStudioAgentPresets(ctx context.Context, in *SetStudioAgentPresetsRequest, opts ...grpc.CallOption) (*SetStudioAgentPresetsResponse, error) { 68 | out := new(SetStudioAgentPresetsResponse) 69 | err := c.cc.Invoke(ctx, StudioService_SetStudioAgentPresets_FullMethodName, in, out, opts...) 70 | if err != nil { 71 | return nil, err 72 | } 73 | return out, nil 74 | } 75 | 76 | // StudioServiceServer is the server API for StudioService service. 77 | // All implementations should embed UnimplementedStudioServiceServer 78 | // for forward compatibility 79 | type StudioServiceServer interface { 80 | // ListStudioAgentPresets returns a list of agent presets in the server. 81 | ListStudioAgentPresets(context.Context, *ListStudioAgentPresetsRequest) (*ListStudioAgentPresetsResponse, error) 82 | // SetStudioAgentPresets sets the list of agent presets in the server. 83 | SetStudioAgentPresets(context.Context, *SetStudioAgentPresetsRequest) (*SetStudioAgentPresetsResponse, error) 84 | } 85 | 86 | // UnimplementedStudioServiceServer should be embedded to have forward compatible implementations. 87 | type UnimplementedStudioServiceServer struct { 88 | } 89 | 90 | func (UnimplementedStudioServiceServer) ListStudioAgentPresets(context.Context, *ListStudioAgentPresetsRequest) (*ListStudioAgentPresetsResponse, error) { 91 | return nil, status.Errorf(codes.Unimplemented, "method ListStudioAgentPresets not implemented") 92 | } 93 | func (UnimplementedStudioServiceServer) SetStudioAgentPresets(context.Context, *SetStudioAgentPresetsRequest) (*SetStudioAgentPresetsResponse, error) { 94 | return nil, status.Errorf(codes.Unimplemented, "method SetStudioAgentPresets not implemented") 95 | } 96 | 97 | // UnsafeStudioServiceServer may be embedded to opt out of forward compatibility for this service. 98 | // Use of this interface is not recommended, as added methods to StudioServiceServer will 99 | // result in compilation errors. 100 | type UnsafeStudioServiceServer interface { 101 | mustEmbedUnimplementedStudioServiceServer() 102 | } 103 | 104 | func RegisterStudioServiceServer(s grpc.ServiceRegistrar, srv StudioServiceServer) { 105 | s.RegisterService(&StudioService_ServiceDesc, srv) 106 | } 107 | 108 | func _StudioService_ListStudioAgentPresets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 109 | in := new(ListStudioAgentPresetsRequest) 110 | if err := dec(in); err != nil { 111 | return nil, err 112 | } 113 | if interceptor == nil { 114 | return srv.(StudioServiceServer).ListStudioAgentPresets(ctx, in) 115 | } 116 | info := &grpc.UnaryServerInfo{ 117 | Server: srv, 118 | FullMethod: StudioService_ListStudioAgentPresets_FullMethodName, 119 | } 120 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 121 | return srv.(StudioServiceServer).ListStudioAgentPresets(ctx, req.(*ListStudioAgentPresetsRequest)) 122 | } 123 | return interceptor(ctx, in, info, handler) 124 | } 125 | 126 | func _StudioService_SetStudioAgentPresets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 127 | in := new(SetStudioAgentPresetsRequest) 128 | if err := dec(in); err != nil { 129 | return nil, err 130 | } 131 | if interceptor == nil { 132 | return srv.(StudioServiceServer).SetStudioAgentPresets(ctx, in) 133 | } 134 | info := &grpc.UnaryServerInfo{ 135 | Server: srv, 136 | FullMethod: StudioService_SetStudioAgentPresets_FullMethodName, 137 | } 138 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 139 | return srv.(StudioServiceServer).SetStudioAgentPresets(ctx, req.(*SetStudioAgentPresetsRequest)) 140 | } 141 | return interceptor(ctx, in, info, handler) 142 | } 143 | 144 | // StudioService_ServiceDesc is the grpc.ServiceDesc for StudioService service. 145 | // It's only intended for direct use with grpc.RegisterService, 146 | // and not to be introspected or modified (even as a copy) 147 | var StudioService_ServiceDesc = grpc.ServiceDesc{ 148 | ServiceName: "buf.alpha.registry.v1alpha1.StudioService", 149 | HandlerType: (*StudioServiceServer)(nil), 150 | Methods: []grpc.MethodDesc{ 151 | { 152 | MethodName: "ListStudioAgentPresets", 153 | Handler: _StudioService_ListStudioAgentPresets_Handler, 154 | }, 155 | { 156 | MethodName: "SetStudioAgentPresets", 157 | Handler: _StudioService_SetStudioAgentPresets_Handler, 158 | }, 159 | }, 160 | Streams: []grpc.StreamDesc{}, 161 | Metadata: "buf/alpha/registry/v1alpha1/studio.proto", 162 | } 163 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/v1alpha1connect/convert.connect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-connect-go. DO NOT EDIT. 16 | // 17 | // Source: buf/alpha/registry/v1alpha1/convert.proto 18 | 19 | package v1alpha1connect 20 | 21 | import ( 22 | connect "connectrpc.com/connect" 23 | context "context" 24 | errors "errors" 25 | v1alpha1 "github.com/easyp-tech/server/gen/proto/buf/alpha/registry/v1alpha1" 26 | http "net/http" 27 | strings "strings" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file and the connect package are 31 | // compatible. If you get a compiler error that this constant is not defined, this code was 32 | // generated with a version of connect newer than the one compiled into your binary. You can fix the 33 | // problem by either regenerating this code with an older version of connect or updating the connect 34 | // version compiled into your binary. 35 | const _ = connect.IsAtLeastVersion0_1_0 36 | 37 | const ( 38 | // ConvertServiceName is the fully-qualified name of the ConvertService service. 39 | ConvertServiceName = "buf.alpha.registry.v1alpha1.ConvertService" 40 | ) 41 | 42 | // These constants are the fully-qualified names of the RPCs defined in this package. They're 43 | // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. 44 | // 45 | // Note that these are different from the fully-qualified method names used by 46 | // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to 47 | // reflection-formatted method names, remove the leading slash and convert the remaining slash to a 48 | // period. 49 | const ( 50 | // ConvertServiceConvertProcedure is the fully-qualified name of the ConvertService's Convert RPC. 51 | ConvertServiceConvertProcedure = "/buf.alpha.registry.v1alpha1.ConvertService/Convert" 52 | ) 53 | 54 | // ConvertServiceClient is a client for the buf.alpha.registry.v1alpha1.ConvertService service. 55 | type ConvertServiceClient interface { 56 | // Convert converts a serialized message according to 57 | // the provided type name using an image. 58 | Convert(context.Context, *connect.Request[v1alpha1.ConvertRequest]) (*connect.Response[v1alpha1.ConvertResponse], error) 59 | } 60 | 61 | // NewConvertServiceClient constructs a client for the buf.alpha.registry.v1alpha1.ConvertService 62 | // service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for 63 | // gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply 64 | // the connect.WithGRPC() or connect.WithGRPCWeb() options. 65 | // 66 | // The URL supplied here should be the base URL for the Connect or gRPC server (for example, 67 | // http://api.acme.com or https://acme.com/grpc). 68 | func NewConvertServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ConvertServiceClient { 69 | baseURL = strings.TrimRight(baseURL, "/") 70 | return &convertServiceClient{ 71 | convert: connect.NewClient[v1alpha1.ConvertRequest, v1alpha1.ConvertResponse]( 72 | httpClient, 73 | baseURL+ConvertServiceConvertProcedure, 74 | opts..., 75 | ), 76 | } 77 | } 78 | 79 | // convertServiceClient implements ConvertServiceClient. 80 | type convertServiceClient struct { 81 | convert *connect.Client[v1alpha1.ConvertRequest, v1alpha1.ConvertResponse] 82 | } 83 | 84 | // Convert calls buf.alpha.registry.v1alpha1.ConvertService.Convert. 85 | func (c *convertServiceClient) Convert(ctx context.Context, req *connect.Request[v1alpha1.ConvertRequest]) (*connect.Response[v1alpha1.ConvertResponse], error) { 86 | return c.convert.CallUnary(ctx, req) 87 | } 88 | 89 | // ConvertServiceHandler is an implementation of the buf.alpha.registry.v1alpha1.ConvertService 90 | // service. 91 | type ConvertServiceHandler interface { 92 | // Convert converts a serialized message according to 93 | // the provided type name using an image. 94 | Convert(context.Context, *connect.Request[v1alpha1.ConvertRequest]) (*connect.Response[v1alpha1.ConvertResponse], error) 95 | } 96 | 97 | // NewConvertServiceHandler builds an HTTP handler from the service implementation. It returns the 98 | // path on which to mount the handler and the handler itself. 99 | // 100 | // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf 101 | // and JSON codecs. They also support gzip compression. 102 | func NewConvertServiceHandler(svc ConvertServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { 103 | convertServiceConvertHandler := connect.NewUnaryHandler( 104 | ConvertServiceConvertProcedure, 105 | svc.Convert, 106 | opts..., 107 | ) 108 | return "/buf.alpha.registry.v1alpha1.ConvertService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 109 | switch r.URL.Path { 110 | case ConvertServiceConvertProcedure: 111 | convertServiceConvertHandler.ServeHTTP(w, r) 112 | default: 113 | http.NotFound(w, r) 114 | } 115 | }) 116 | } 117 | 118 | // UnimplementedConvertServiceHandler returns CodeUnimplemented from all methods. 119 | type UnimplementedConvertServiceHandler struct{} 120 | 121 | func (UnimplementedConvertServiceHandler) Convert(context.Context, *connect.Request[v1alpha1.ConvertRequest]) (*connect.Response[v1alpha1.ConvertResponse], error) { 122 | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.ConvertService.Convert is not implemented")) 123 | } 124 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/v1alpha1connect/github.connect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-connect-go. DO NOT EDIT. 16 | // 17 | // Source: buf/alpha/registry/v1alpha1/github.proto 18 | 19 | package v1alpha1connect 20 | 21 | import ( 22 | connect "connectrpc.com/connect" 23 | context "context" 24 | errors "errors" 25 | v1alpha1 "github.com/easyp-tech/server/gen/proto/buf/alpha/registry/v1alpha1" 26 | http "net/http" 27 | strings "strings" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file and the connect package are 31 | // compatible. If you get a compiler error that this constant is not defined, this code was 32 | // generated with a version of connect newer than the one compiled into your binary. You can fix the 33 | // problem by either regenerating this code with an older version of connect or updating the connect 34 | // version compiled into your binary. 35 | const _ = connect.IsAtLeastVersion1_7_0 36 | 37 | const ( 38 | // GithubServiceName is the fully-qualified name of the GithubService service. 39 | GithubServiceName = "buf.alpha.registry.v1alpha1.GithubService" 40 | ) 41 | 42 | // These constants are the fully-qualified names of the RPCs defined in this package. They're 43 | // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. 44 | // 45 | // Note that these are different from the fully-qualified method names used by 46 | // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to 47 | // reflection-formatted method names, remove the leading slash and convert the remaining slash to a 48 | // period. 49 | const ( 50 | // GithubServiceGetGithubAppConfigProcedure is the fully-qualified name of the GithubService's 51 | // GetGithubAppConfig RPC. 52 | GithubServiceGetGithubAppConfigProcedure = "/buf.alpha.registry.v1alpha1.GithubService/GetGithubAppConfig" 53 | ) 54 | 55 | // GithubServiceClient is a client for the buf.alpha.registry.v1alpha1.GithubService service. 56 | type GithubServiceClient interface { 57 | // GetGithubAppConfig returns a Github Application Configuration. 58 | GetGithubAppConfig(context.Context, *connect.Request[v1alpha1.GetGithubAppConfigRequest]) (*connect.Response[v1alpha1.GetGithubAppConfigResponse], error) 59 | } 60 | 61 | // NewGithubServiceClient constructs a client for the buf.alpha.registry.v1alpha1.GithubService 62 | // service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for 63 | // gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply 64 | // the connect.WithGRPC() or connect.WithGRPCWeb() options. 65 | // 66 | // The URL supplied here should be the base URL for the Connect or gRPC server (for example, 67 | // http://api.acme.com or https://acme.com/grpc). 68 | func NewGithubServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) GithubServiceClient { 69 | baseURL = strings.TrimRight(baseURL, "/") 70 | return &githubServiceClient{ 71 | getGithubAppConfig: connect.NewClient[v1alpha1.GetGithubAppConfigRequest, v1alpha1.GetGithubAppConfigResponse]( 72 | httpClient, 73 | baseURL+GithubServiceGetGithubAppConfigProcedure, 74 | connect.WithIdempotency(connect.IdempotencyNoSideEffects), 75 | connect.WithClientOptions(opts...), 76 | ), 77 | } 78 | } 79 | 80 | // githubServiceClient implements GithubServiceClient. 81 | type githubServiceClient struct { 82 | getGithubAppConfig *connect.Client[v1alpha1.GetGithubAppConfigRequest, v1alpha1.GetGithubAppConfigResponse] 83 | } 84 | 85 | // GetGithubAppConfig calls buf.alpha.registry.v1alpha1.GithubService.GetGithubAppConfig. 86 | func (c *githubServiceClient) GetGithubAppConfig(ctx context.Context, req *connect.Request[v1alpha1.GetGithubAppConfigRequest]) (*connect.Response[v1alpha1.GetGithubAppConfigResponse], error) { 87 | return c.getGithubAppConfig.CallUnary(ctx, req) 88 | } 89 | 90 | // GithubServiceHandler is an implementation of the buf.alpha.registry.v1alpha1.GithubService 91 | // service. 92 | type GithubServiceHandler interface { 93 | // GetGithubAppConfig returns a Github Application Configuration. 94 | GetGithubAppConfig(context.Context, *connect.Request[v1alpha1.GetGithubAppConfigRequest]) (*connect.Response[v1alpha1.GetGithubAppConfigResponse], error) 95 | } 96 | 97 | // NewGithubServiceHandler builds an HTTP handler from the service implementation. It returns the 98 | // path on which to mount the handler and the handler itself. 99 | // 100 | // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf 101 | // and JSON codecs. They also support gzip compression. 102 | func NewGithubServiceHandler(svc GithubServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { 103 | githubServiceGetGithubAppConfigHandler := connect.NewUnaryHandler( 104 | GithubServiceGetGithubAppConfigProcedure, 105 | svc.GetGithubAppConfig, 106 | connect.WithIdempotency(connect.IdempotencyNoSideEffects), 107 | connect.WithHandlerOptions(opts...), 108 | ) 109 | return "/buf.alpha.registry.v1alpha1.GithubService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 110 | switch r.URL.Path { 111 | case GithubServiceGetGithubAppConfigProcedure: 112 | githubServiceGetGithubAppConfigHandler.ServeHTTP(w, r) 113 | default: 114 | http.NotFound(w, r) 115 | } 116 | }) 117 | } 118 | 119 | // UnimplementedGithubServiceHandler returns CodeUnimplemented from all methods. 120 | type UnimplementedGithubServiceHandler struct{} 121 | 122 | func (UnimplementedGithubServiceHandler) GetGithubAppConfig(context.Context, *connect.Request[v1alpha1.GetGithubAppConfigRequest]) (*connect.Response[v1alpha1.GetGithubAppConfigResponse], error) { 123 | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.GithubService.GetGithubAppConfig is not implemented")) 124 | } 125 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/v1alpha1connect/image.connect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-connect-go. DO NOT EDIT. 16 | // 17 | // Source: buf/alpha/registry/v1alpha1/image.proto 18 | 19 | package v1alpha1connect 20 | 21 | import ( 22 | connect "connectrpc.com/connect" 23 | context "context" 24 | errors "errors" 25 | v1alpha1 "github.com/easyp-tech/server/gen/proto/buf/alpha/registry/v1alpha1" 26 | http "net/http" 27 | strings "strings" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file and the connect package are 31 | // compatible. If you get a compiler error that this constant is not defined, this code was 32 | // generated with a version of connect newer than the one compiled into your binary. You can fix the 33 | // problem by either regenerating this code with an older version of connect or updating the connect 34 | // version compiled into your binary. 35 | const _ = connect.IsAtLeastVersion1_7_0 36 | 37 | const ( 38 | // ImageServiceName is the fully-qualified name of the ImageService service. 39 | ImageServiceName = "buf.alpha.registry.v1alpha1.ImageService" 40 | ) 41 | 42 | // These constants are the fully-qualified names of the RPCs defined in this package. They're 43 | // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. 44 | // 45 | // Note that these are different from the fully-qualified method names used by 46 | // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to 47 | // reflection-formatted method names, remove the leading slash and convert the remaining slash to a 48 | // period. 49 | const ( 50 | // ImageServiceGetImageProcedure is the fully-qualified name of the ImageService's GetImage RPC. 51 | ImageServiceGetImageProcedure = "/buf.alpha.registry.v1alpha1.ImageService/GetImage" 52 | ) 53 | 54 | // ImageServiceClient is a client for the buf.alpha.registry.v1alpha1.ImageService service. 55 | type ImageServiceClient interface { 56 | // GetImage serves a compiled image for the local module. It automatically 57 | // downloads dependencies if necessary. 58 | GetImage(context.Context, *connect.Request[v1alpha1.GetImageRequest]) (*connect.Response[v1alpha1.GetImageResponse], error) 59 | } 60 | 61 | // NewImageServiceClient constructs a client for the buf.alpha.registry.v1alpha1.ImageService 62 | // service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for 63 | // gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply 64 | // the connect.WithGRPC() or connect.WithGRPCWeb() options. 65 | // 66 | // The URL supplied here should be the base URL for the Connect or gRPC server (for example, 67 | // http://api.acme.com or https://acme.com/grpc). 68 | func NewImageServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ImageServiceClient { 69 | baseURL = strings.TrimRight(baseURL, "/") 70 | return &imageServiceClient{ 71 | getImage: connect.NewClient[v1alpha1.GetImageRequest, v1alpha1.GetImageResponse]( 72 | httpClient, 73 | baseURL+ImageServiceGetImageProcedure, 74 | connect.WithIdempotency(connect.IdempotencyNoSideEffects), 75 | connect.WithClientOptions(opts...), 76 | ), 77 | } 78 | } 79 | 80 | // imageServiceClient implements ImageServiceClient. 81 | type imageServiceClient struct { 82 | getImage *connect.Client[v1alpha1.GetImageRequest, v1alpha1.GetImageResponse] 83 | } 84 | 85 | // GetImage calls buf.alpha.registry.v1alpha1.ImageService.GetImage. 86 | func (c *imageServiceClient) GetImage(ctx context.Context, req *connect.Request[v1alpha1.GetImageRequest]) (*connect.Response[v1alpha1.GetImageResponse], error) { 87 | return c.getImage.CallUnary(ctx, req) 88 | } 89 | 90 | // ImageServiceHandler is an implementation of the buf.alpha.registry.v1alpha1.ImageService service. 91 | type ImageServiceHandler interface { 92 | // GetImage serves a compiled image for the local module. It automatically 93 | // downloads dependencies if necessary. 94 | GetImage(context.Context, *connect.Request[v1alpha1.GetImageRequest]) (*connect.Response[v1alpha1.GetImageResponse], error) 95 | } 96 | 97 | // NewImageServiceHandler builds an HTTP handler from the service implementation. It returns the 98 | // path on which to mount the handler and the handler itself. 99 | // 100 | // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf 101 | // and JSON codecs. They also support gzip compression. 102 | func NewImageServiceHandler(svc ImageServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { 103 | imageServiceGetImageHandler := connect.NewUnaryHandler( 104 | ImageServiceGetImageProcedure, 105 | svc.GetImage, 106 | connect.WithIdempotency(connect.IdempotencyNoSideEffects), 107 | connect.WithHandlerOptions(opts...), 108 | ) 109 | return "/buf.alpha.registry.v1alpha1.ImageService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 110 | switch r.URL.Path { 111 | case ImageServiceGetImageProcedure: 112 | imageServiceGetImageHandler.ServeHTTP(w, r) 113 | default: 114 | http.NotFound(w, r) 115 | } 116 | }) 117 | } 118 | 119 | // UnimplementedImageServiceHandler returns CodeUnimplemented from all methods. 120 | type UnimplementedImageServiceHandler struct{} 121 | 122 | func (UnimplementedImageServiceHandler) GetImage(context.Context, *connect.Request[v1alpha1.GetImageRequest]) (*connect.Response[v1alpha1.GetImageResponse], error) { 123 | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.ImageService.GetImage is not implemented")) 124 | } 125 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/v1alpha1connect/jsonschema.connect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-connect-go. DO NOT EDIT. 16 | // 17 | // Source: buf/alpha/registry/v1alpha1/jsonschema.proto 18 | 19 | package v1alpha1connect 20 | 21 | import ( 22 | connect "connectrpc.com/connect" 23 | context "context" 24 | errors "errors" 25 | v1alpha1 "github.com/easyp-tech/server/gen/proto/buf/alpha/registry/v1alpha1" 26 | http "net/http" 27 | strings "strings" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file and the connect package are 31 | // compatible. If you get a compiler error that this constant is not defined, this code was 32 | // generated with a version of connect newer than the one compiled into your binary. You can fix the 33 | // problem by either regenerating this code with an older version of connect or updating the connect 34 | // version compiled into your binary. 35 | const _ = connect.IsAtLeastVersion1_7_0 36 | 37 | const ( 38 | // JSONSchemaServiceName is the fully-qualified name of the JSONSchemaService service. 39 | JSONSchemaServiceName = "buf.alpha.registry.v1alpha1.JSONSchemaService" 40 | ) 41 | 42 | // These constants are the fully-qualified names of the RPCs defined in this package. They're 43 | // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. 44 | // 45 | // Note that these are different from the fully-qualified method names used by 46 | // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to 47 | // reflection-formatted method names, remove the leading slash and convert the remaining slash to a 48 | // period. 49 | const ( 50 | // JSONSchemaServiceGetJSONSchemaProcedure is the fully-qualified name of the JSONSchemaService's 51 | // GetJSONSchema RPC. 52 | JSONSchemaServiceGetJSONSchemaProcedure = "/buf.alpha.registry.v1alpha1.JSONSchemaService/GetJSONSchema" 53 | ) 54 | 55 | // JSONSchemaServiceClient is a client for the buf.alpha.registry.v1alpha1.JSONSchemaService 56 | // service. 57 | type JSONSchemaServiceClient interface { 58 | // GetJSONSchema allows users to get an (approximate) json schema for a 59 | // protobuf type. 60 | GetJSONSchema(context.Context, *connect.Request[v1alpha1.GetJSONSchemaRequest]) (*connect.Response[v1alpha1.GetJSONSchemaResponse], error) 61 | } 62 | 63 | // NewJSONSchemaServiceClient constructs a client for the 64 | // buf.alpha.registry.v1alpha1.JSONSchemaService service. By default, it uses the Connect protocol 65 | // with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To 66 | // use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() 67 | // options. 68 | // 69 | // The URL supplied here should be the base URL for the Connect or gRPC server (for example, 70 | // http://api.acme.com or https://acme.com/grpc). 71 | func NewJSONSchemaServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) JSONSchemaServiceClient { 72 | baseURL = strings.TrimRight(baseURL, "/") 73 | return &jSONSchemaServiceClient{ 74 | getJSONSchema: connect.NewClient[v1alpha1.GetJSONSchemaRequest, v1alpha1.GetJSONSchemaResponse]( 75 | httpClient, 76 | baseURL+JSONSchemaServiceGetJSONSchemaProcedure, 77 | connect.WithIdempotency(connect.IdempotencyNoSideEffects), 78 | connect.WithClientOptions(opts...), 79 | ), 80 | } 81 | } 82 | 83 | // jSONSchemaServiceClient implements JSONSchemaServiceClient. 84 | type jSONSchemaServiceClient struct { 85 | getJSONSchema *connect.Client[v1alpha1.GetJSONSchemaRequest, v1alpha1.GetJSONSchemaResponse] 86 | } 87 | 88 | // GetJSONSchema calls buf.alpha.registry.v1alpha1.JSONSchemaService.GetJSONSchema. 89 | func (c *jSONSchemaServiceClient) GetJSONSchema(ctx context.Context, req *connect.Request[v1alpha1.GetJSONSchemaRequest]) (*connect.Response[v1alpha1.GetJSONSchemaResponse], error) { 90 | return c.getJSONSchema.CallUnary(ctx, req) 91 | } 92 | 93 | // JSONSchemaServiceHandler is an implementation of the 94 | // buf.alpha.registry.v1alpha1.JSONSchemaService service. 95 | type JSONSchemaServiceHandler interface { 96 | // GetJSONSchema allows users to get an (approximate) json schema for a 97 | // protobuf type. 98 | GetJSONSchema(context.Context, *connect.Request[v1alpha1.GetJSONSchemaRequest]) (*connect.Response[v1alpha1.GetJSONSchemaResponse], error) 99 | } 100 | 101 | // NewJSONSchemaServiceHandler builds an HTTP handler from the service implementation. It returns 102 | // the path on which to mount the handler and the handler itself. 103 | // 104 | // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf 105 | // and JSON codecs. They also support gzip compression. 106 | func NewJSONSchemaServiceHandler(svc JSONSchemaServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { 107 | jSONSchemaServiceGetJSONSchemaHandler := connect.NewUnaryHandler( 108 | JSONSchemaServiceGetJSONSchemaProcedure, 109 | svc.GetJSONSchema, 110 | connect.WithIdempotency(connect.IdempotencyNoSideEffects), 111 | connect.WithHandlerOptions(opts...), 112 | ) 113 | return "/buf.alpha.registry.v1alpha1.JSONSchemaService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 114 | switch r.URL.Path { 115 | case JSONSchemaServiceGetJSONSchemaProcedure: 116 | jSONSchemaServiceGetJSONSchemaHandler.ServeHTTP(w, r) 117 | default: 118 | http.NotFound(w, r) 119 | } 120 | }) 121 | } 122 | 123 | // UnimplementedJSONSchemaServiceHandler returns CodeUnimplemented from all methods. 124 | type UnimplementedJSONSchemaServiceHandler struct{} 125 | 126 | func (UnimplementedJSONSchemaServiceHandler) GetJSONSchema(context.Context, *connect.Request[v1alpha1.GetJSONSchemaRequest]) (*connect.Response[v1alpha1.GetJSONSchemaResponse], error) { 127 | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.JSONSchemaService.GetJSONSchema is not implemented")) 128 | } 129 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/v1alpha1connect/owner.connect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-connect-go. DO NOT EDIT. 16 | // 17 | // Source: buf/alpha/registry/v1alpha1/owner.proto 18 | 19 | package v1alpha1connect 20 | 21 | import ( 22 | connect "connectrpc.com/connect" 23 | context "context" 24 | errors "errors" 25 | v1alpha1 "github.com/easyp-tech/server/gen/proto/buf/alpha/registry/v1alpha1" 26 | http "net/http" 27 | strings "strings" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file and the connect package are 31 | // compatible. If you get a compiler error that this constant is not defined, this code was 32 | // generated with a version of connect newer than the one compiled into your binary. You can fix the 33 | // problem by either regenerating this code with an older version of connect or updating the connect 34 | // version compiled into your binary. 35 | const _ = connect.IsAtLeastVersion1_7_0 36 | 37 | const ( 38 | // OwnerServiceName is the fully-qualified name of the OwnerService service. 39 | OwnerServiceName = "buf.alpha.registry.v1alpha1.OwnerService" 40 | ) 41 | 42 | // These constants are the fully-qualified names of the RPCs defined in this package. They're 43 | // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. 44 | // 45 | // Note that these are different from the fully-qualified method names used by 46 | // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to 47 | // reflection-formatted method names, remove the leading slash and convert the remaining slash to a 48 | // period. 49 | const ( 50 | // OwnerServiceGetOwnerByNameProcedure is the fully-qualified name of the OwnerService's 51 | // GetOwnerByName RPC. 52 | OwnerServiceGetOwnerByNameProcedure = "/buf.alpha.registry.v1alpha1.OwnerService/GetOwnerByName" 53 | ) 54 | 55 | // OwnerServiceClient is a client for the buf.alpha.registry.v1alpha1.OwnerService service. 56 | type OwnerServiceClient interface { 57 | // GetOwnerByName takes an owner name and returns the owner as 58 | // either a user or organization. 59 | GetOwnerByName(context.Context, *connect.Request[v1alpha1.GetOwnerByNameRequest]) (*connect.Response[v1alpha1.GetOwnerByNameResponse], error) 60 | } 61 | 62 | // NewOwnerServiceClient constructs a client for the buf.alpha.registry.v1alpha1.OwnerService 63 | // service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for 64 | // gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply 65 | // the connect.WithGRPC() or connect.WithGRPCWeb() options. 66 | // 67 | // The URL supplied here should be the base URL for the Connect or gRPC server (for example, 68 | // http://api.acme.com or https://acme.com/grpc). 69 | func NewOwnerServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) OwnerServiceClient { 70 | baseURL = strings.TrimRight(baseURL, "/") 71 | return &ownerServiceClient{ 72 | getOwnerByName: connect.NewClient[v1alpha1.GetOwnerByNameRequest, v1alpha1.GetOwnerByNameResponse]( 73 | httpClient, 74 | baseURL+OwnerServiceGetOwnerByNameProcedure, 75 | connect.WithIdempotency(connect.IdempotencyNoSideEffects), 76 | connect.WithClientOptions(opts...), 77 | ), 78 | } 79 | } 80 | 81 | // ownerServiceClient implements OwnerServiceClient. 82 | type ownerServiceClient struct { 83 | getOwnerByName *connect.Client[v1alpha1.GetOwnerByNameRequest, v1alpha1.GetOwnerByNameResponse] 84 | } 85 | 86 | // GetOwnerByName calls buf.alpha.registry.v1alpha1.OwnerService.GetOwnerByName. 87 | func (c *ownerServiceClient) GetOwnerByName(ctx context.Context, req *connect.Request[v1alpha1.GetOwnerByNameRequest]) (*connect.Response[v1alpha1.GetOwnerByNameResponse], error) { 88 | return c.getOwnerByName.CallUnary(ctx, req) 89 | } 90 | 91 | // OwnerServiceHandler is an implementation of the buf.alpha.registry.v1alpha1.OwnerService service. 92 | type OwnerServiceHandler interface { 93 | // GetOwnerByName takes an owner name and returns the owner as 94 | // either a user or organization. 95 | GetOwnerByName(context.Context, *connect.Request[v1alpha1.GetOwnerByNameRequest]) (*connect.Response[v1alpha1.GetOwnerByNameResponse], error) 96 | } 97 | 98 | // NewOwnerServiceHandler builds an HTTP handler from the service implementation. It returns the 99 | // path on which to mount the handler and the handler itself. 100 | // 101 | // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf 102 | // and JSON codecs. They also support gzip compression. 103 | func NewOwnerServiceHandler(svc OwnerServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { 104 | ownerServiceGetOwnerByNameHandler := connect.NewUnaryHandler( 105 | OwnerServiceGetOwnerByNameProcedure, 106 | svc.GetOwnerByName, 107 | connect.WithIdempotency(connect.IdempotencyNoSideEffects), 108 | connect.WithHandlerOptions(opts...), 109 | ) 110 | return "/buf.alpha.registry.v1alpha1.OwnerService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 111 | switch r.URL.Path { 112 | case OwnerServiceGetOwnerByNameProcedure: 113 | ownerServiceGetOwnerByNameHandler.ServeHTTP(w, r) 114 | default: 115 | http.NotFound(w, r) 116 | } 117 | }) 118 | } 119 | 120 | // UnimplementedOwnerServiceHandler returns CodeUnimplemented from all methods. 121 | type UnimplementedOwnerServiceHandler struct{} 122 | 123 | func (UnimplementedOwnerServiceHandler) GetOwnerByName(context.Context, *connect.Request[v1alpha1.GetOwnerByNameRequest]) (*connect.Response[v1alpha1.GetOwnerByNameResponse], error) { 124 | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.OwnerService.GetOwnerByName is not implemented")) 125 | } 126 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/v1alpha1connect/push.connect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-connect-go. DO NOT EDIT. 16 | // 17 | // Source: buf/alpha/registry/v1alpha1/push.proto 18 | 19 | package v1alpha1connect 20 | 21 | import ( 22 | connect "connectrpc.com/connect" 23 | context "context" 24 | errors "errors" 25 | v1alpha1 "github.com/easyp-tech/server/gen/proto/buf/alpha/registry/v1alpha1" 26 | http "net/http" 27 | strings "strings" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file and the connect package are 31 | // compatible. If you get a compiler error that this constant is not defined, this code was 32 | // generated with a version of connect newer than the one compiled into your binary. You can fix the 33 | // problem by either regenerating this code with an older version of connect or updating the connect 34 | // version compiled into your binary. 35 | const _ = connect.IsAtLeastVersion1_7_0 36 | 37 | const ( 38 | // PushServiceName is the fully-qualified name of the PushService service. 39 | PushServiceName = "buf.alpha.registry.v1alpha1.PushService" 40 | ) 41 | 42 | // These constants are the fully-qualified names of the RPCs defined in this package. They're 43 | // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. 44 | // 45 | // Note that these are different from the fully-qualified method names used by 46 | // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to 47 | // reflection-formatted method names, remove the leading slash and convert the remaining slash to a 48 | // period. 49 | const ( 50 | // PushServicePushProcedure is the fully-qualified name of the PushService's Push RPC. 51 | PushServicePushProcedure = "/buf.alpha.registry.v1alpha1.PushService/Push" 52 | // PushServicePushManifestAndBlobsProcedure is the fully-qualified name of the PushService's 53 | // PushManifestAndBlobs RPC. 54 | PushServicePushManifestAndBlobsProcedure = "/buf.alpha.registry.v1alpha1.PushService/PushManifestAndBlobs" 55 | ) 56 | 57 | // PushServiceClient is a client for the buf.alpha.registry.v1alpha1.PushService service. 58 | type PushServiceClient interface { 59 | // Push pushes. 60 | // NOTE: Newer clients should use PushManifestAndBlobs. 61 | Push(context.Context, *connect.Request[v1alpha1.PushRequest]) (*connect.Response[v1alpha1.PushResponse], error) 62 | // PushManifestAndBlobs pushes a module by encoding it in a manifest and blobs format. 63 | PushManifestAndBlobs(context.Context, *connect.Request[v1alpha1.PushManifestAndBlobsRequest]) (*connect.Response[v1alpha1.PushManifestAndBlobsResponse], error) 64 | } 65 | 66 | // NewPushServiceClient constructs a client for the buf.alpha.registry.v1alpha1.PushService service. 67 | // By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped 68 | // responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the 69 | // connect.WithGRPC() or connect.WithGRPCWeb() options. 70 | // 71 | // The URL supplied here should be the base URL for the Connect or gRPC server (for example, 72 | // http://api.acme.com or https://acme.com/grpc). 73 | func NewPushServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) PushServiceClient { 74 | baseURL = strings.TrimRight(baseURL, "/") 75 | return &pushServiceClient{ 76 | push: connect.NewClient[v1alpha1.PushRequest, v1alpha1.PushResponse]( 77 | httpClient, 78 | baseURL+PushServicePushProcedure, 79 | connect.WithIdempotency(connect.IdempotencyIdempotent), 80 | connect.WithClientOptions(opts...), 81 | ), 82 | pushManifestAndBlobs: connect.NewClient[v1alpha1.PushManifestAndBlobsRequest, v1alpha1.PushManifestAndBlobsResponse]( 83 | httpClient, 84 | baseURL+PushServicePushManifestAndBlobsProcedure, 85 | connect.WithIdempotency(connect.IdempotencyIdempotent), 86 | connect.WithClientOptions(opts...), 87 | ), 88 | } 89 | } 90 | 91 | // pushServiceClient implements PushServiceClient. 92 | type pushServiceClient struct { 93 | push *connect.Client[v1alpha1.PushRequest, v1alpha1.PushResponse] 94 | pushManifestAndBlobs *connect.Client[v1alpha1.PushManifestAndBlobsRequest, v1alpha1.PushManifestAndBlobsResponse] 95 | } 96 | 97 | // Push calls buf.alpha.registry.v1alpha1.PushService.Push. 98 | func (c *pushServiceClient) Push(ctx context.Context, req *connect.Request[v1alpha1.PushRequest]) (*connect.Response[v1alpha1.PushResponse], error) { 99 | return c.push.CallUnary(ctx, req) 100 | } 101 | 102 | // PushManifestAndBlobs calls buf.alpha.registry.v1alpha1.PushService.PushManifestAndBlobs. 103 | func (c *pushServiceClient) PushManifestAndBlobs(ctx context.Context, req *connect.Request[v1alpha1.PushManifestAndBlobsRequest]) (*connect.Response[v1alpha1.PushManifestAndBlobsResponse], error) { 104 | return c.pushManifestAndBlobs.CallUnary(ctx, req) 105 | } 106 | 107 | // PushServiceHandler is an implementation of the buf.alpha.registry.v1alpha1.PushService service. 108 | type PushServiceHandler interface { 109 | // Push pushes. 110 | // NOTE: Newer clients should use PushManifestAndBlobs. 111 | Push(context.Context, *connect.Request[v1alpha1.PushRequest]) (*connect.Response[v1alpha1.PushResponse], error) 112 | // PushManifestAndBlobs pushes a module by encoding it in a manifest and blobs format. 113 | PushManifestAndBlobs(context.Context, *connect.Request[v1alpha1.PushManifestAndBlobsRequest]) (*connect.Response[v1alpha1.PushManifestAndBlobsResponse], error) 114 | } 115 | 116 | // NewPushServiceHandler builds an HTTP handler from the service implementation. It returns the path 117 | // on which to mount the handler and the handler itself. 118 | // 119 | // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf 120 | // and JSON codecs. They also support gzip compression. 121 | func NewPushServiceHandler(svc PushServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { 122 | pushServicePushHandler := connect.NewUnaryHandler( 123 | PushServicePushProcedure, 124 | svc.Push, 125 | connect.WithIdempotency(connect.IdempotencyIdempotent), 126 | connect.WithHandlerOptions(opts...), 127 | ) 128 | pushServicePushManifestAndBlobsHandler := connect.NewUnaryHandler( 129 | PushServicePushManifestAndBlobsProcedure, 130 | svc.PushManifestAndBlobs, 131 | connect.WithIdempotency(connect.IdempotencyIdempotent), 132 | connect.WithHandlerOptions(opts...), 133 | ) 134 | return "/buf.alpha.registry.v1alpha1.PushService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 135 | switch r.URL.Path { 136 | case PushServicePushProcedure: 137 | pushServicePushHandler.ServeHTTP(w, r) 138 | case PushServicePushManifestAndBlobsProcedure: 139 | pushServicePushManifestAndBlobsHandler.ServeHTTP(w, r) 140 | default: 141 | http.NotFound(w, r) 142 | } 143 | }) 144 | } 145 | 146 | // UnimplementedPushServiceHandler returns CodeUnimplemented from all methods. 147 | type UnimplementedPushServiceHandler struct{} 148 | 149 | func (UnimplementedPushServiceHandler) Push(context.Context, *connect.Request[v1alpha1.PushRequest]) (*connect.Response[v1alpha1.PushResponse], error) { 150 | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PushService.Push is not implemented")) 151 | } 152 | 153 | func (UnimplementedPushServiceHandler) PushManifestAndBlobs(context.Context, *connect.Request[v1alpha1.PushManifestAndBlobsRequest]) (*connect.Response[v1alpha1.PushManifestAndBlobsResponse], error) { 154 | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PushService.PushManifestAndBlobs is not implemented")) 155 | } 156 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/registry/v1alpha1/v1alpha1connect/resource.connect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-connect-go. DO NOT EDIT. 16 | // 17 | // Source: buf/alpha/registry/v1alpha1/resource.proto 18 | 19 | package v1alpha1connect 20 | 21 | import ( 22 | connect "connectrpc.com/connect" 23 | context "context" 24 | errors "errors" 25 | v1alpha1 "github.com/easyp-tech/server/gen/proto/buf/alpha/registry/v1alpha1" 26 | http "net/http" 27 | strings "strings" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file and the connect package are 31 | // compatible. If you get a compiler error that this constant is not defined, this code was 32 | // generated with a version of connect newer than the one compiled into your binary. You can fix the 33 | // problem by either regenerating this code with an older version of connect or updating the connect 34 | // version compiled into your binary. 35 | const _ = connect.IsAtLeastVersion1_7_0 36 | 37 | const ( 38 | // ResourceServiceName is the fully-qualified name of the ResourceService service. 39 | ResourceServiceName = "buf.alpha.registry.v1alpha1.ResourceService" 40 | ) 41 | 42 | // These constants are the fully-qualified names of the RPCs defined in this package. They're 43 | // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. 44 | // 45 | // Note that these are different from the fully-qualified method names used by 46 | // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to 47 | // reflection-formatted method names, remove the leading slash and convert the remaining slash to a 48 | // period. 49 | const ( 50 | // ResourceServiceGetResourceByNameProcedure is the fully-qualified name of the ResourceService's 51 | // GetResourceByName RPC. 52 | ResourceServiceGetResourceByNameProcedure = "/buf.alpha.registry.v1alpha1.ResourceService/GetResourceByName" 53 | ) 54 | 55 | // ResourceServiceClient is a client for the buf.alpha.registry.v1alpha1.ResourceService service. 56 | type ResourceServiceClient interface { 57 | // GetResourceByName takes a resource name and returns the 58 | // resource either as a repository or a plugin. 59 | GetResourceByName(context.Context, *connect.Request[v1alpha1.GetResourceByNameRequest]) (*connect.Response[v1alpha1.GetResourceByNameResponse], error) 60 | } 61 | 62 | // NewResourceServiceClient constructs a client for the buf.alpha.registry.v1alpha1.ResourceService 63 | // service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for 64 | // gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply 65 | // the connect.WithGRPC() or connect.WithGRPCWeb() options. 66 | // 67 | // The URL supplied here should be the base URL for the Connect or gRPC server (for example, 68 | // http://api.acme.com or https://acme.com/grpc). 69 | func NewResourceServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ResourceServiceClient { 70 | baseURL = strings.TrimRight(baseURL, "/") 71 | return &resourceServiceClient{ 72 | getResourceByName: connect.NewClient[v1alpha1.GetResourceByNameRequest, v1alpha1.GetResourceByNameResponse]( 73 | httpClient, 74 | baseURL+ResourceServiceGetResourceByNameProcedure, 75 | connect.WithIdempotency(connect.IdempotencyNoSideEffects), 76 | connect.WithClientOptions(opts...), 77 | ), 78 | } 79 | } 80 | 81 | // resourceServiceClient implements ResourceServiceClient. 82 | type resourceServiceClient struct { 83 | getResourceByName *connect.Client[v1alpha1.GetResourceByNameRequest, v1alpha1.GetResourceByNameResponse] 84 | } 85 | 86 | // GetResourceByName calls buf.alpha.registry.v1alpha1.ResourceService.GetResourceByName. 87 | func (c *resourceServiceClient) GetResourceByName(ctx context.Context, req *connect.Request[v1alpha1.GetResourceByNameRequest]) (*connect.Response[v1alpha1.GetResourceByNameResponse], error) { 88 | return c.getResourceByName.CallUnary(ctx, req) 89 | } 90 | 91 | // ResourceServiceHandler is an implementation of the buf.alpha.registry.v1alpha1.ResourceService 92 | // service. 93 | type ResourceServiceHandler interface { 94 | // GetResourceByName takes a resource name and returns the 95 | // resource either as a repository or a plugin. 96 | GetResourceByName(context.Context, *connect.Request[v1alpha1.GetResourceByNameRequest]) (*connect.Response[v1alpha1.GetResourceByNameResponse], error) 97 | } 98 | 99 | // NewResourceServiceHandler builds an HTTP handler from the service implementation. It returns the 100 | // path on which to mount the handler and the handler itself. 101 | // 102 | // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf 103 | // and JSON codecs. They also support gzip compression. 104 | func NewResourceServiceHandler(svc ResourceServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { 105 | resourceServiceGetResourceByNameHandler := connect.NewUnaryHandler( 106 | ResourceServiceGetResourceByNameProcedure, 107 | svc.GetResourceByName, 108 | connect.WithIdempotency(connect.IdempotencyNoSideEffects), 109 | connect.WithHandlerOptions(opts...), 110 | ) 111 | return "/buf.alpha.registry.v1alpha1.ResourceService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 112 | switch r.URL.Path { 113 | case ResourceServiceGetResourceByNameProcedure: 114 | resourceServiceGetResourceByNameHandler.ServeHTTP(w, r) 115 | default: 116 | http.NotFound(w, r) 117 | } 118 | }) 119 | } 120 | 121 | // UnimplementedResourceServiceHandler returns CodeUnimplemented from all methods. 122 | type UnimplementedResourceServiceHandler struct{} 123 | 124 | func (UnimplementedResourceServiceHandler) GetResourceByName(context.Context, *connect.Request[v1alpha1.GetResourceByNameRequest]) (*connect.Response[v1alpha1.GetResourceByNameResponse], error) { 125 | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.ResourceService.GetResourceByName is not implemented")) 126 | } 127 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/webhook/v1alpha1/event_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 | // versions: 17 | // - protoc-gen-go-grpc v1.3.0 18 | // - protoc (unknown) 19 | // source: buf/alpha/webhook/v1alpha1/event.proto 20 | 21 | package v1alpha1 22 | 23 | import ( 24 | context "context" 25 | grpc "google.golang.org/grpc" 26 | codes "google.golang.org/grpc/codes" 27 | status "google.golang.org/grpc/status" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file 31 | // is compatible with the grpc package it is being compiled against. 32 | // Requires gRPC-Go v1.32.0 or later. 33 | const _ = grpc.SupportPackageIsVersion7 34 | 35 | const ( 36 | EventService_Event_FullMethodName = "/buf.alpha.webhook.v1alpha1.EventService/Event" 37 | ) 38 | 39 | // EventServiceClient is the client API for EventService service. 40 | // 41 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 42 | type EventServiceClient interface { 43 | // Event is the rpc which receives webhook events. 44 | Event(ctx context.Context, in *EventRequest, opts ...grpc.CallOption) (*EventResponse, error) 45 | } 46 | 47 | type eventServiceClient struct { 48 | cc grpc.ClientConnInterface 49 | } 50 | 51 | func NewEventServiceClient(cc grpc.ClientConnInterface) EventServiceClient { 52 | return &eventServiceClient{cc} 53 | } 54 | 55 | func (c *eventServiceClient) Event(ctx context.Context, in *EventRequest, opts ...grpc.CallOption) (*EventResponse, error) { 56 | out := new(EventResponse) 57 | err := c.cc.Invoke(ctx, EventService_Event_FullMethodName, in, out, opts...) 58 | if err != nil { 59 | return nil, err 60 | } 61 | return out, nil 62 | } 63 | 64 | // EventServiceServer is the server API for EventService service. 65 | // All implementations should embed UnimplementedEventServiceServer 66 | // for forward compatibility 67 | type EventServiceServer interface { 68 | // Event is the rpc which receives webhook events. 69 | Event(context.Context, *EventRequest) (*EventResponse, error) 70 | } 71 | 72 | // UnimplementedEventServiceServer should be embedded to have forward compatible implementations. 73 | type UnimplementedEventServiceServer struct { 74 | } 75 | 76 | func (UnimplementedEventServiceServer) Event(context.Context, *EventRequest) (*EventResponse, error) { 77 | return nil, status.Errorf(codes.Unimplemented, "method Event not implemented") 78 | } 79 | 80 | // UnsafeEventServiceServer may be embedded to opt out of forward compatibility for this service. 81 | // Use of this interface is not recommended, as added methods to EventServiceServer will 82 | // result in compilation errors. 83 | type UnsafeEventServiceServer interface { 84 | mustEmbedUnimplementedEventServiceServer() 85 | } 86 | 87 | func RegisterEventServiceServer(s grpc.ServiceRegistrar, srv EventServiceServer) { 88 | s.RegisterService(&EventService_ServiceDesc, srv) 89 | } 90 | 91 | func _EventService_Event_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 92 | in := new(EventRequest) 93 | if err := dec(in); err != nil { 94 | return nil, err 95 | } 96 | if interceptor == nil { 97 | return srv.(EventServiceServer).Event(ctx, in) 98 | } 99 | info := &grpc.UnaryServerInfo{ 100 | Server: srv, 101 | FullMethod: EventService_Event_FullMethodName, 102 | } 103 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 104 | return srv.(EventServiceServer).Event(ctx, req.(*EventRequest)) 105 | } 106 | return interceptor(ctx, in, info, handler) 107 | } 108 | 109 | // EventService_ServiceDesc is the grpc.ServiceDesc for EventService service. 110 | // It's only intended for direct use with grpc.RegisterService, 111 | // and not to be introspected or modified (even as a copy) 112 | var EventService_ServiceDesc = grpc.ServiceDesc{ 113 | ServiceName: "buf.alpha.webhook.v1alpha1.EventService", 114 | HandlerType: (*EventServiceServer)(nil), 115 | Methods: []grpc.MethodDesc{ 116 | { 117 | MethodName: "Event", 118 | Handler: _EventService_Event_Handler, 119 | }, 120 | }, 121 | Streams: []grpc.StreamDesc{}, 122 | Metadata: "buf/alpha/webhook/v1alpha1/event.proto", 123 | } 124 | -------------------------------------------------------------------------------- /gen/proto/buf/alpha/webhook/v1alpha1/v1alpha1connect/event.connect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by protoc-gen-connect-go. DO NOT EDIT. 16 | // 17 | // Source: buf/alpha/webhook/v1alpha1/event.proto 18 | 19 | package v1alpha1connect 20 | 21 | import ( 22 | connect "connectrpc.com/connect" 23 | context "context" 24 | errors "errors" 25 | v1alpha1 "github.com/easyp-tech/server/gen/proto/buf/alpha/webhook/v1alpha1" 26 | http "net/http" 27 | strings "strings" 28 | ) 29 | 30 | // This is a compile-time assertion to ensure that this generated file and the connect package are 31 | // compatible. If you get a compiler error that this constant is not defined, this code was 32 | // generated with a version of connect newer than the one compiled into your binary. You can fix the 33 | // problem by either regenerating this code with an older version of connect or updating the connect 34 | // version compiled into your binary. 35 | const _ = connect.IsAtLeastVersion0_1_0 36 | 37 | const ( 38 | // EventServiceName is the fully-qualified name of the EventService service. 39 | EventServiceName = "buf.alpha.webhook.v1alpha1.EventService" 40 | ) 41 | 42 | // These constants are the fully-qualified names of the RPCs defined in this package. They're 43 | // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. 44 | // 45 | // Note that these are different from the fully-qualified method names used by 46 | // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to 47 | // reflection-formatted method names, remove the leading slash and convert the remaining slash to a 48 | // period. 49 | const ( 50 | // EventServiceEventProcedure is the fully-qualified name of the EventService's Event RPC. 51 | EventServiceEventProcedure = "/buf.alpha.webhook.v1alpha1.EventService/Event" 52 | ) 53 | 54 | // EventServiceClient is a client for the buf.alpha.webhook.v1alpha1.EventService service. 55 | type EventServiceClient interface { 56 | // Event is the rpc which receives webhook events. 57 | Event(context.Context, *connect.Request[v1alpha1.EventRequest]) (*connect.Response[v1alpha1.EventResponse], error) 58 | } 59 | 60 | // NewEventServiceClient constructs a client for the buf.alpha.webhook.v1alpha1.EventService 61 | // service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for 62 | // gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply 63 | // the connect.WithGRPC() or connect.WithGRPCWeb() options. 64 | // 65 | // The URL supplied here should be the base URL for the Connect or gRPC server (for example, 66 | // http://api.acme.com or https://acme.com/grpc). 67 | func NewEventServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) EventServiceClient { 68 | baseURL = strings.TrimRight(baseURL, "/") 69 | return &eventServiceClient{ 70 | event: connect.NewClient[v1alpha1.EventRequest, v1alpha1.EventResponse]( 71 | httpClient, 72 | baseURL+EventServiceEventProcedure, 73 | opts..., 74 | ), 75 | } 76 | } 77 | 78 | // eventServiceClient implements EventServiceClient. 79 | type eventServiceClient struct { 80 | event *connect.Client[v1alpha1.EventRequest, v1alpha1.EventResponse] 81 | } 82 | 83 | // Event calls buf.alpha.webhook.v1alpha1.EventService.Event. 84 | func (c *eventServiceClient) Event(ctx context.Context, req *connect.Request[v1alpha1.EventRequest]) (*connect.Response[v1alpha1.EventResponse], error) { 85 | return c.event.CallUnary(ctx, req) 86 | } 87 | 88 | // EventServiceHandler is an implementation of the buf.alpha.webhook.v1alpha1.EventService service. 89 | type EventServiceHandler interface { 90 | // Event is the rpc which receives webhook events. 91 | Event(context.Context, *connect.Request[v1alpha1.EventRequest]) (*connect.Response[v1alpha1.EventResponse], error) 92 | } 93 | 94 | // NewEventServiceHandler builds an HTTP handler from the service implementation. It returns the 95 | // path on which to mount the handler and the handler itself. 96 | // 97 | // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf 98 | // and JSON codecs. They also support gzip compression. 99 | func NewEventServiceHandler(svc EventServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { 100 | eventServiceEventHandler := connect.NewUnaryHandler( 101 | EventServiceEventProcedure, 102 | svc.Event, 103 | opts..., 104 | ) 105 | return "/buf.alpha.webhook.v1alpha1.EventService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 106 | switch r.URL.Path { 107 | case EventServiceEventProcedure: 108 | eventServiceEventHandler.ServeHTTP(w, r) 109 | default: 110 | http.NotFound(w, r) 111 | } 112 | }) 113 | } 114 | 115 | // UnimplementedEventServiceHandler returns CodeUnimplemented from all methods. 116 | type UnimplementedEventServiceHandler struct{} 117 | 118 | func (UnimplementedEventServiceHandler) Event(context.Context, *connect.Request[v1alpha1.EventRequest]) (*connect.Response[v1alpha1.EventResponse], error) { 119 | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("buf.alpha.webhook.v1alpha1.EventService.Event is not implemented")) 120 | } 121 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/easyp-tech/server 2 | 3 | go 1.22 4 | 5 | require ( 6 | connectrpc.com/connect v1.11.1 7 | github.com/ghodss/yaml v1.0.0 8 | github.com/go-git/go-git/v5 v5.9.0 9 | github.com/google/go-github/v59 v59.0.0 10 | golang.org/x/crypto v0.23.0 11 | golang.org/x/exp v0.0.0-20231006140011-7918f672742d 12 | google.golang.org/grpc v1.59.0 13 | google.golang.org/protobuf v1.34.1 14 | ) 15 | 16 | require ( 17 | dario.cat/mergo v1.0.0 // indirect 18 | github.com/Microsoft/go-winio v0.6.1 // indirect 19 | github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect 20 | github.com/acomagu/bufpipe v1.0.4 // indirect 21 | github.com/cloudflare/circl v1.3.3 // indirect 22 | github.com/cyphar/filepath-securejoin v0.2.4 // indirect 23 | github.com/emirpasic/gods v1.18.1 // indirect 24 | github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect 25 | github.com/go-git/go-billy/v5 v5.5.0 // indirect 26 | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect 27 | github.com/golang/protobuf v1.5.4 // indirect 28 | github.com/google/go-querystring v1.1.0 // indirect 29 | github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect 30 | github.com/kevinburke/ssh_config v1.2.0 // indirect 31 | github.com/pjbgf/sha1cd v0.3.0 // indirect 32 | github.com/sergi/go-diff v1.1.0 // indirect 33 | github.com/skeema/knownhosts v1.2.0 // indirect 34 | github.com/stretchr/testify v1.8.4 // indirect 35 | github.com/xanzy/ssh-agent v0.3.3 // indirect 36 | golang.org/x/mod v0.13.0 // indirect 37 | golang.org/x/net v0.25.0 // indirect 38 | golang.org/x/sys v0.20.0 // indirect 39 | golang.org/x/text v0.15.0 // indirect 40 | golang.org/x/tools v0.14.0 // indirect 41 | google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect 42 | gopkg.in/warnings.v0 v0.1.2 // indirect 43 | gopkg.in/yaml.v2 v2.4.0 // indirect 44 | ) 45 | -------------------------------------------------------------------------------- /internal/connect/api.go: -------------------------------------------------------------------------------- 1 | package connect 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | 7 | "golang.org/x/exp/slog" 8 | 9 | connect "github.com/easyp-tech/server/gen/proto/buf/alpha/registry/v1alpha1/v1alpha1connect" 10 | "github.com/easyp-tech/server/internal/providers/content" 11 | ) 12 | 13 | type provider interface { 14 | GetMeta(ctx context.Context, owner, repoName, commit string) (content.Meta, error) 15 | GetFiles(ctx context.Context, owner, repoName, commit string) ([]content.File, error) 16 | } 17 | 18 | type api struct { 19 | log *slog.Logger 20 | connect.UnimplementedRepositoryServiceHandler 21 | connect.UnimplementedResolveServiceHandler 22 | connect.UnimplementedDownloadServiceHandler 23 | repo provider 24 | domain string 25 | } 26 | 27 | // New creates and returns gRPC server. 28 | func New( 29 | log *slog.Logger, 30 | core provider, 31 | domain string, 32 | ) *http.ServeMux { 33 | a := &api{ //nolint:exhaustruct 34 | log: log, 35 | repo: core, 36 | domain: domain, 37 | } 38 | 39 | mux := http.NewServeMux() 40 | mux.Handle(connect.NewResolveServiceHandler(a)) 41 | mux.Handle(connect.NewRepositoryServiceHandler(a)) 42 | mux.Handle(connect.NewDownloadServiceHandler(a)) 43 | 44 | return mux 45 | } 46 | -------------------------------------------------------------------------------- /internal/connect/blobs.go: -------------------------------------------------------------------------------- 1 | package connect 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "fmt" 7 | 8 | "connectrpc.com/connect" 9 | 10 | module "github.com/easyp-tech/server/gen/proto/buf/alpha/module/v1alpha1" 11 | registry "github.com/easyp-tech/server/gen/proto/buf/alpha/registry/v1alpha1" 12 | "github.com/easyp-tech/server/internal/shake256" 13 | ) 14 | 15 | const digestFormat = "shake256:%s %s\n" 16 | 17 | func (a *api) DownloadManifestAndBlobs( 18 | ctx context.Context, 19 | req *connect.Request[registry.DownloadManifestAndBlobsRequest], 20 | ) ( 21 | *connect.Response[registry.DownloadManifestAndBlobsResponse], 22 | error, 23 | ) { 24 | files, err := a.repo.GetFiles(ctx, req.Msg.GetOwner(), req.Msg.GetRepository(), req.Msg.GetReference()) 25 | if err != nil { 26 | return nil, fmt.Errorf("a.repo.GetRepository: %w", err) 27 | } 28 | 29 | var ( 30 | manifest bytes.Buffer 31 | blobs = make([]*module.Blob, 0, len(files)) 32 | ) 33 | 34 | for _, file := range files { 35 | fmt.Fprintf(&manifest, digestFormat, file.Hash.String(), file.Path) 36 | blobs = append(blobs, buildBlob(file.Hash, file.Data)) 37 | } 38 | 39 | manifestHash, err := shake256.SHA3Shake256(manifest.Bytes()) 40 | if err != nil { 41 | return nil, fmt.Errorf("calculating manifest hash: %w", err) 42 | } 43 | 44 | return &connect.Response[registry.DownloadManifestAndBlobsResponse]{ 45 | Msg: ®istry.DownloadManifestAndBlobsResponse{ 46 | Manifest: &module.Blob{ 47 | Digest: &module.Digest{ 48 | DigestType: module.DigestType_DIGEST_TYPE_SHAKE256, 49 | Digest: manifestHash[:], 50 | }, 51 | Content: manifest.Bytes(), 52 | }, 53 | Blobs: blobs, 54 | }, 55 | }, nil 56 | } 57 | 58 | func buildBlob(hash shake256.Hash, data []byte) *module.Blob { 59 | return &module.Blob{ 60 | Digest: &module.Digest{ 61 | DigestType: module.DigestType_DIGEST_TYPE_SHAKE256, 62 | Digest: hash[:], 63 | }, 64 | Content: data, 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /internal/connect/bynames.go: -------------------------------------------------------------------------------- 1 | package connect 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "path" 7 | "strings" 8 | 9 | "connectrpc.com/connect" 10 | "google.golang.org/protobuf/types/known/timestamppb" 11 | 12 | registry "github.com/easyp-tech/server/gen/proto/buf/alpha/registry/v1alpha1" 13 | ) 14 | 15 | func (a *api) GetRepositoriesByFullName( 16 | ctx context.Context, 17 | req *connect.Request[registry.GetRepositoriesByFullNameRequest], 18 | ) ( 19 | *connect.Response[registry.GetRepositoriesByFullNameResponse], 20 | error, 21 | ) { 22 | repositories, err := a.resolveReposByFullNames(ctx, req.Msg.GetFullNames()) 23 | if err != nil { 24 | return nil, fmt.Errorf("getting repositories: %w", err) 25 | } 26 | 27 | return &connect.Response[registry.GetRepositoriesByFullNameResponse]{ 28 | Msg: ®istry.GetRepositoriesByFullNameResponse{Repositories: repositories}, 29 | }, nil 30 | } 31 | 32 | func (a *api) GetRepositoryByFullName( 33 | ctx context.Context, 34 | req *connect.Request[registry.GetRepositoryByFullNameRequest], 35 | ) ( 36 | *connect.Response[registry.GetRepositoryByFullNameResponse], 37 | error, 38 | ) { 39 | repository, err := a.resolveRepoByFullName(ctx, req.Msg.GetFullName()) 40 | if err != nil { 41 | return nil, fmt.Errorf("getting repositories: %w", err) 42 | } 43 | 44 | return &connect.Response[registry.GetRepositoryByFullNameResponse]{ 45 | Msg: ®istry.GetRepositoryByFullNameResponse{Repository: repository}, //nolint:exhaustruct 46 | }, nil 47 | } 48 | 49 | func (a *api) resolveReposByFullNames(ctx context.Context, in []string) ([]*registry.Repository, error) { 50 | out := make([]*registry.Repository, 0, len(in)) 51 | 52 | for i, name := range in { 53 | v, err := a.resolveRepoByFullName(ctx, name) 54 | if err != nil { 55 | return out, fmt.Errorf("iterating %d of %d: %w", i, len(in), err) 56 | } 57 | 58 | out = append(out, v) 59 | } 60 | 61 | return out, nil 62 | } 63 | 64 | func (a *api) resolveRepoByFullName(ctx context.Context, name string) (*registry.Repository, error) { 65 | owner, repositoryName := splitRepoName(name) 66 | 67 | repo, err := a.repo.GetMeta(ctx, owner, repositoryName, "") 68 | if err != nil { 69 | return nil, fmt.Errorf("resolving %q: %w", name, err) 70 | } 71 | 72 | //nolint:godox,exhaustruct 73 | return ®istry.Repository{ 74 | Id: path.Join(a.domain, owner, repositoryName), 75 | CreateTime: timestamppb.New(repo.CreatedAt), 76 | UpdateTime: timestamppb.New(repo.UpdatedAt), 77 | Name: repositoryName, 78 | Owner: ®istry.Repository_UserId{UserId: owner}, 79 | Visibility: registry.Visibility_VISIBILITY_PUBLIC, 80 | OwnerName: owner, 81 | Description: "", // TODO 82 | Url: path.Join(a.domain, owner, repositoryName), 83 | DefaultBranch: repo.DefaultBranch, 84 | }, nil 85 | } 86 | 87 | func splitRepoName(name string) (string, string) { 88 | fields := strings.Split(name, "/") 89 | 90 | return fields[0], fields[1] 91 | } 92 | -------------------------------------------------------------------------------- /internal/connect/modulepins.go: -------------------------------------------------------------------------------- 1 | package connect 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "connectrpc.com/connect" 8 | 9 | module "github.com/easyp-tech/server/gen/proto/buf/alpha/module/v1alpha1" 10 | registry "github.com/easyp-tech/server/gen/proto/buf/alpha/registry/v1alpha1" 11 | ) 12 | 13 | func (a *api) GetModulePins( 14 | ctx context.Context, 15 | req *connect.Request[registry.GetModulePinsRequest], 16 | ) ( 17 | *connect.Response[registry.GetModulePinsResponse], 18 | error, 19 | ) { 20 | modulePins, err := a.resolveModulePins(ctx, req.Msg.GetModuleReferences()) 21 | if err != nil { 22 | return nil, fmt.Errorf("getting repository: %w", err) 23 | } 24 | 25 | return &connect.Response[registry.GetModulePinsResponse]{ 26 | Msg: ®istry.GetModulePinsResponse{ModulePins: modulePins}, 27 | }, nil 28 | } 29 | 30 | func (a *api) resolveModulePins(ctx context.Context, in []*module.ModuleReference) ([]*module.ModulePin, error) { 31 | out := make([]*module.ModulePin, 0, len(in)) 32 | 33 | for i, m := range in { 34 | v, err := a.resolveModulePin(ctx, m) 35 | if err != nil { 36 | return out, fmt.Errorf("iterating %d of %d: %w", i, len(in), err) 37 | } 38 | 39 | out = append(out, v) 40 | } 41 | 42 | return out, nil 43 | } 44 | 45 | func (a *api) resolveModulePin(ctx context.Context, v *module.ModuleReference) (*module.ModulePin, error) { 46 | repo, err := a.repo.GetMeta(ctx, v.GetOwner(), v.GetRepository(), v.GetReference()) 47 | if err != nil { 48 | return nil, fmt.Errorf("resolving %q/%q:%q: %w", v.GetOwner(), v.GetRepository(), v.GetReference(), err) 49 | } 50 | 51 | return &module.ModulePin{ //nolint:exhaustruct 52 | Remote: a.domain, 53 | Owner: v.GetOwner(), 54 | Repository: v.GetRepository(), 55 | Commit: repo.Commit, 56 | }, nil 57 | } 58 | -------------------------------------------------------------------------------- /internal/https/https.go: -------------------------------------------------------------------------------- 1 | package https 2 | 3 | import ( 4 | "crypto/tls" 5 | "crypto/x509" 6 | "fmt" 7 | "net/http" 8 | "net/netip" 9 | "os" 10 | "time" 11 | ) 12 | 13 | const ReadHeaderTimeout = 10 * time.Second 14 | 15 | func ListenAndServe( 16 | listen netip.AddrPort, 17 | handler http.Handler, 18 | certFileName, 19 | keyFileName, 20 | caFileName string, 21 | ) error { 22 | server := &http.Server{ //nolint:exhaustruct 23 | Addr: listen.String(), 24 | Handler: handler, 25 | ReadHeaderTimeout: ReadHeaderTimeout, 26 | } 27 | 28 | if caFileName != "" { 29 | caCertPool, err := loadCA(caFileName) 30 | if err != nil { 31 | return fmt.Errorf("loading CA %q: %w", caFileName, err) 32 | } 33 | 34 | server.TLSConfig = &tls.Config{ //nolint:exhaustruct 35 | ClientCAs: caCertPool, 36 | ClientAuth: tls.RequireAndVerifyClientCert, 37 | MinVersion: tls.VersionTLS13, 38 | } 39 | } 40 | 41 | return server.ListenAndServeTLS(certFileName, keyFileName) //nolint:wrapcheck 42 | } 43 | 44 | func loadCA(fileName string) (*x509.CertPool, error) { 45 | caCert, err := os.ReadFile(fileName) 46 | if err != nil { 47 | return nil, fmt.Errorf("loading cert: %w", err) 48 | } 49 | 50 | caCertPool := x509.NewCertPool() 51 | caCertPool.AppendCertsFromPEM(caCert) 52 | 53 | return caCertPool, nil 54 | } 55 | -------------------------------------------------------------------------------- /internal/logger/logger.go: -------------------------------------------------------------------------------- 1 | package logger 2 | 3 | import ( 4 | "os" 5 | 6 | "golang.org/x/exp/slog" 7 | ) 8 | 9 | func New(debug bool) *slog.Logger { 10 | level := slog.LevelInfo 11 | if debug { 12 | level = slog.LevelDebug 13 | } 14 | 15 | return slog.New( 16 | slog.NewTextHandler( 17 | os.Stdout, 18 | &slog.HandlerOptions{ //nolint:exhaustruct 19 | // AddSource: true, 20 | Level: level, 21 | }, 22 | ), 23 | ) 24 | } 25 | -------------------------------------------------------------------------------- /internal/providers/bitbucket/client.go: -------------------------------------------------------------------------------- 1 | package bitbucket 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "encoding/json" 7 | "errors" 8 | "fmt" 9 | "io" 10 | "net/http" 11 | "net/url" 12 | "text/template" 13 | 14 | "golang.org/x/exp/slog" 15 | ) 16 | 17 | type client struct { 18 | log *slog.Logger 19 | client httpClient 20 | } 21 | 22 | func connect(log *slog.Logger, user User, token Password, baseURL string) client { 23 | return client{ 24 | log: log, 25 | client: httpClient{ 26 | basePath: baseURL, 27 | user: string(user), 28 | password: string(token), 29 | }, 30 | } 31 | } 32 | 33 | var ErrUnexpected = errors.New("unexpected") 34 | 35 | type ( 36 | paramsMap map[string]string 37 | qeryMap map[string]string 38 | ) 39 | 40 | func httpGetJSON[T any]( 41 | ctx context.Context, 42 | cln httpClient, 43 | path *template.Template, 44 | params paramsMap, 45 | query qeryMap, 46 | ) (T, error) { 47 | var out T 48 | 49 | body, err := cln.get(ctx, path, params, query) 50 | if err != nil { 51 | return out, fmt.Errorf("requesting: %w", err) 52 | } 53 | 54 | if err = json.Unmarshal(body, &out); err != nil { 55 | return out, fmt.Errorf("decoding: %w", err) 56 | } 57 | 58 | return out, nil 59 | } 60 | 61 | //nolint:gochecknoglobals 62 | var ( 63 | tmplGetDefaultBranch = tmplBuild("/branches/default") 64 | tmplGetFilesList = tmplBuild("/files") 65 | tmplGetFileContent = tmplBuild("/raw/{{.name}}") 66 | ) 67 | 68 | type httpClient struct { 69 | basePath string 70 | user string 71 | password string 72 | } 73 | 74 | func (c httpClient) get( 75 | ctx context.Context, 76 | path *template.Template, 77 | params paramsMap, 78 | query qeryMap, 79 | ) ([]byte, error) { 80 | req, err := http.NewRequestWithContext( 81 | ctx, 82 | http.MethodGet, 83 | c.basePath+tmplExec(path, params), 84 | nil, 85 | ) 86 | if err != nil { 87 | return nil, fmt.Errorf("building request: %w", err) 88 | } 89 | 90 | req.URL.RawQuery = buildQuery(req.URL.Query(), query) 91 | req.SetBasicAuth(c.user, c.password) 92 | req.Header.Add("Accept", "application/json") 93 | 94 | resp, err := http.DefaultClient.Do(req) 95 | if err != nil { 96 | return nil, fmt.Errorf("getting %q: %w", req.URL.String(), err) 97 | } 98 | 99 | defer resp.Body.Close() 100 | 101 | if resp.StatusCode != http.StatusOK { 102 | return nil, fmt.Errorf("getting %q: response %d: %w", req.URL.String(), resp.StatusCode, ErrUnexpected) 103 | } 104 | 105 | b, err := io.ReadAll(resp.Body) 106 | if err != nil { 107 | return nil, fmt.Errorf("reading %q: %w", req.URL.String(), err) 108 | } 109 | 110 | return b, nil 111 | } 112 | 113 | func tmplBuild(tmpl string) *template.Template { 114 | return template.Must(template.New("").Parse(tmpl)) 115 | } 116 | 117 | func tmplExec(tmpl *template.Template, params map[string]string) string { 118 | var buf bytes.Buffer 119 | 120 | if err := tmpl.Execute(&buf, params); err != nil { 121 | panic(err) 122 | } 123 | 124 | return buf.String() 125 | } 126 | 127 | func buildQuery(query url.Values, params map[string]string) string { 128 | for k, v := range params { 129 | query.Set(k, v) 130 | } 131 | 132 | return query.Encode() 133 | } 134 | -------------------------------------------------------------------------------- /internal/providers/bitbucket/getfiles.go: -------------------------------------------------------------------------------- 1 | package bitbucket 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "strings" 7 | 8 | "golang.org/x/exp/slices" 9 | 10 | "github.com/easyp-tech/server/internal/providers/content" 11 | "github.com/easyp-tech/server/internal/providers/filter" 12 | "github.com/easyp-tech/server/internal/shake256" 13 | ) 14 | 15 | func (c client) GetFiles( 16 | ctx context.Context, 17 | commit string, 18 | repo filter.Repo, 19 | ) ([]content.File, error) { 20 | tree, err := c.listFiles(ctx, commit) 21 | if err != nil { 22 | return nil, fmt.Errorf("listing %q: %w", commit, err) 23 | } 24 | 25 | files, err := c.getFiles(ctx, commit, filterEntries(tree, repo)) 26 | if err != nil { 27 | return files, fmt.Errorf("downloading %q: %w", commit, err) 28 | } 29 | 30 | return files, nil 31 | } 32 | 33 | type fileFiltered struct { 34 | orig string 35 | name string 36 | } 37 | 38 | func filterEntries(entries []string, repo filter.Repo) []fileFiltered { 39 | out := make([]fileFiltered, 0, len(entries)) 40 | 41 | for _, entry := range entries { 42 | if name, ok := repo.Check(entry); ok { 43 | out = append(out, fileFiltered{orig: entry, name: name}) 44 | } 45 | } 46 | 47 | slices.SortFunc(out, func(a, b fileFiltered) int { return strings.Compare(a.name, b.name) }) 48 | 49 | return out 50 | } 51 | 52 | func (c client) getFiles( 53 | ctx context.Context, 54 | commit string, 55 | files []fileFiltered, 56 | ) ([]content.File, error) { 57 | out := make([]content.File, 0, len(files)) 58 | 59 | for _, file := range files { 60 | data, err := c.getFile(ctx, c.client, commit, file.orig) 61 | if err != nil { 62 | return nil, fmt.Errorf("downloading %q: %w", file, err) 63 | } 64 | 65 | hash, err := shake256.SHA3Shake256(data) 66 | if err != nil { 67 | return nil, fmt.Errorf("hashing %q: %w", file, err) 68 | } 69 | 70 | out = append(out, content.File{Path: file.name, Data: data, Hash: hash}) 71 | } 72 | 73 | return out, nil 74 | } 75 | 76 | func (c client) getFile( 77 | ctx context.Context, 78 | cln httpClient, 79 | commit string, 80 | name string, 81 | ) ([]byte, error) { 82 | data, err := cln.get( 83 | ctx, 84 | tmplGetFileContent, 85 | paramsMap{"name": name}, 86 | qeryMap{"at": commit}, 87 | ) 88 | if err != nil { 89 | return data, fmt.Errorf("downloading: %w", err) 90 | } 91 | 92 | return data, nil 93 | } 94 | 95 | const filesListUnlimited = "1000000" 96 | 97 | func (c client) listFiles( 98 | ctx context.Context, 99 | commit string, 100 | ) ([]string, error) { 101 | type filesList struct { 102 | Values []string `json:"values"` 103 | Size int `json:"size"` 104 | IsLastPage bool `json:"isLastPage"` 105 | Start int `json:"start"` 106 | Limit int `json:"limit"` 107 | NextPageStart int `json:"nextPageStart"` 108 | } 109 | 110 | list, err := httpGetJSON[filesList]( 111 | ctx, 112 | c.client, 113 | tmplGetFilesList, 114 | nil, 115 | qeryMap{ 116 | "at": commit, 117 | "limit": filesListUnlimited, 118 | }, 119 | ) 120 | if err != nil { 121 | return nil, fmt.Errorf("getting files list: %w", err) 122 | } 123 | 124 | return list.Values, nil 125 | } 126 | -------------------------------------------------------------------------------- /internal/providers/bitbucket/getrepo.go: -------------------------------------------------------------------------------- 1 | package bitbucket 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "fmt" 7 | "time" 8 | 9 | "github.com/easyp-tech/server/internal/providers/content" 10 | ) 11 | 12 | func (c client) getMeta(ctx context.Context, commit string) (content.Meta, error) { 13 | meta, err := c.getRepo(ctx) 14 | if err != nil { 15 | return meta, fmt.Errorf("investigating: %w", err) 16 | } 17 | 18 | if commit != "" && commit != "main" { 19 | meta.Commit = commit 20 | } 21 | 22 | return meta, nil 23 | } 24 | 25 | var ErrEmpty = errors.New("empty") 26 | 27 | func (c client) getRepo(ctx context.Context) (content.Meta, error) { 28 | var out content.Meta 29 | 30 | repo, err := c.searchRepo(ctx) 31 | if err != nil { 32 | return out, fmt.Errorf("searching repo: %w", err) 33 | } 34 | 35 | if repo.DisplayID == "" { 36 | return out, fmt.Errorf("error getting default branch: %w", ErrEmpty) 37 | } 38 | 39 | out.DefaultBranch = repo.DisplayID 40 | out.Commit = repo.LatestCommit 41 | out.CreatedAt = time.Now() 42 | out.UpdatedAt = out.CreatedAt 43 | 44 | return out, nil 45 | } 46 | 47 | type repoInfo struct { 48 | ID string `json:"id"` 49 | DisplayID string `json:"displayId"` 50 | Type string `json:"type"` 51 | LatestCommit string `json:"latestCommit"` 52 | LatestChangeset string `json:"latestChangeset"` 53 | IsDefault bool `json:"isDefault"` 54 | } 55 | 56 | func (c client) searchRepo(ctx context.Context) (repoInfo, error) { 57 | branchInfo, err := httpGetJSON[repoInfo]( 58 | ctx, 59 | c.client, 60 | tmplGetDefaultBranch, 61 | nil, 62 | nil, 63 | ) 64 | if err != nil { 65 | return branchInfo, fmt.Errorf("getting default branch: %w", err) 66 | } 67 | 68 | return branchInfo, nil 69 | } 70 | -------------------------------------------------------------------------------- /internal/providers/bitbucket/repos.go: -------------------------------------------------------------------------------- 1 | package bitbucket 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "hash/crc32" 7 | "net/url" 8 | 9 | "golang.org/x/exp/slices" 10 | "golang.org/x/exp/slog" 11 | 12 | "github.com/easyp-tech/server/internal/providers/content" 13 | "github.com/easyp-tech/server/internal/providers/filter" 14 | "github.com/easyp-tech/server/internal/providers/source" 15 | ) 16 | 17 | type ( 18 | User string 19 | Password string 20 | Project string 21 | ) 22 | 23 | type Repo struct { 24 | User User 25 | Password Password 26 | URL url.URL 27 | filter.Repo 28 | } 29 | 30 | type multiRepo struct { 31 | log *slog.Logger 32 | repos []Repo 33 | } 34 | 35 | func (m multiRepo) Find(owner, name string) source.Source { //nolint:ireturn 36 | s, ok := m.find(owner, name) 37 | if !ok { 38 | return nil 39 | } 40 | 41 | return s 42 | } 43 | 44 | func (m multiRepo) find(owner, name string) (sourceRepo, bool) { 45 | i := slices.IndexFunc(m.repos, func(r Repo) bool { 46 | return r.Repo.Owner == owner && r.Repo.Name == name 47 | }) 48 | if i < 0 { 49 | return sourceRepo{}, false //nolint:exhaustruct 50 | } 51 | 52 | return sourceRepo{log: m.log, repo: m.repos[i]}, true 53 | } 54 | 55 | func NewMultiRepo(log *slog.Logger, repos []Repo) multiRepo { 56 | return multiRepo{ 57 | log: log, 58 | repos: repos, 59 | } 60 | } 61 | 62 | var _ source.Source = sourceRepo{} //nolint:exhaustruct 63 | 64 | type sourceRepo struct { 65 | log *slog.Logger 66 | repo Repo 67 | } 68 | 69 | func (r sourceRepo) ConfigHash() string { 70 | return fmt.Sprintf("%X", crc32.ChecksumIEEE([]byte(fmt.Sprintf("%+v", r.repo.Repo)))) 71 | } 72 | 73 | func (r sourceRepo) Name() string { return "bitbucket proxy" } 74 | 75 | func (r sourceRepo) GetMeta(ctx context.Context, commit string) (content.Meta, error) { 76 | return connect(r.log, r.repo.User, r.repo.Password, r.repo.URL.String()). 77 | getMeta(ctx, commit) 78 | } 79 | 80 | func (r sourceRepo) GetFiles(ctx context.Context, commit string) ([]content.File, error) { 81 | return connect(r.log, r.repo.User, r.repo.Password, r.repo.URL.String()). 82 | GetFiles(ctx, commit, r.repo.Repo) 83 | } 84 | -------------------------------------------------------------------------------- /internal/providers/cache/artifactory/artifactory.go: -------------------------------------------------------------------------------- 1 | package artifactory 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "encoding/json" 7 | "errors" 8 | "fmt" 9 | "io" 10 | "net/http" 11 | "strings" 12 | 13 | "golang.org/x/exp/slog" 14 | 15 | "github.com/easyp-tech/server/internal/providers/content" 16 | ) 17 | 18 | var ErrUnexpected = errors.New("unexpected") 19 | 20 | func New( 21 | log *slog.Logger, 22 | baseURL string, 23 | user string, 24 | password string, 25 | ) artifactory { 26 | return artifactory{ 27 | log: log, 28 | baseURL: baseURL, 29 | user: user, 30 | password: password, 31 | } 32 | } 33 | 34 | type artifactory struct { 35 | log *slog.Logger 36 | baseURL string 37 | user string 38 | password string 39 | } 40 | 41 | func (c artifactory) Get( 42 | ctx context.Context, 43 | owner string, 44 | repoName string, 45 | commit string, 46 | configHash string, 47 | ) ([]content.File, error) { 48 | req, err := http.NewRequestWithContext( 49 | ctx, 50 | http.MethodGet, 51 | strings.Join([]string{c.baseURL, owner, repoName, configHash, commit + ".json"}, "/"), 52 | nil, 53 | ) 54 | if err != nil { 55 | return nil, fmt.Errorf("building request: %w", err) 56 | } 57 | 58 | req.SetBasicAuth(c.user, c.password) 59 | 60 | resp, err := http.DefaultClient.Do(req) 61 | if err != nil { 62 | return nil, fmt.Errorf("getting %q: %w", req.URL.String(), err) 63 | } 64 | 65 | defer resp.Body.Close() 66 | 67 | if resp.StatusCode == http.StatusNotFound { 68 | return nil, nil 69 | } 70 | 71 | if resp.StatusCode != http.StatusOK { 72 | return nil, fmt.Errorf("getting %q: response %d: %w", req.URL.String(), resp.StatusCode, ErrUnexpected) 73 | } 74 | 75 | data, err := io.ReadAll(resp.Body) 76 | if err != nil { 77 | return nil, fmt.Errorf("reading %q: %w", req.URL.String(), err) 78 | } 79 | 80 | var out []content.File 81 | 82 | if err = json.Unmarshal(data, &out); err != nil { //nolint:musttag 83 | return nil, fmt.Errorf("decoding %q: %w", req.URL.String(), err) 84 | } 85 | 86 | return out, nil 87 | } 88 | 89 | func (c artifactory) Put(ctx context.Context, owner, repoName, commit, configHash string, in []content.File) error { 90 | var buf bytes.Buffer 91 | 92 | encoder := json.NewEncoder(&buf) 93 | encoder.SetIndent("", " ") 94 | 95 | if err := encoder.Encode(in); err != nil { //nolint:musttag 96 | return fmt.Errorf("encoding: %w", err) 97 | } 98 | 99 | req, err := http.NewRequestWithContext( 100 | ctx, 101 | http.MethodPut, 102 | strings.Join([]string{c.baseURL, owner, repoName, configHash, commit + ".json"}, "/"), 103 | &buf, 104 | ) 105 | if err != nil { 106 | return fmt.Errorf("building request: %w", err) 107 | } 108 | 109 | req.SetBasicAuth(c.user, c.password) 110 | 111 | resp, err := http.DefaultClient.Do(req) 112 | if err != nil { 113 | return fmt.Errorf("putting %q: %w", req.URL.String(), err) 114 | } 115 | 116 | defer resp.Body.Close() 117 | 118 | if resp.StatusCode < http.StatusOK && resp.StatusCode >= http.StatusMultipleChoices { 119 | return fmt.Errorf("putting %q: response %d: %w", req.URL.String(), resp.StatusCode, ErrUnexpected) 120 | } 121 | 122 | return nil 123 | } 124 | -------------------------------------------------------------------------------- /internal/providers/cache/file.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "fmt" 8 | "io/fs" 9 | "os" 10 | "path" 11 | 12 | "github.com/easyp-tech/server/internal/providers/content" 13 | ) 14 | 15 | type Local struct { 16 | Dir string 17 | } 18 | 19 | func (c Local) Get(_ context.Context, owner, repoName, commit, configHash string) ([]content.File, error) { 20 | if c.Dir == "" { 21 | return nil, nil 22 | } 23 | 24 | fullName := path.Join(c.Dir, owner, repoName, configHash, commit+".json") 25 | 26 | data, err := os.ReadFile(fullName) 27 | if err != nil { 28 | if errors.Is(err, fs.ErrNotExist) { 29 | return nil, nil 30 | } 31 | 32 | return nil, fmt.Errorf("reading %q: %w", fullName, err) 33 | } 34 | 35 | var out []content.File 36 | 37 | if err = json.Unmarshal(data, &out); err != nil { //nolint:musttag 38 | return nil, fmt.Errorf("decoding %q: %w", fullName, err) 39 | } 40 | 41 | return out, nil 42 | } 43 | 44 | func (c Local) Put(_ context.Context, owner, repoName, commit, configHash string, in []content.File) error { 45 | if c.Dir == "" { 46 | return nil 47 | } 48 | 49 | fullDir := path.Join(c.Dir, owner, repoName, configHash) 50 | 51 | err := os.MkdirAll(fullDir, 0o750) //nolint:gomnd 52 | if err != nil { 53 | return fmt.Errorf("creating dir %q: %w", fullDir, err) 54 | } 55 | 56 | var ( 57 | fileName = path.Join(fullDir, commit+".json") 58 | tmpName = fileName + ".tmp" 59 | ) 60 | 61 | file, err := os.Create(tmpName) 62 | if err != nil { 63 | return fmt.Errorf("creating %q: %w", tmpName, err) 64 | } 65 | 66 | defer file.Close() 67 | 68 | encoder := json.NewEncoder(file) 69 | encoder.SetIndent("", " ") 70 | 71 | if err = encoder.Encode(in); err != nil { //nolint:musttag 72 | return fmt.Errorf("writing %q: %w", tmpName, err) 73 | } 74 | 75 | if err = os.Rename(tmpName, fileName); err != nil { 76 | return fmt.Errorf("renaming %q to %q: %w", tmpName, fileName, err) 77 | } 78 | 79 | return nil 80 | } 81 | -------------------------------------------------------------------------------- /internal/providers/cache/noop.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/easyp-tech/server/internal/providers/content" 7 | ) 8 | 9 | type Noop struct{} 10 | 11 | func (c Noop) Get(_ context.Context, _, _, _, _ string) ([]content.File, error) { 12 | return nil, nil 13 | } 14 | 15 | func (c Noop) Put(_ context.Context, _, _, _, _ string, _ []content.File) error { 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /internal/providers/content/repo.go: -------------------------------------------------------------------------------- 1 | package content 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/easyp-tech/server/internal/shake256" 7 | ) 8 | 9 | type Meta struct { 10 | Commit string 11 | DefaultBranch string 12 | CreatedAt time.Time 13 | UpdatedAt time.Time 14 | } 15 | 16 | type File struct { 17 | Path string 18 | Data []byte 19 | Hash shake256.Hash 20 | } 21 | -------------------------------------------------------------------------------- /internal/providers/filter/filter.go: -------------------------------------------------------------------------------- 1 | package filter 2 | 3 | import ( 4 | "fmt" 5 | "hash/crc32" 6 | "strings" 7 | 8 | "golang.org/x/exp/slices" 9 | ) 10 | 11 | const ProtoSuffix = ".proto" 12 | 13 | type Repo struct { 14 | Owner string 15 | Name string 16 | Prefixes []string 17 | Paths []string 18 | } 19 | 20 | func FindRepo(owner, repoName string, repos []Repo) Repo { 21 | i := slices.IndexFunc(repos, func(repo Repo) bool { return repo.Owner == owner && repo.Name == repoName }) 22 | if i < 0 { 23 | return Repo{} //nolint:exhaustruct 24 | } 25 | 26 | return repos[i] 27 | } 28 | 29 | func (r Repo) Hash() string { 30 | return fmt.Sprintf("%X", crc32.ChecksumIEEE([]byte(fmt.Sprintf("%+v", r)))) 31 | } 32 | 33 | func (r Repo) Check(fileName string) (string, bool) { 34 | fileName = checkPrefix(fileName, r.Prefixes) 35 | if fileName == "" { 36 | return "", false 37 | } 38 | 39 | if !checkPath(fileName, r.Paths) { 40 | return "", false 41 | } 42 | 43 | if !strings.HasSuffix(fileName, ProtoSuffix) { 44 | return "", false 45 | } 46 | 47 | return fileName, true 48 | } 49 | 50 | func checkPrefix(fileName string, prefixes []string) string { 51 | if len(prefixes) == 0 { 52 | return fileName 53 | } 54 | 55 | for _, prefix := range prefixes { 56 | if strings.HasPrefix(fileName, prefix) { 57 | return strings.TrimPrefix(fileName, prefix) 58 | } 59 | } 60 | 61 | return "" 62 | } 63 | 64 | func checkPath(name string, paths []string) bool { 65 | if len(paths) == 0 { 66 | return true 67 | } 68 | 69 | for _, path := range paths { 70 | if strings.HasPrefix(name, path) { 71 | return true 72 | } 73 | } 74 | 75 | return false 76 | } 77 | -------------------------------------------------------------------------------- /internal/providers/github/client.go: -------------------------------------------------------------------------------- 1 | package github 2 | 3 | import ( 4 | "context" 5 | "io" 6 | 7 | "github.com/google/go-github/v59/github" 8 | "golang.org/x/exp/slog" 9 | ) 10 | 11 | const ( 12 | ProtoSuffix = ".proto" 13 | MaxRedirects = 1024 14 | ) 15 | 16 | //nolint:lll 17 | type Repositories interface { 18 | GetCommit(ctx context.Context, owner, repo, sha string, opts *github.ListOptions) (*github.RepositoryCommit, *github.Response, error) 19 | Get(ctx context.Context, owner, repo string) (*github.Repository, *github.Response, error) 20 | GetBranch(ctx context.Context, owner, repo, branch string, maxRedirects int) (*github.Branch, *github.Response, error) 21 | DownloadContents(ctx context.Context, owner, repo, filepath string, opts *github.RepositoryContentGetOptions) (io.ReadCloser, *github.Response, error) 22 | } 23 | 24 | //nolint:lll 25 | type Git interface { 26 | GetTree(ctx context.Context, owner string, repo string, sha string, recursive bool) (*github.Tree, *github.Response, error) 27 | } 28 | 29 | type client struct { 30 | log *slog.Logger 31 | repos Repositories 32 | git Git 33 | } 34 | 35 | func connect(log *slog.Logger, token string) client { 36 | c := github.NewClient(nil) 37 | 38 | if token != "" { 39 | c = c.WithAuthToken(token) 40 | } 41 | 42 | return client{log: log, repos: c.Repositories, git: c.Git} 43 | } 44 | -------------------------------------------------------------------------------- /internal/providers/github/getfiles.go: -------------------------------------------------------------------------------- 1 | package github 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "io" 7 | "strings" 8 | 9 | "github.com/google/go-github/v59/github" 10 | "golang.org/x/exp/slices" 11 | 12 | "github.com/easyp-tech/server/internal/providers/content" 13 | "github.com/easyp-tech/server/internal/providers/filter" 14 | "github.com/easyp-tech/server/internal/shake256" 15 | ) 16 | 17 | func (c client) GetFiles( 18 | ctx context.Context, 19 | owner string, 20 | repoName string, 21 | commit string, 22 | repo filter.Repo, 23 | ) ([]content.File, error) { 24 | tree, _, err := c.git.GetTree(ctx, owner, repoName, commit, true) 25 | if err != nil { 26 | return nil, fmt.Errorf("listing %q/%q:%q: %w", owner, repoName, commit, err) 27 | } 28 | 29 | files, err := c.getFiles(ctx, owner, repoName, commit, filterEntries(tree.Entries, repo)) 30 | if err != nil { 31 | return files, fmt.Errorf("downloading %q/%q:%q: %w", owner, repoName, commit, err) 32 | } 33 | 34 | return files, nil 35 | } 36 | 37 | type fileFiltered struct { 38 | orig string 39 | name string 40 | } 41 | 42 | func filterEntries(entries []*github.TreeEntry, repo filter.Repo) []fileFiltered { 43 | out := make([]fileFiltered, 0, len(entries)) 44 | 45 | for _, entry := range entries { 46 | if name, ok := repo.Check(entry.GetPath()); ok { 47 | out = append(out, fileFiltered{orig: entry.GetPath(), name: name}) 48 | } 49 | } 50 | 51 | slices.SortFunc(out, func(a, b fileFiltered) int { return strings.Compare(a.name, b.name) }) 52 | 53 | return out 54 | } 55 | 56 | func (c client) getFiles( 57 | ctx context.Context, 58 | owner string, 59 | repoName string, 60 | commit string, 61 | files []fileFiltered, 62 | ) ([]content.File, error) { 63 | out := make([]content.File, 0, len(files)) 64 | 65 | for _, file := range files { 66 | data, err := c.getFile(ctx, owner, repoName, commit, file.orig) 67 | if err != nil { 68 | return nil, fmt.Errorf("downloading %q: %w", file, err) 69 | } 70 | 71 | hash, err := shake256.SHA3Shake256(data) 72 | if err != nil { 73 | return nil, fmt.Errorf("hashing %q: %w", file, err) 74 | } 75 | 76 | out = append(out, content.File{Path: file.name, Data: data, Hash: hash}) 77 | } 78 | 79 | return out, nil 80 | } 81 | 82 | func (c client) getFile( 83 | ctx context.Context, 84 | owner string, 85 | repoName string, 86 | commit string, 87 | path string, 88 | ) ([]byte, error) { 89 | r, _, err := c.repos.DownloadContents( 90 | ctx, 91 | owner, 92 | repoName, 93 | path, 94 | &github.RepositoryContentGetOptions{Ref: commit}, 95 | ) 96 | if err != nil { 97 | return nil, fmt.Errorf("requesting: %w", err) 98 | } 99 | 100 | defer r.Close() 101 | 102 | data, err := io.ReadAll(r) 103 | if err != nil { 104 | return data, fmt.Errorf("downloading: %w", err) 105 | } 106 | 107 | return data, nil 108 | } 109 | -------------------------------------------------------------------------------- /internal/providers/github/getrepo.go: -------------------------------------------------------------------------------- 1 | package github 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "fmt" 7 | "time" 8 | 9 | "github.com/easyp-tech/server/internal/providers/content" 10 | ) 11 | 12 | func (c client) GetMeta(ctx context.Context, owner, repoName, commit string) (content.Meta, error) { 13 | meta, err := c.getRepo(ctx, owner, repoName) 14 | if err != nil { 15 | return meta, fmt.Errorf("investigating %q/%q: %w", owner, repoName, err) 16 | } 17 | 18 | if commit != "" && commit != "main" { 19 | meta.Commit = commit 20 | } 21 | 22 | return meta, nil 23 | } 24 | 25 | var ErrEmpty = errors.New("empty") 26 | 27 | func (c client) getRepo(ctx context.Context, owner, repoName string) (content.Meta, error) { 28 | var out content.Meta 29 | 30 | repo, _, err := c.repos.Get(ctx, owner, repoName) 31 | if err != nil { 32 | return out, fmt.Errorf("resolving default branch: %w", err) 33 | } 34 | 35 | c.log.Debug( 36 | "found repo", 37 | "default branch", 38 | repo.GetDefaultBranch(), 39 | "created", repo.CreatedAt.GetTime(), 40 | "updated", repo.UpdatedAt.GetTime(), 41 | ) 42 | 43 | out.CreatedAt = safeTime(repo.CreatedAt.GetTime()) 44 | out.UpdatedAt = safeTime(repo.UpdatedAt.GetTime()) 45 | 46 | out.DefaultBranch = repo.GetDefaultBranch() 47 | if out.DefaultBranch == "" { 48 | return out, fmt.Errorf("error getting default branch: %w", ErrEmpty) 49 | } 50 | 51 | branch, _, err := c.repos.GetBranch(ctx, owner, repoName, out.DefaultBranch, MaxRedirects) 52 | if err != nil { 53 | return out, fmt.Errorf("investigating branch %q: %w", out.DefaultBranch, err) 54 | } 55 | 56 | c.log.Debug("found branch", "SHA", branch.GetCommit().GetSHA()) 57 | 58 | out.Commit = branch.GetCommit().GetSHA() 59 | 60 | return out, nil 61 | } 62 | 63 | func safeTime(v *time.Time) time.Time { 64 | if v == nil { 65 | return time.Time{} 66 | } 67 | 68 | return *v 69 | } 70 | -------------------------------------------------------------------------------- /internal/providers/github/repos.go: -------------------------------------------------------------------------------- 1 | package github 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "hash/crc32" 7 | 8 | "golang.org/x/exp/slices" 9 | "golang.org/x/exp/slog" 10 | 11 | "github.com/easyp-tech/server/internal/providers/content" 12 | "github.com/easyp-tech/server/internal/providers/filter" 13 | "github.com/easyp-tech/server/internal/providers/source" 14 | ) 15 | 16 | type Repo struct { 17 | Token string 18 | filter.Repo 19 | } 20 | 21 | type multiRepo struct { 22 | log *slog.Logger 23 | repos []Repo 24 | } 25 | 26 | func (m multiRepo) Find(owner, name string) source.Source { //nolint:ireturn 27 | s, ok := m.find(owner, name) 28 | if !ok { 29 | return nil 30 | } 31 | 32 | return s 33 | } 34 | 35 | func (m multiRepo) find(owner, name string) (sourceRepo, bool) { 36 | i := slices.IndexFunc(m.repos, func(r Repo) bool { 37 | return r.Repo.Owner == owner && r.Repo.Name == name 38 | }) 39 | if i < 0 { 40 | return sourceRepo{}, false //nolint:exhaustruct 41 | } 42 | 43 | return sourceRepo{log: m.log, repo: m.repos[i]}, true 44 | } 45 | 46 | func NewMultiRepo(log *slog.Logger, repos []Repo) multiRepo { 47 | return multiRepo{ 48 | log: log, 49 | repos: repos, 50 | } 51 | } 52 | 53 | var _ source.Source = sourceRepo{} //nolint:exhaustruct 54 | 55 | type sourceRepo struct { 56 | log *slog.Logger 57 | repo Repo 58 | } 59 | 60 | func (r sourceRepo) ConfigHash() string { 61 | return fmt.Sprintf("%X", crc32.ChecksumIEEE([]byte(fmt.Sprintf("%+v", r.repo.Repo)))) 62 | } 63 | 64 | func (r sourceRepo) Name() string { return "github proxy" } 65 | 66 | func (r sourceRepo) GetMeta(ctx context.Context, commit string) (content.Meta, error) { 67 | return connect(r.log, r.repo.Token).GetMeta(ctx, r.repo.Owner, r.repo.Name, commit) 68 | } 69 | 70 | func (r sourceRepo) GetFiles(ctx context.Context, commit string) ([]content.File, error) { 71 | return connect(r.log, r.repo.Token).GetFiles(ctx, r.repo.Owner, r.repo.Name, commit, r.repo.Repo) 72 | } 73 | -------------------------------------------------------------------------------- /internal/providers/localgit/localgit.go: -------------------------------------------------------------------------------- 1 | package localgit 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "hash/crc32" 7 | "io/fs" 8 | "os" 9 | "path" 10 | "path/filepath" 11 | "strings" 12 | 13 | "github.com/go-git/go-git/v5" 14 | "github.com/go-git/go-git/v5/plumbing" 15 | "golang.org/x/exp/slices" 16 | 17 | "github.com/easyp-tech/server/internal/providers/content" 18 | "github.com/easyp-tech/server/internal/providers/filter" 19 | "github.com/easyp-tech/server/internal/providers/localgit/namedlocks" 20 | "github.com/easyp-tech/server/internal/providers/source" 21 | "github.com/easyp-tech/server/internal/shake256" 22 | ) 23 | 24 | const ( 25 | minNumberOfFiles = 1024 26 | ) 27 | 28 | type namedLocks interface { 29 | Lock(name string) *namedlocks.Unlocker 30 | } 31 | 32 | type store struct { 33 | rootDir string 34 | repos []filter.Repo 35 | l namedLocks 36 | } 37 | 38 | //nolint:ireturn 39 | func (s *store) Find(owner, repoName string) source.Source { 40 | if s.rootDir == "" { 41 | return nil 42 | } 43 | 44 | dirName := path.Join(s.rootDir, owner, repoName) 45 | 46 | fileStat, err := os.Stat(filepath.Join(s.rootDir, owner, repoName)) 47 | if err != nil || !fileStat.IsDir() { 48 | return nil 49 | } 50 | 51 | repo := filter.FindRepo(owner, repoName, s.repos) 52 | 53 | if repo.Owner != owner { 54 | return nil 55 | } 56 | 57 | return sourceRepo{ 58 | dirName: dirName, 59 | repo: repo, 60 | l: s.l, 61 | } 62 | } 63 | 64 | func (s *store) Check(owner, repoName string) bool { 65 | if s.rootDir == "" { 66 | return false 67 | } 68 | 69 | fileStat, err := os.Stat(filepath.Join(s.rootDir, owner, repoName)) 70 | if err != nil { 71 | return false 72 | } 73 | 74 | return fileStat.IsDir() 75 | } 76 | 77 | // New returns new instance of store. 78 | func New( 79 | rootDir string, 80 | repos []filter.Repo, 81 | l namedLocks, 82 | ) *store { 83 | return &store{ 84 | rootDir: rootDir, 85 | repos: repos, 86 | l: l, 87 | } 88 | } 89 | 90 | var _ source.Source = sourceRepo{} //nolint:exhaustruct 91 | 92 | type sourceRepo struct { 93 | dirName string 94 | repo filter.Repo 95 | l namedLocks 96 | } 97 | 98 | func (r sourceRepo) ConfigHash() string { 99 | return fmt.Sprintf("%X", crc32.ChecksumIEEE([]byte(fmt.Sprintf("%+v", r.repo)))) 100 | } 101 | 102 | func (r sourceRepo) Name() string { return "local git" } 103 | 104 | func (r sourceRepo) GetMeta(_ context.Context, commit string) (content.Meta, error) { 105 | l := r.l.Lock(r.dirName) 106 | defer l.Unlock() 107 | 108 | defaultBranch, commit, err := getRepoSwitchedCommit(r.dirName, commit) 109 | if err != nil { 110 | return content.Meta{DefaultBranch: defaultBranch, Commit: commit}, //nolint:exhaustruct 111 | fmt.Errorf("investigating %q/%q:%q: %w", r.repo.Owner, r.repo.Name, commit, err) 112 | } 113 | 114 | return content.Meta{DefaultBranch: defaultBranch, Commit: commit}, nil //nolint:exhaustruct 115 | } 116 | 117 | func (r sourceRepo) GetFiles(_ context.Context, commit string) ([]content.File, error) { 118 | l := r.l.Lock(r.dirName) 119 | defer l.Unlock() 120 | 121 | if _, _, err := getRepoSwitchedCommit(r.dirName, commit); err != nil { 122 | return nil, fmt.Errorf("investigating %q/%q:%q: %w", r.repo.Owner, r.repo.Name, commit, err) 123 | } 124 | 125 | files, err := enumerateProto(r.dirName, r.repo) 126 | if err != nil { 127 | return files, fmt.Errorf("enumerating %q/%q:%q: %w", r.repo.Owner, r.repo.Name, commit, err) 128 | } 129 | 130 | return files, nil 131 | } 132 | 133 | func getRepoSwitchedCommit(dirName, commit string) (string, string, error) { 134 | r, err := git.PlainOpen(dirName) 135 | if err != nil { 136 | return "", "", fmt.Errorf("opening git: %w", err) 137 | } 138 | 139 | defaultBranch, err := r.Reference(plumbing.NewRemoteHEADReferenceName("origin"), true) 140 | if err != nil { 141 | return "", "", fmt.Errorf("resolving default branch: %w", err) 142 | } 143 | 144 | if commit == "" || commit == "main" { 145 | commit = defaultBranch.Hash().String() 146 | } 147 | 148 | w, err := r.Worktree() 149 | if err != nil { 150 | return "", "", fmt.Errorf("getting work tree: %w", err) 151 | } 152 | 153 | if err = w.Checkout(&git.CheckoutOptions{Hash: plumbing.NewHash(commit)}); err != nil { //nolint:exhaustruct 154 | return "", "", fmt.Errorf("checking out %q: %w", commit, err) 155 | } 156 | 157 | return defaultBranch.Name().Short(), commit, nil 158 | } 159 | 160 | func enumerateProto(dirName string, repo filter.Repo) ([]content.File, error) { 161 | res := make([]content.File, 0, minNumberOfFiles) 162 | 163 | fsys := os.DirFS(dirName) 164 | 165 | err := fs.WalkDir( 166 | fsys, 167 | ".", 168 | func(path string, info fs.DirEntry, err error) error { 169 | if err != nil || info.IsDir() { 170 | return nil //nolint:nilerr 171 | } 172 | 173 | newPath, ok := repo.Check(path) 174 | if !ok { 175 | return nil 176 | } 177 | 178 | data, err := fs.ReadFile(fsys, path) 179 | if err != nil { 180 | return fmt.Errorf("reading %q: %w", path, err) 181 | } 182 | 183 | hash, err := shake256.SHA3Shake256(data) 184 | if err != nil { 185 | return fmt.Errorf("hashing %q: %w", path, err) 186 | } 187 | 188 | res = append(res, content.File{Path: newPath, Data: data, Hash: hash}) 189 | 190 | return nil 191 | }, 192 | ) 193 | if err != nil { 194 | return nil, fmt.Errorf("walking %q: %w", dirName, err) 195 | } 196 | 197 | slices.SortFunc(res, func(a, b content.File) int { return strings.Compare(a.Path, b.Path) }) 198 | 199 | return res, nil 200 | } 201 | -------------------------------------------------------------------------------- /internal/providers/localgit/namedlocks/lock.go: -------------------------------------------------------------------------------- 1 | package namedlocks 2 | 3 | import ( 4 | "sync" 5 | ) 6 | 7 | type Unlocker struct { 8 | m *sync.Mutex 9 | } 10 | 11 | func (l *Unlocker) Unlock() { 12 | l.m.Unlock() 13 | } 14 | 15 | type namedLocks struct { 16 | m sync.Mutex 17 | byName map[string]*sync.Mutex 18 | } 19 | 20 | func (l *namedLocks) Lock(name string) *Unlocker { 21 | m := l.lock(name) 22 | 23 | m.Lock() 24 | 25 | return &Unlocker{m: m} 26 | } 27 | 28 | func (l *namedLocks) lock(name string) *sync.Mutex { 29 | l.m.Lock() 30 | defer l.m.Unlock() 31 | 32 | if m, ok := l.byName[name]; ok { 33 | return m 34 | } 35 | 36 | m := &sync.Mutex{} 37 | l.byName[name] = m 38 | 39 | return m 40 | } 41 | 42 | func New(size int) *namedLocks { 43 | return &namedLocks{ //nolint:exhaustruct 44 | byName: make(map[string]*sync.Mutex, size), 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /internal/providers/multisource/repo.go: -------------------------------------------------------------------------------- 1 | package multisource 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "fmt" 7 | 8 | "golang.org/x/exp/slog" 9 | 10 | "github.com/easyp-tech/server/internal/providers/content" 11 | "github.com/easyp-tech/server/internal/providers/source" 12 | ) 13 | 14 | type Source interface { 15 | Find(owner, repoName string) source.Source 16 | } 17 | 18 | type Cache interface { 19 | Get(ctx context.Context, owner, repoName, commit, configHash string) ([]content.File, error) 20 | Put(ctx context.Context, owner, repoName, commit, configHash string, in []content.File) error 21 | } 22 | 23 | type Repo struct { 24 | log *slog.Logger 25 | cache Cache 26 | sources []Source 27 | } 28 | 29 | func New(log *slog.Logger, cache Cache, sources ...Source) Repo { 30 | return Repo{ 31 | log: log, 32 | cache: cache, 33 | sources: sources, 34 | } 35 | } 36 | 37 | var ErrNotFound = errors.New("not found") 38 | 39 | func (r Repo) GetMeta(ctx context.Context, owner, repoName, commit string) (content.Meta, error) { 40 | r.log.Debug("looking for meta", "owner", owner, "repo", repoName) 41 | 42 | s := r.findSource(owner, repoName) 43 | if s == nil { 44 | return content.Meta{}, ErrNotFound 45 | } 46 | 47 | r.log.Debug("module found", "source", s.Name(), "config", s.ConfigHash(), "owner", owner, "repo", repoName) 48 | 49 | return s.GetMeta(ctx, commit) //nolint:wrapcheck 50 | } 51 | 52 | func (r Repo) GetFiles(ctx context.Context, owner, repoName, commit string) ([]content.File, error) { 53 | s := r.findSource(owner, repoName) 54 | if s == nil { 55 | return nil, ErrNotFound 56 | } 57 | 58 | r.log.Debug("module found", "source", s.Name(), "config", s.ConfigHash(), "owner", owner, "repo", repoName) 59 | 60 | if files := r.cacheGet(ctx, owner, repoName, commit, s.ConfigHash()); files != nil { 61 | return files, nil 62 | } 63 | 64 | files, err := s.GetFiles(ctx, commit) 65 | if err != nil { 66 | return files, fmt.Errorf("getting files: %w", err) 67 | } 68 | 69 | r.cachePut(ctx, owner, repoName, commit, s.ConfigHash(), files) 70 | 71 | return files, nil 72 | } 73 | 74 | func (r Repo) cacheGet(ctx context.Context, owner, repoName, commit, configHash string) []content.File { 75 | files, err := r.cache.Get(ctx, owner, repoName, commit, configHash) 76 | if err != nil { 77 | r.log.Error("from cache", "owner", owner, "repo", repoName, "commit", commit, "error", err) 78 | 79 | return nil 80 | } 81 | 82 | r.log.Debug("from cache", "owner", owner, "repo", repoName, "commit", commit, "files", len(files)) 83 | 84 | return files 85 | } 86 | 87 | func (r Repo) cachePut(ctx context.Context, owner, repoName, commit, configHash string, files []content.File) { 88 | if err := r.cache.Put(ctx, owner, repoName, commit, configHash, files); err != nil { 89 | r.log.Error( 90 | "to cache", 91 | "owner", owner, 92 | "repo", repoName, 93 | "commit", commit, 94 | "files", len(files), 95 | "error", err, 96 | ) 97 | 98 | return 99 | } 100 | 101 | r.log.Debug("to cache", "owner", owner, "repo", repoName, "commit", commit, "files", len(files)) 102 | } 103 | 104 | func (r Repo) findSource(owner, repoName string) source.Source { //nolint:ireturn 105 | for _, s := range r.sources { 106 | if repo := s.Find(owner, repoName); repo != nil { 107 | return repo 108 | } 109 | } 110 | 111 | return nil 112 | } 113 | -------------------------------------------------------------------------------- /internal/providers/source/source.go: -------------------------------------------------------------------------------- 1 | package source 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/easyp-tech/server/internal/providers/content" 7 | ) 8 | 9 | type Source interface { 10 | GetMeta(ctx context.Context, commit string) (content.Meta, error) 11 | GetFiles(ctx context.Context, commit string) ([]content.File, error) 12 | ConfigHash() string 13 | Name() string 14 | } 15 | -------------------------------------------------------------------------------- /internal/shake256/hash.go: -------------------------------------------------------------------------------- 1 | package shake256 2 | 3 | import ( 4 | "encoding/hex" 5 | "fmt" 6 | 7 | "golang.org/x/crypto/sha3" 8 | ) 9 | 10 | type Hash [64]byte 11 | 12 | func (h *Hash) String() string { return hex.EncodeToString(h[:]) } 13 | func (h *Hash) MarshalText() ([]byte, error) { return []byte(hex.EncodeToString(h[:])), nil } 14 | 15 | func (h *Hash) UnmarshalText(text []byte) error { 16 | if _, err := hex.Decode(h[:], text); err != nil { 17 | return fmt.Errorf("unmarshaling: %w", err) 18 | } 19 | 20 | return nil 21 | } 22 | 23 | func SHA3Shake256(data []byte) (Hash, error) { 24 | var hash Hash 25 | 26 | d := sha3.NewShake256() 27 | 28 | if _, err := d.Write(data); err != nil { 29 | return hash, fmt.Errorf("calculating hash: %w", err) 30 | } 31 | 32 | if _, err := d.Read(hash[:]); err != nil { 33 | return hash, fmt.Errorf("extracting hash: %w", err) 34 | } 35 | 36 | return hash, nil 37 | } 38 | -------------------------------------------------------------------------------- /local.config.yml: -------------------------------------------------------------------------------- 1 | listen: 127.0.0.1:8080 2 | domain: some-proper-url:8080 3 | #cache: ./.storage/.cache 4 | tls: 5 | cert: cert.pem 6 | key: key.pem 7 | #ca: ca.pem 8 | proxy: 9 | github: 10 | token: some_github_token 11 | repo: 12 | - token: some_github_token 13 | repo: 14 | owner: googleapis 15 | name: googleapis 16 | path: 17 | - google/type/ 18 | - google/api/ 19 | - google/rpc/ 20 | - token: some_github_token 21 | repo: 22 | owner: bufbuild 23 | name: protovalidate 24 | prefix: 25 | - proto/protovalidate/ 26 | - token: some_github_token 27 | repo: 28 | owner: grpc-ecosystem 29 | name: grpc-gateway 30 | path: 31 | - protoc-gen-openapiv2/ 32 | local: 33 | #storage: ./.storage/gitlocal 34 | repo: 35 | - owner: googleapis 36 | name: googleapis 37 | path: 38 | - google/type/ 39 | - google/api/ 40 | - google/rpc/ 41 | - owner: bufbuild 42 | name: protovalidate 43 | prefix: 44 | - proto/protovalidate/ 45 | - owner: grpc-ecosystem 46 | name: grpc-gateway 47 | path: 48 | - protoc-gen-openapiv2/ 49 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x -e -o pipefail 3 | 4 | rm -rf bin/ 5 | mkdir bin/ 6 | 7 | # Build binaries for linux-based Docker container. 8 | export CGO_ENABLED=0 9 | export GOOS=linux 10 | export GOARCH=amd64 11 | 12 | for d in ./cmd/*; do 13 | if test -f ${d}/docker/Dockerfile; then 14 | go build -o bin/ ${d} 15 | fi 16 | done 17 | -------------------------------------------------------------------------------- /scripts/clone_repos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -eq 0 ]; then 4 | echo "Error: urls must be set." 5 | exit 1 6 | fi 7 | 8 | BASE_DIR="easyp_volume" 9 | mkdir -p "$BASE_DIR" 10 | 11 | clone_repo() { 12 | REPO_URL=$1 13 | IFS='/' 14 | read -ra ADDR <<< "$REPO_URL" 15 | USER=${ADDR[3]} 16 | REPO=${ADDR[4]%.git} 17 | 18 | DIR_PATH="$BASE_DIR/$USER/$REPO" 19 | 20 | git clone "$REPO_URL" "$DIR_PATH" 21 | } 22 | 23 | for REPO_URL in "$@"; do 24 | clone_repo "$REPO_URL" 25 | done 26 | 27 | echo "Cloning is complete." 28 | -------------------------------------------------------------------------------- /scripts/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x -e -o pipefail 3 | 4 | rm -rf bin/ 5 | mkdir bin/ 6 | 7 | # Build binaries for linux-based Docker container. 8 | export CGO_ENABLED=0 9 | export GOOS=linux 10 | export GOARCH=amd64 11 | 12 | go build -o bin/easyp-server ./cmd/easyp 13 | 14 | dockerTag="easyp/server:v0.1.0" 15 | docker build -f Dockerfile --tag ${dockerTag} . 16 | docker push ${dockerTag} -------------------------------------------------------------------------------- /scripts/push_stage_to_docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x -e -o pipefail 3 | 4 | rm -rf bin/ 5 | mkdir bin/ 6 | 7 | # Build binaries for linux-based Docker container. 8 | export CGO_ENABLED=0 9 | export GOOS=linux 10 | export GOARCH=amd64 11 | 12 | for d in ./cmd/*; do 13 | if test -f ${d}/docker/Dockerfile; then 14 | go build -o bin/ ${d} 15 | dockerTag="cr.yandex/crplga9vcvsvk4uv6541/${d#"./cmd/"}:stage" 16 | docker build -f ${d}/docker/Dockerfile --tag ${dockerTag} . 17 | echo ${dockerTag} 18 | docker push ${dockerTag} 19 | fi 20 | done 21 | -------------------------------------------------------------------------------- /testdata/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIID3TCCAsWgAwIBAgIUV2uzjuof2D2iTMDcoKkRfq6q14QwDQYJKoZIhvcNAQEL 3 | BQAwfjELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM 4 | DU1vdW50YWluIFZpZXcxGjAYBgNVBAoMEVlvdXIgT3JnYW5pemF0aW9uMRIwEAYD 5 | VQQLDAlZb3VyIFVuaXQxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0yNDAyMTkxMDM0 6 | MjlaFw0zNDAyMTYxMDM0MjlaMH4xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxp 7 | Zm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MRowGAYDVQQKDBFZb3VyIE9y 8 | Z2FuaXphdGlvbjESMBAGA1UECwwJWW91ciBVbml0MRIwEAYDVQQDDAlsb2NhbGhv 9 | c3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCpIYbKv+PxyicvB7VJ 10 | u34MjtWxNQO40M54aAmiwRk1m9LMTsIZP0K95Sj/EAHfJ4pfLOqLVtD5i541Cggn 11 | RxjGq0Wbe4huWDDb1M2S6g4aRfDPvQEI0WqK5x1aFw6z1b2pEg5Hf18TKaH8hEUT 12 | lrpSy/zFe0bpPodkvZlLIluDNMU/xSOBLkYrAu1GM17U468s+9DbvNqUZjht/WF6 13 | 4l87DkBoRBO0QEGBv7FKrsSr1DrWZXa7pCyms7/SouFvYswHfz/IPO4LEBoAuSf1 14 | yhdLjlM5P5o5w+jB0ScJg0kwQzxUG++6qaxXNYv2G+HDyghT+Vs8tu9EMAr5dsUj 15 | KpC3AgMBAAGjUzBRMB0GA1UdDgQWBBRldKSPBUU9bROq3AxP3y2/8/UiAjAfBgNV 16 | HSMEGDAWgBRldKSPBUU9bROq3AxP3y2/8/UiAjAPBgNVHRMBAf8EBTADAQH/MA0G 17 | CSqGSIb3DQEBCwUAA4IBAQCaKGGtEBFym0goCwjU+o1LwoYyuddp4LVfggB7dv7o 18 | f7zfz3LT2vKSfR954ngPJTyy2AYS6vbUJhSJAzjHwmJEKwuIqEX1P9ULSAjMz+n2 19 | u4oZTlXR5KhkUqbygWrnbY+1Yyge0C5R9GfR8k1iz3/3hvyLiB0MVK6BXZ+7/Qzz 20 | uwc3ETlIelanIik7kiTCBJTyIxm7NRVLarhnL8WI8k1dBQQOFpZRgYKKbBJnfObm 21 | 6ev0AF2MzDbqUU6Zx0Bz2MBadX5dXgCHFs2bkONOsOhnBF4RLtxSlgnGxhSdYr93 22 | YyMgivmUwhg+pN/VSjwRlKZ/OrAWSyyl7s8odttRqp6Q 23 | -----END CERTIFICATE----- 24 | -------------------------------------------------------------------------------- /testdata/key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCpIYbKv+Pxyicv 3 | B7VJu34MjtWxNQO40M54aAmiwRk1m9LMTsIZP0K95Sj/EAHfJ4pfLOqLVtD5i541 4 | CggnRxjGq0Wbe4huWDDb1M2S6g4aRfDPvQEI0WqK5x1aFw6z1b2pEg5Hf18TKaH8 5 | hEUTlrpSy/zFe0bpPodkvZlLIluDNMU/xSOBLkYrAu1GM17U468s+9DbvNqUZjht 6 | /WF64l87DkBoRBO0QEGBv7FKrsSr1DrWZXa7pCyms7/SouFvYswHfz/IPO4LEBoA 7 | uSf1yhdLjlM5P5o5w+jB0ScJg0kwQzxUG++6qaxXNYv2G+HDyghT+Vs8tu9EMAr5 8 | dsUjKpC3AgMBAAECggEAI9OUxH0KcYzzaOx2lARR6qIVFSEYRT2CBxJuvBmwV+FG 9 | sX2bcxKp9iTFXuZKpzUuhAO1OUfuI3ZWUIDsAjn2vxrHt2xfFZS74M0+sLjAvQME 10 | xFSSlAYcTgkv+AX7WM/Viatn9/A8uQfwJtfz8/bRSDmqtUBsYHsc3hOllbtU7EFY 11 | m8pDgnZtWBak3aZlj/stq4fpIRdAw0hNhvXSSI3oRRyzxDB8eH34hvxVgnxnGw3w 12 | XP/Z4G/4MdjON3xkMyC3w297VtmO2QnCndZHaGw9ynzH89+LZ6Qv5Q/pP/vpcuoq 13 | JkmjJ106q+XdhhNX2/akr81M23Q0OQZy1vnjkirGpQKBgQDccRQzwz241PJ6pBcR 14 | 6RxrnMCTf26Cy0pxYQ1gyiFXbQlabC8UM1GDIonrv3uLEOQIIQ53liENQaKGGVZB 15 | fuy+7qGmAJslSndRdjyrLOkmu4EN3NUaQfgZQkWAPjPWYp2VNYxUwu/T/NXh5InS 16 | vohzDV/1NrD8UvHhP3F/WHIgCwKBgQDEaZ8I03hXl1NJQbCMfy/pLsf71RDRpht1 17 | Vf4Frk6hBGQzduG7BnrKHoq1ZwWAChjADkiWdGAxpSEoKcGw1JcBnXd0LG32eUa4 18 | abgvGbWzuSw7zlUHr7z+MbPdTmHfKawWXMrT+fWcLewXDY/ruERiH3WjtiNP7Jxx 19 | RJQCo8uhhQKBgAIAWNGbfSz3afgpEziLaEGl2627I3K2i8d5vRha3XCgwcv7XXYO 20 | fTf2kU/9ng6GKbvVKP928nffV61l/316vIWDPx51tPLiuTCZJTXco4VBgItyrNCf 21 | NrRsAJuIdQoGPS4EnXCLkIfZLMvvOj0ak7yPq4ZbZ8HystV7sPkaAXc/AoGAGYNi 22 | ziGyEyasAesPhOCMl6yk+5hsq9742CAIdDJ1MkNAxNKfdczcrF6VRAUS2NP27ROt 23 | 6CVLzYcWrIHoEBE9YE9VEfkne4m7Xv8UlsGvMZ5PGaGut+XjFd3c8FVbL0LZgLoi 24 | +rAQcG4iqcfwNv1jnJ9bh52ELsCcfbYbx9ABBoUCgYAdLAF55O63nPw4HlSwIhjN 25 | 3R2NbTBqUT+2Zbuen5nkT2G4x0k0TMYet/wRsPG2IRoYdkkoSKZSol0VtMo6ZOnp 26 | V7jiZ9ej16uvt+JaPRoTG0P+b7XWjAbOQQM8o3xrNXU4wt+gOxx8f/z/DLsgb0kH 27 | sJtwlNTVQSNt6gAdUFsT2A== 28 | -----END PRIVATE KEY----- 29 | --------------------------------------------------------------------------------