├── .dockerignore ├── .drone.yml ├── .gitignore ├── .golangci.json ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── go.mod ├── go.sum ├── main.go └── pkg ├── apis └── services │ └── images │ ├── images.go │ └── v1alpha1 │ ├── images.go │ ├── images.pb.go │ └── images.proto ├── auth └── auth.go ├── cli ├── cli.go └── commands │ ├── agent │ └── agent.go │ ├── build │ └── build.go │ ├── images │ └── images.go │ ├── info │ └── info.go │ ├── install │ └── install.go │ ├── pull │ └── pull.go │ ├── push │ └── push.go │ ├── rmi │ └── rmi.go │ ├── tag │ └── tag.go │ └── uninstall │ └── uninstall.go ├── client ├── action │ ├── action-build.go │ ├── action-images.go │ ├── action-install.go │ ├── action-pull.go │ ├── action-push.go │ ├── action-rmi.go │ ├── action-tag.go │ ├── action-uninstall.go │ └── action.go └── client.go ├── progress ├── progress.go └── tracker.go ├── server ├── action │ ├── agent.go │ ├── agent_linux.go │ └── agent_other.go ├── config.go ├── images-pull.go ├── images-push.go ├── images-tag.go ├── images.go └── server.go └── version └── version.go /.dockerignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /dist/ 3 | /k3c 4 | -------------------------------------------------------------------------------- /.drone.yml: -------------------------------------------------------------------------------- 1 | --- 2 | kind: pipeline 3 | type: docker 4 | name: amd64 5 | 6 | platform: 7 | os: linux 8 | arch: amd64 9 | 10 | steps: 11 | - name: build-binaries 12 | image: rancher/dapper:v0.5.0 13 | environment: 14 | GOLANG: golang:1.16beta1-alpine 15 | commands: 16 | - dapper -f Dockerfile --target dapper make GOOS=linux GOARCH=amd64 DRONE_TAG=${DRONE_TAG} dist 17 | - dapper -f Dockerfile --target dapper make GOOS=linux GOARCH=arm64 DRONE_TAG=${DRONE_TAG} dist 18 | - dapper -f Dockerfile --target dapper make GOOS=darwin GOARCH=amd64 DRONE_TAG=${DRONE_TAG} dist 19 | - dapper -f Dockerfile --target dapper make GOOS=darwin GOARCH=arm64 DRONE_TAG=${DRONE_TAG} dist 20 | - dapper -f Dockerfile --target dapper make GOOS=windows GOARCH=amd64 DRONE_TAG=${DRONE_TAG} dist 21 | volumes: 22 | - name: docker 23 | path: /var/run/docker.sock 24 | 25 | - name: publish-binaries 26 | image: plugins/github-release 27 | settings: 28 | api_key: 29 | from_secret: github_token 30 | checksum: 31 | - sha256 32 | checksum_file: CHECKSUMsum.txt 33 | checksum_flatten: true 34 | files: 35 | - dist/artifacts/* 36 | prerelease: true 37 | when: 38 | event: 39 | - tag 40 | instance: 41 | - drone-publish.rancher.io 42 | ref: 43 | - refs/head/master 44 | - refs/tags/* 45 | 46 | - name: publish-images 47 | image: golang:1.16beta1-alpine 48 | commands: 49 | - apk --no-cache add docker-cli file git make 50 | - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD 51 | - make DRONE_TAG=${DRONE_TAG} publish 52 | environment: 53 | DOCKER_USERNAME: 54 | from_secret: docker_username 55 | DOCKER_PASSWORD: 56 | from_secret: docker_password 57 | when: 58 | event: 59 | - tag 60 | instance: 61 | - drone-publish.rancher.io 62 | ref: 63 | - refs/head/master 64 | - refs/tags/* 65 | 66 | volumes: 67 | - name: docker 68 | host: 69 | path: /var/run/docker.sock 70 | 71 | --- 72 | kind: pipeline 73 | type: docker 74 | name: arm64 75 | 76 | platform: 77 | os: linux 78 | arch: arm64 79 | 80 | steps: 81 | - name: publish-images 82 | image: golang:1.16beta1-alpine 83 | commands: 84 | - apk --no-cache add docker-cli file git make 85 | - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD 86 | - make DRONE_TAG=${DRONE_TAG} publish 87 | environment: 88 | DOCKER_USERNAME: 89 | from_secret: docker_username 90 | DOCKER_PASSWORD: 91 | from_secret: docker_password 92 | when: 93 | event: 94 | - tag 95 | instance: 96 | - drone-publish.rancher.io 97 | ref: 98 | - refs/head/master 99 | - refs/tags/* 100 | 101 | volumes: 102 | - name: docker 103 | host: 104 | path: /var/run/docker.sock 105 | 106 | ... 107 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .dapper 2 | /.idea/ 3 | /dist/ 4 | /bin/ 5 | /k3c 6 | /vendor/ 7 | -------------------------------------------------------------------------------- /.golangci.json: -------------------------------------------------------------------------------- 1 | { 2 | "linters": { 3 | "disable-all": true, 4 | "enable": [ 5 | "govet", 6 | "golint", 7 | "goimports", 8 | "misspell", 9 | "ineffassign", 10 | "gofmt" 11 | ] 12 | }, 13 | "run": { 14 | "skip-files": [ 15 | "/zz_generated_" 16 | ], 17 | "deadline": "5m" 18 | }, 19 | "issues": { 20 | "exclude-rules": [ 21 | { 22 | "path":"cmd", 23 | "text":"don't use underscores in Go names", 24 | "linters":["golint"] 25 | }, 26 | { 27 | "path":"cmd", 28 | "text":"struct field .* should be", 29 | "linters":["golint"] 30 | } 31 | 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG GOLANG=golang:1.15-alpine 2 | FROM ${GOLANG} AS base 3 | RUN apk --no-cache add \ 4 | file \ 5 | gcc \ 6 | git \ 7 | libseccomp-dev \ 8 | libselinux-dev \ 9 | make \ 10 | musl-dev \ 11 | protobuf-dev \ 12 | protoc 13 | RUN GO111MODULE=on go get github.com/gogo/protobuf/protoc-gen-gofast@v1.3.2 14 | COPY . /go/src/k3c 15 | WORKDIR /go/src/k3c 16 | 17 | FROM base AS dapper 18 | RUN apk --no-cache add docker-cli 19 | ENV DAPPER_ENV GOLANG GODEBUG GOARCH GOOS ORG TAG DRONE_TAG DRONE_BUILD_EVENT 20 | ARG DAPPER_HOST_ARCH 21 | ENV GOARCH $DAPPER_HOST_ARCH 22 | ENV DAPPER_SOURCE /go/src/k3c 23 | ENV DAPPER_OUTPUT ./dist ./bin 24 | ENV DAPPER_DOCKER_SOCKET true 25 | ENV DAPPER_TARGET dapper 26 | ENV DAPPER_RUN_ARGS "--privileged --network host -v k3c-pkg:/go/pkg -v k3c-cache:/root/.cache/go-build" 27 | RUN go version 28 | 29 | FROM base AS build 30 | RUN go mod vendor 31 | RUN go generate -x 32 | ARG ORG=rancher 33 | ARG PKG=github.com/rancher/k3c 34 | ARG TAG=0.0.0-dev 35 | RUN make bin/k3c ORG=${ORG} PKG=${PKG} TAG=${TAG} 36 | RUN file bin/k3c 37 | RUN install -s bin/k3c -m 0755 /usr/local/bin 38 | 39 | FROM scratch AS release 40 | COPY --from=build /usr/local/bin/k3c /bin/k3c 41 | ENTRYPOINT ["k3c"] 42 | CMD ["--help"] 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(GOARCH),) 2 | GOARCH := $(shell go env GOARCH) 3 | endif 4 | 5 | ifeq ($(GOOS),) 6 | GOOS := $(shell go env GOOS) 7 | endif 8 | 9 | ifneq ($(DRONE_TAG),) 10 | TAG := $(DRONE_TAG) 11 | endif 12 | 13 | DOCKER_BUILDKIT ?= 1 14 | 15 | ORG ?= rancher 16 | PKG ?= github.com/rancher/k3c 17 | TAG ?= v0.0.0-dev 18 | 19 | ifeq ($(GO_BUILDTAGS),) 20 | GO_BUILDTAGS := static_build,netgo,osusergo 21 | #ifeq ($(GOOS),linux) 22 | #GO_BUILDTAGS := $(GO_BUILDTAGS),seccomp,selinux 23 | #endif 24 | endif 25 | 26 | GO_LDFLAGS ?= -w -extldflags=-static 27 | GO_LDFLAGS += -X $(PKG)/pkg/version.GitCommit=$(shell git rev-parse HEAD) 28 | GO_LDFLAGS += -X $(PKG)/pkg/version.Version=$(TAG) 29 | GO_LDFLAGS += -X $(PKG)/pkg/server.DefaultAgentImage=docker.io/$(ORG)/k3c 30 | 31 | GO ?= go 32 | GOLANG ?= docker.io/library/golang:1.15-alpine 33 | ifeq ($(GOOS),windows) 34 | BINSUFFIX := .exe 35 | endif 36 | BIN ?= bin/k3c 37 | BIN := $(BIN)$(BINSUFFIX) 38 | 39 | .PHONY: build package validate ci publish 40 | build: $(BIN) 41 | package: | dist image-build 42 | validate: 43 | publish: | image-build image-push image-manifest 44 | ci: | build package validate 45 | .PHONY: $(BIN) 46 | $(BIN): 47 | $(GO) build -ldflags "$(GO_LDFLAGS)" -tags "$(GO_BUILDTAGS)" -o $@ . 48 | 49 | .PHONY: dist 50 | dist: 51 | @mkdir -p dist/artifacts 52 | @make GOOS=$(GOOS) GOARCH=$(GOARCH) BIN=dist/artifacts/k3c-$(GOOS)-$(GOARCH)$(BINSUFFIX) -C . 53 | 54 | .PHONY: clean 55 | clean: 56 | rm -rf bin dist 57 | 58 | .PHONY: image-build 59 | image-build: 60 | DOCKER_BUILDKIT=$(DOCKER_BUILDKIT) docker build \ 61 | --build-arg GOLANG=$(GOLANG) \ 62 | --build-arg ORG=$(ORG) \ 63 | --build-arg PKG=$(PKG) \ 64 | --build-arg TAG=$(TAG) \ 65 | --tag $(ORG)/k3c:$(TAG) \ 66 | --tag $(ORG)/k3c:$(TAG)-$(GOARCH) \ 67 | . 68 | 69 | .PHONY: image-push 70 | image-push: 71 | docker push $(ORG)/k3c:$(TAG)-$(GOARCH) 72 | 73 | .PHONY: image-manifest 74 | image-manifest: 75 | DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create --amend \ 76 | $(ORG)/k3c:$(TAG) \ 77 | $(ORG)/k3c:$(TAG)-$(GOARCH) 78 | DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push \ 79 | $(ORG)/k3c:$(TAG) 80 | 81 | ./.dapper: 82 | @echo Downloading dapper 83 | @curl -sL https://releases.rancher.com/dapper/v0.5.0/dapper-$$(uname -s)-$$(uname -m) > .dapper.tmp 84 | @@chmod +x .dapper.tmp 85 | @./.dapper.tmp -v 86 | @mv .dapper.tmp .dapper 87 | 88 | dapper-%: .dapper 89 | @mkdir -p ./bin/ ./dist/ 90 | env DOCKER_BUILDKIT=$(DOCKER_BUILDKIT) ./.dapper -f Dockerfile --target dapper make $* -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | k3c - Classic Docker (Build) for a Kubernetes world 2 | =========================================== 3 | 4 | ***STATUS: EXPERIMENT - Let us know what you think*** 5 | 6 | ***NOTE: the original experiment started on `master` while the next-gen work will be on `main`*** 7 | 8 | `k3c` brings the Classic ™ Docker images manipulation UX to your 9 | `k3s` development workflow. It is designed to enable the rapid feedback 10 | when developing and testing local container images in `k3s` and `rke2`. 11 | Currently `k3s`, the [lightweight Kubernetes distribution](https://github.com/k3s-io/k3s), 12 | provides a great solution for Kubernetes from dev to production. While 13 | `k3s` satisifies the Kubernetes runtime needs, one still needs to run 14 | `docker` (or a docker-like tool) to actually develop and build the container 15 | images. `k3c` is intended to replace `docker` for just the functionality 16 | needed for building and manipulating images in the Kubernetes ecosystem. 17 | 18 | ## A familiar UX 19 | 20 | There really is nothing better than the classic Docker UX of `build/push/pull/tag`. 21 | This tool copies the same UX as classic Docker (think Docker v1.12). The intention 22 | is to follow the same style but not be a 100% drop in replacement. Behaviour and 23 | arguments have been changed to better match the behavior of the Kubernetes ecosystem. 24 | 25 | ## A single binary 26 | 27 | `k3c`, similar to `k3s` and old school docker, is packaged as a single binary, because nothing 28 | is easier for distribution than a static binary. 29 | 30 | ## Built on Kubernetes Tech (and others) 31 | 32 | Fundamentally `k3c` is a built on the [Container Runtime Interface (CRI)](https://github.com/kubernetes/cri-api), 33 | [containerd](https://github.com/containerd/containerd), and [buildkit](https://github.com/moby/buildkit). 34 | 35 | ## Architecture 36 | 37 | `k3c` enables building `k3s`-local images by installing a DaemonSet Pod that runs both `buildkitd` and `k3c agent` 38 | and exposing the gRPC endpoints for these active agents in your cluster via a Service. Once installed, the `k3c` CLI 39 | can inspect your installation and communicate with the backend daemons for image building and manipulation with merely 40 | the KUBECONFIG that was available when invoking `k3c install`. When building `k3c` will talk directly to the `buildkit` 41 | service but all other interactions with the underlying containerd/CRI are mediated by the `k3c agent` (primarily 42 | because the `containerd` client code assumes a certain level of co-locality with the `containerd` installation). 43 | 44 | ## Building 45 | 46 | ```bash 47 | # more to come on this front but builds are currently a very manual affair 48 | # git clone --branch=trunk https://github.com/rancher/k3c.git ~/Projects/rancher/k3c 49 | # cd ~/Projects/rancher/k3c 50 | go generate # only necessary when modifying the gRPC protobuf IDL, see Dockerfile for pre-reqs 51 | make ORG= build publish 52 | ``` 53 | 54 | ## Running 55 | 56 | Have a working `k3s` installation with a working `$HOME/.kube/config` or `$KUBECONFIG`, then: 57 | 58 | ```bash 59 | # Installation on a single-node cluster 60 | ./bin/k3c install --agent-image=docker.io/${ORG}/k3c 61 | ``` 62 | 63 | ```bash 64 | # Installation on a multi-node cluster, targeting a Node named "my-builder-node" 65 | ./bin/k3c install --agent-image=docker.io/${ORG}/k3c --selector k3s.io/hostname=my-builder-node 66 | 67 | ``` 68 | 69 | `k3c` currently works against a single builder node so you must specify a narrow selector when 70 | installing on multi-node clusters. Upon successful installation this node will acquire the "builder" role. 71 | 72 | Build images like you would with `docker` 73 | 74 | ``` 75 | $ ./bin/k3c --help 76 | Usage: 77 | k3c [flags] 78 | k3c [command] 79 | 80 | Available Commands: 81 | build Build an image 82 | help Help about any command 83 | images List images 84 | install Install builder component(s) 85 | pull Pull an image 86 | push Push an image 87 | rmi Remove an image 88 | tag Tag an image 89 | uninstall Uninstall builder component(s) 90 | 91 | Flags: 92 | -x, --context string kubeconfig context for authentication 93 | --debug 94 | --debug-level int 95 | -h, --help help for k3c 96 | -k, --kubeconfig string kubeconfig for authentication 97 | -n, --namespace string namespace (default "k3c") 98 | -v, --version version for k3c 99 | 100 | Use "k3c [command] --help" for more information about a command. 101 | ``` 102 | 103 | ## Roadmap 104 | 105 | - Automated builds for clients on MacOS (amd64/arm64), Windows (amd64), and Linux client/server (amd64/arm64/arm). 106 | 107 | # License 108 | 109 | Copyright (c) 2020-2021 [Rancher Labs, Inc.](http://rancher.com) 110 | 111 | Licensed under the Apache License, Version 2.0 (the "License"); 112 | you may not use this file except in compliance with the License. 113 | You may obtain a copy of the License at 114 | 115 | [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) 116 | 117 | Unless required by applicable law or agreed to in writing, software 118 | distributed under the License is distributed on an "AS IS" BASIS, 119 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 120 | See the License for the specific language governing permissions and 121 | limitations under the License. 122 | 123 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/rancher/k3c 2 | 3 | go 1.15 4 | 5 | replace ( 6 | github.com/Azure/go-autorest => github.com/Azure/go-autorest v14.0.0+incompatible 7 | github.com/containerd/containerd => github.com/k3s-io/containerd v1.4.3-k3s2 8 | github.com/jaguilar/vt100 => github.com/tonistiigi/vt100 v0.0.0-20190402012908-ad4c4a574305 // same as buildkit 9 | k8s.io/api => github.com/k3s-io/kubernetes/staging/src/k8s.io/api v1.19.5-k3s1 10 | k8s.io/apiextensions-apiserver => github.com/k3s-io/kubernetes/staging/src/k8s.io/apiextensions-apiserver v1.19.5-k3s1 11 | k8s.io/apimachinery => github.com/k3s-io/kubernetes/staging/src/k8s.io/apimachinery v1.19.5-k3s1 12 | k8s.io/apiserver => github.com/k3s-io/kubernetes/staging/src/k8s.io/apiserver v1.19.5-k3s1 13 | k8s.io/cli-runtime => github.com/k3s-io/kubernetes/staging/src/k8s.io/cli-runtime v1.19.5-k3s1 14 | k8s.io/client-go => github.com/k3s-io/kubernetes/staging/src/k8s.io/client-go v1.19.5-k3s1 15 | k8s.io/cloud-provider => github.com/k3s-io/kubernetes/staging/src/k8s.io/cloud-provider v1.19.5-k3s1 16 | k8s.io/cluster-bootstrap => github.com/k3s-io/kubernetes/staging/src/k8s.io/cluster-bootstrap v1.19.5-k3s1 17 | k8s.io/code-generator => github.com/k3s-io/kubernetes/staging/src/k8s.io/code-generator v1.19.5-k3s1 18 | k8s.io/component-base => github.com/k3s-io/kubernetes/staging/src/k8s.io/component-base v1.19.5-k3s1 19 | k8s.io/cri-api => github.com/k3s-io/kubernetes/staging/src/k8s.io/cri-api v1.19.5-k3s1 20 | k8s.io/csi-translation-lib => github.com/k3s-io/kubernetes/staging/src/k8s.io/csi-translation-lib v1.19.5-k3s1 21 | k8s.io/kube-aggregator => github.com/k3s-io/kubernetes/staging/src/k8s.io/kube-aggregator v1.19.5-k3s1 22 | k8s.io/kube-controller-manager => github.com/k3s-io/kubernetes/staging/src/k8s.io/kube-controller-manager v1.19.5-k3s1 23 | k8s.io/kube-proxy => github.com/k3s-io/kubernetes/staging/src/k8s.io/kube-proxy v1.19.5-k3s1 24 | k8s.io/kube-scheduler => github.com/k3s-io/kubernetes/staging/src/k8s.io/kube-scheduler v1.19.5-k3s1 25 | k8s.io/kubectl => github.com/k3s-io/kubernetes/staging/src/k8s.io/kubectl v1.19.5-k3s1 26 | k8s.io/kubelet => github.com/k3s-io/kubernetes/staging/src/k8s.io/kubelet v1.19.5-k3s1 27 | k8s.io/kubernetes => github.com/k3s-io/kubernetes v1.19.5-k3s1 28 | k8s.io/legacy-cloud-providers => github.com/k3s-io/kubernetes/staging/src/k8s.io/legacy-cloud-providers v1.19.5-k3s1 29 | k8s.io/metrics => github.com/k3s-io/kubernetes/staging/src/k8s.io/metrics v1.19.5-k3s1 30 | k8s.io/node-api => github.com/k3s-io/kubernetes/staging/src/k8s.io/node-api v1.19.5-k3s1 31 | k8s.io/sample-apiserver => github.com/k3s-io/kubernetes/staging/src/k8s.io/sample-apiserver v1.19.5-k3s1 32 | k8s.io/sample-cli-plugin => github.com/k3s-io/kubernetes/staging/src/k8s.io/sample-cli-plugin v1.19.5-k3s1 33 | k8s.io/sample-controller => github.com/k3s-io/kubernetes/staging/src/k8s.io/sample-controller v1.19.5-k3s1 34 | ) 35 | 36 | require ( 37 | github.com/containerd/console v1.0.1 38 | github.com/containerd/containerd v1.4.3 39 | github.com/containerd/cri v1.11.1-0.20200810101850-4e6644c8cf7f 40 | github.com/containerd/typeurl v1.0.1 41 | github.com/docker/go-units v0.4.0 42 | github.com/gogo/googleapis v1.3.2 43 | github.com/gogo/protobuf v1.3.2 44 | github.com/golang/protobuf v1.4.3 45 | github.com/moby/buildkit v0.8.1 46 | github.com/moby/sys/symlink v0.1.0 // indirect 47 | github.com/opencontainers/go-digest v1.0.0 // indirect 48 | github.com/opencontainers/image-spec v1.0.1 49 | github.com/pkg/errors v0.9.1 50 | github.com/rancher/wrangler v0.7.3-0.20201002224307-4303c423125a 51 | github.com/rancher/wrangler-cli v0.0.0-20200815040857-81c48cf8ab43 52 | github.com/sirupsen/logrus v1.7.0 53 | github.com/spf13/cobra v1.1.1 54 | golang.org/dl v0.0.0-20210120004500-be2bfd84e4cf // indirect 55 | golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 56 | google.golang.org/grpc v1.29.1 57 | k8s.io/api v0.19.0 58 | k8s.io/apimachinery v0.19.0 59 | k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible 60 | k8s.io/cri-api v0.19.0 61 | k8s.io/kubernetes v1.13.0 62 | ) 63 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | //go:generate protoc --gofast_out=plugins=grpc:. -I=./vendor:. pkg/apis/services/images/v1alpha1/images.proto 2 | 3 | package main 4 | 5 | import ( 6 | "github.com/containerd/containerd/pkg/seed" 7 | "github.com/rancher/k3c/pkg/cli" 8 | command "github.com/rancher/wrangler-cli" 9 | 10 | // Add non-default auth providers 11 | _ "k8s.io/client-go/plugin/pkg/client/auth" 12 | ) 13 | 14 | func init() { 15 | seed.WithTimeAndRand() 16 | } 17 | 18 | func main() { 19 | command.Main(cli.Main()) 20 | } 21 | -------------------------------------------------------------------------------- /pkg/apis/services/images/images.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | // adapted from https://github.com/kubernetes-sigs/cri-tools/blob/1bcad62d514c1166c9fd49557d2c5de2b05368aa/cmd/crictl/image.go 16 | 17 | package images 18 | 19 | import ( 20 | "sort" 21 | "strings" 22 | 23 | criv1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 24 | ) 25 | 26 | type byId []*criv1.Image 27 | 28 | func (a byId) Len() int { return len(a) } 29 | func (a byId) Swap(i, j int) { a[i], a[j] = a[j], a[i] } 30 | func (a byId) Less(i, j int) bool { 31 | return a[i].Id < a[j].Id 32 | } 33 | 34 | type byDigest []*criv1.Image 35 | 36 | func (a byDigest) Len() int { return len(a) } 37 | func (a byDigest) Swap(i, j int) { a[i], a[j] = a[j], a[i] } 38 | func (a byDigest) Less(i, j int) bool { 39 | return strings.Join(a[i].RepoDigests, `_`) < strings.Join(a[j].RepoDigests, `_`) 40 | } 41 | 42 | func Sort(refs []*criv1.Image) { 43 | sort.Sort(byId(refs)) 44 | sort.Sort(byDigest(refs)) 45 | } 46 | 47 | func TruncateID(id, prefix string, n int) string { 48 | id = strings.TrimPrefix(id, prefix) 49 | if len(id) > n { 50 | id = id[:n] 51 | } 52 | return id 53 | } 54 | 55 | func NormalizeRepoDigest(repoDigests []string) (string, string) { 56 | if len(repoDigests) == 0 { 57 | return "", "" 58 | } 59 | repoDigestPair := strings.Split(repoDigests[0], "@") 60 | if len(repoDigestPair) != 2 { 61 | return "errorName", "errorRepoDigest" 62 | } 63 | return repoDigestPair[0], repoDigestPair[1] 64 | } 65 | 66 | func NormalizeRepoTagPair(repoTags []string, imageName string) (repoTagPairs [][]string) { 67 | const none = "" 68 | if len(repoTags) == 0 { 69 | repoTagPairs = append(repoTagPairs, []string{imageName, none}) 70 | return 71 | } 72 | for _, repoTag := range repoTags { 73 | idx := strings.LastIndex(repoTag, ":") 74 | if idx == -1 { 75 | repoTagPairs = append(repoTagPairs, []string{"errorRepoTag", "errorRepoTag"}) 76 | continue 77 | } 78 | name := repoTag[:idx] 79 | if name == none { 80 | name = imageName 81 | } 82 | repoTagPairs = append(repoTagPairs, []string{name, repoTag[idx+1:]}) 83 | } 84 | return 85 | } 86 | -------------------------------------------------------------------------------- /pkg/apis/services/images/v1alpha1/images.go: -------------------------------------------------------------------------------- 1 | // support protobuf code generation 2 | 3 | package images 4 | 5 | import ( 6 | // vendor-time imports supporting protoc imports 7 | _ "github.com/gogo/googleapis/google/rpc" 8 | _ "github.com/gogo/protobuf/gogoproto" 9 | _ "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 10 | ) 11 | -------------------------------------------------------------------------------- /pkg/apis/services/images/v1alpha1/images.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-gogo. DO NOT EDIT. 2 | // source: pkg/apis/services/images/v1alpha1/images.proto 3 | 4 | package images 5 | 6 | import ( 7 | context "context" 8 | fmt "fmt" 9 | _ "github.com/gogo/protobuf/gogoproto" 10 | github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" 11 | proto "github.com/golang/protobuf/proto" 12 | _ "github.com/golang/protobuf/ptypes/timestamp" 13 | grpc "google.golang.org/grpc" 14 | codes "google.golang.org/grpc/codes" 15 | status "google.golang.org/grpc/status" 16 | io "io" 17 | v1alpha2 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 18 | math "math" 19 | math_bits "math/bits" 20 | reflect "reflect" 21 | strings "strings" 22 | time "time" 23 | ) 24 | 25 | // Reference imports to suppress errors if they are not otherwise used. 26 | var _ = proto.Marshal 27 | var _ = fmt.Errorf 28 | var _ = math.Inf 29 | var _ = time.Kitchen 30 | 31 | // This is a compile-time assertion to ensure that this generated file 32 | // is compatible with the proto package it is being compiled against. 33 | // A compilation error at this line likely means your copy of the 34 | // proto package needs to be updated. 35 | const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package 36 | 37 | type ImageListRequest struct { 38 | // Filter to list images. 39 | Filter *v1alpha2.ImageFilter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` 40 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 41 | XXX_sizecache int32 `json:"-"` 42 | } 43 | 44 | func (m *ImageListRequest) Reset() { *m = ImageListRequest{} } 45 | func (*ImageListRequest) ProtoMessage() {} 46 | func (*ImageListRequest) Descriptor() ([]byte, []int) { 47 | return fileDescriptor_51c65cb1807988f9, []int{0} 48 | } 49 | func (m *ImageListRequest) XXX_Unmarshal(b []byte) error { 50 | return m.Unmarshal(b) 51 | } 52 | func (m *ImageListRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 53 | if deterministic { 54 | return xxx_messageInfo_ImageListRequest.Marshal(b, m, deterministic) 55 | } else { 56 | b = b[:cap(b)] 57 | n, err := m.MarshalToSizedBuffer(b) 58 | if err != nil { 59 | return nil, err 60 | } 61 | return b[:n], nil 62 | } 63 | } 64 | func (m *ImageListRequest) XXX_Merge(src proto.Message) { 65 | xxx_messageInfo_ImageListRequest.Merge(m, src) 66 | } 67 | func (m *ImageListRequest) XXX_Size() int { 68 | return m.Size() 69 | } 70 | func (m *ImageListRequest) XXX_DiscardUnknown() { 71 | xxx_messageInfo_ImageListRequest.DiscardUnknown(m) 72 | } 73 | 74 | var xxx_messageInfo_ImageListRequest proto.InternalMessageInfo 75 | 76 | func (m *ImageListRequest) GetFilter() *v1alpha2.ImageFilter { 77 | if m != nil { 78 | return m.Filter 79 | } 80 | return nil 81 | } 82 | 83 | type ImageListResponse struct { 84 | // List of images. 85 | Images []*v1alpha2.Image `protobuf:"bytes,1,rep,name=images,proto3" json:"images,omitempty"` 86 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 87 | XXX_sizecache int32 `json:"-"` 88 | } 89 | 90 | func (m *ImageListResponse) Reset() { *m = ImageListResponse{} } 91 | func (*ImageListResponse) ProtoMessage() {} 92 | func (*ImageListResponse) Descriptor() ([]byte, []int) { 93 | return fileDescriptor_51c65cb1807988f9, []int{1} 94 | } 95 | func (m *ImageListResponse) XXX_Unmarshal(b []byte) error { 96 | return m.Unmarshal(b) 97 | } 98 | func (m *ImageListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 99 | if deterministic { 100 | return xxx_messageInfo_ImageListResponse.Marshal(b, m, deterministic) 101 | } else { 102 | b = b[:cap(b)] 103 | n, err := m.MarshalToSizedBuffer(b) 104 | if err != nil { 105 | return nil, err 106 | } 107 | return b[:n], nil 108 | } 109 | } 110 | func (m *ImageListResponse) XXX_Merge(src proto.Message) { 111 | xxx_messageInfo_ImageListResponse.Merge(m, src) 112 | } 113 | func (m *ImageListResponse) XXX_Size() int { 114 | return m.Size() 115 | } 116 | func (m *ImageListResponse) XXX_DiscardUnknown() { 117 | xxx_messageInfo_ImageListResponse.DiscardUnknown(m) 118 | } 119 | 120 | var xxx_messageInfo_ImageListResponse proto.InternalMessageInfo 121 | 122 | func (m *ImageListResponse) GetImages() []*v1alpha2.Image { 123 | if m != nil { 124 | return m.Images 125 | } 126 | return nil 127 | } 128 | 129 | type ImagePullRequest struct { 130 | Image *v1alpha2.ImageSpec `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` 131 | Auth *v1alpha2.AuthConfig `protobuf:"bytes,2,opt,name=auth,proto3" json:"auth,omitempty"` 132 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 133 | XXX_sizecache int32 `json:"-"` 134 | } 135 | 136 | func (m *ImagePullRequest) Reset() { *m = ImagePullRequest{} } 137 | func (*ImagePullRequest) ProtoMessage() {} 138 | func (*ImagePullRequest) Descriptor() ([]byte, []int) { 139 | return fileDescriptor_51c65cb1807988f9, []int{2} 140 | } 141 | func (m *ImagePullRequest) XXX_Unmarshal(b []byte) error { 142 | return m.Unmarshal(b) 143 | } 144 | func (m *ImagePullRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 145 | if deterministic { 146 | return xxx_messageInfo_ImagePullRequest.Marshal(b, m, deterministic) 147 | } else { 148 | b = b[:cap(b)] 149 | n, err := m.MarshalToSizedBuffer(b) 150 | if err != nil { 151 | return nil, err 152 | } 153 | return b[:n], nil 154 | } 155 | } 156 | func (m *ImagePullRequest) XXX_Merge(src proto.Message) { 157 | xxx_messageInfo_ImagePullRequest.Merge(m, src) 158 | } 159 | func (m *ImagePullRequest) XXX_Size() int { 160 | return m.Size() 161 | } 162 | func (m *ImagePullRequest) XXX_DiscardUnknown() { 163 | xxx_messageInfo_ImagePullRequest.DiscardUnknown(m) 164 | } 165 | 166 | var xxx_messageInfo_ImagePullRequest proto.InternalMessageInfo 167 | 168 | func (m *ImagePullRequest) GetImage() *v1alpha2.ImageSpec { 169 | if m != nil { 170 | return m.Image 171 | } 172 | return nil 173 | } 174 | 175 | func (m *ImagePullRequest) GetAuth() *v1alpha2.AuthConfig { 176 | if m != nil { 177 | return m.Auth 178 | } 179 | return nil 180 | } 181 | 182 | type ImagePullResponse struct { 183 | Image string `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` 184 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 185 | XXX_sizecache int32 `json:"-"` 186 | } 187 | 188 | func (m *ImagePullResponse) Reset() { *m = ImagePullResponse{} } 189 | func (*ImagePullResponse) ProtoMessage() {} 190 | func (*ImagePullResponse) Descriptor() ([]byte, []int) { 191 | return fileDescriptor_51c65cb1807988f9, []int{3} 192 | } 193 | func (m *ImagePullResponse) XXX_Unmarshal(b []byte) error { 194 | return m.Unmarshal(b) 195 | } 196 | func (m *ImagePullResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 197 | if deterministic { 198 | return xxx_messageInfo_ImagePullResponse.Marshal(b, m, deterministic) 199 | } else { 200 | b = b[:cap(b)] 201 | n, err := m.MarshalToSizedBuffer(b) 202 | if err != nil { 203 | return nil, err 204 | } 205 | return b[:n], nil 206 | } 207 | } 208 | func (m *ImagePullResponse) XXX_Merge(src proto.Message) { 209 | xxx_messageInfo_ImagePullResponse.Merge(m, src) 210 | } 211 | func (m *ImagePullResponse) XXX_Size() int { 212 | return m.Size() 213 | } 214 | func (m *ImagePullResponse) XXX_DiscardUnknown() { 215 | xxx_messageInfo_ImagePullResponse.DiscardUnknown(m) 216 | } 217 | 218 | var xxx_messageInfo_ImagePullResponse proto.InternalMessageInfo 219 | 220 | func (m *ImagePullResponse) GetImage() string { 221 | if m != nil { 222 | return m.Image 223 | } 224 | return "" 225 | } 226 | 227 | type ImagePushRequest struct { 228 | Image *v1alpha2.ImageSpec `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` 229 | Auth *v1alpha2.AuthConfig `protobuf:"bytes,2,opt,name=auth,proto3" json:"auth,omitempty"` 230 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 231 | XXX_sizecache int32 `json:"-"` 232 | } 233 | 234 | func (m *ImagePushRequest) Reset() { *m = ImagePushRequest{} } 235 | func (*ImagePushRequest) ProtoMessage() {} 236 | func (*ImagePushRequest) Descriptor() ([]byte, []int) { 237 | return fileDescriptor_51c65cb1807988f9, []int{4} 238 | } 239 | func (m *ImagePushRequest) XXX_Unmarshal(b []byte) error { 240 | return m.Unmarshal(b) 241 | } 242 | func (m *ImagePushRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 243 | if deterministic { 244 | return xxx_messageInfo_ImagePushRequest.Marshal(b, m, deterministic) 245 | } else { 246 | b = b[:cap(b)] 247 | n, err := m.MarshalToSizedBuffer(b) 248 | if err != nil { 249 | return nil, err 250 | } 251 | return b[:n], nil 252 | } 253 | } 254 | func (m *ImagePushRequest) XXX_Merge(src proto.Message) { 255 | xxx_messageInfo_ImagePushRequest.Merge(m, src) 256 | } 257 | func (m *ImagePushRequest) XXX_Size() int { 258 | return m.Size() 259 | } 260 | func (m *ImagePushRequest) XXX_DiscardUnknown() { 261 | xxx_messageInfo_ImagePushRequest.DiscardUnknown(m) 262 | } 263 | 264 | var xxx_messageInfo_ImagePushRequest proto.InternalMessageInfo 265 | 266 | func (m *ImagePushRequest) GetImage() *v1alpha2.ImageSpec { 267 | if m != nil { 268 | return m.Image 269 | } 270 | return nil 271 | } 272 | 273 | func (m *ImagePushRequest) GetAuth() *v1alpha2.AuthConfig { 274 | if m != nil { 275 | return m.Auth 276 | } 277 | return nil 278 | } 279 | 280 | type ImagePushResponse struct { 281 | Image string `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` 282 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 283 | XXX_sizecache int32 `json:"-"` 284 | } 285 | 286 | func (m *ImagePushResponse) Reset() { *m = ImagePushResponse{} } 287 | func (*ImagePushResponse) ProtoMessage() {} 288 | func (*ImagePushResponse) Descriptor() ([]byte, []int) { 289 | return fileDescriptor_51c65cb1807988f9, []int{5} 290 | } 291 | func (m *ImagePushResponse) XXX_Unmarshal(b []byte) error { 292 | return m.Unmarshal(b) 293 | } 294 | func (m *ImagePushResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 295 | if deterministic { 296 | return xxx_messageInfo_ImagePushResponse.Marshal(b, m, deterministic) 297 | } else { 298 | b = b[:cap(b)] 299 | n, err := m.MarshalToSizedBuffer(b) 300 | if err != nil { 301 | return nil, err 302 | } 303 | return b[:n], nil 304 | } 305 | } 306 | func (m *ImagePushResponse) XXX_Merge(src proto.Message) { 307 | xxx_messageInfo_ImagePushResponse.Merge(m, src) 308 | } 309 | func (m *ImagePushResponse) XXX_Size() int { 310 | return m.Size() 311 | } 312 | func (m *ImagePushResponse) XXX_DiscardUnknown() { 313 | xxx_messageInfo_ImagePushResponse.DiscardUnknown(m) 314 | } 315 | 316 | var xxx_messageInfo_ImagePushResponse proto.InternalMessageInfo 317 | 318 | func (m *ImagePushResponse) GetImage() string { 319 | if m != nil { 320 | return m.Image 321 | } 322 | return "" 323 | } 324 | 325 | type ImageProgressRequest struct { 326 | Image string `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` 327 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 328 | XXX_sizecache int32 `json:"-"` 329 | } 330 | 331 | func (m *ImageProgressRequest) Reset() { *m = ImageProgressRequest{} } 332 | func (*ImageProgressRequest) ProtoMessage() {} 333 | func (*ImageProgressRequest) Descriptor() ([]byte, []int) { 334 | return fileDescriptor_51c65cb1807988f9, []int{6} 335 | } 336 | func (m *ImageProgressRequest) XXX_Unmarshal(b []byte) error { 337 | return m.Unmarshal(b) 338 | } 339 | func (m *ImageProgressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 340 | if deterministic { 341 | return xxx_messageInfo_ImageProgressRequest.Marshal(b, m, deterministic) 342 | } else { 343 | b = b[:cap(b)] 344 | n, err := m.MarshalToSizedBuffer(b) 345 | if err != nil { 346 | return nil, err 347 | } 348 | return b[:n], nil 349 | } 350 | } 351 | func (m *ImageProgressRequest) XXX_Merge(src proto.Message) { 352 | xxx_messageInfo_ImageProgressRequest.Merge(m, src) 353 | } 354 | func (m *ImageProgressRequest) XXX_Size() int { 355 | return m.Size() 356 | } 357 | func (m *ImageProgressRequest) XXX_DiscardUnknown() { 358 | xxx_messageInfo_ImageProgressRequest.DiscardUnknown(m) 359 | } 360 | 361 | var xxx_messageInfo_ImageProgressRequest proto.InternalMessageInfo 362 | 363 | func (m *ImageProgressRequest) GetImage() string { 364 | if m != nil { 365 | return m.Image 366 | } 367 | return "" 368 | } 369 | 370 | type ImageProgressResponse struct { 371 | Status []ImageStatus `protobuf:"bytes,1,rep,name=status,proto3" json:"status"` 372 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 373 | XXX_sizecache int32 `json:"-"` 374 | } 375 | 376 | func (m *ImageProgressResponse) Reset() { *m = ImageProgressResponse{} } 377 | func (*ImageProgressResponse) ProtoMessage() {} 378 | func (*ImageProgressResponse) Descriptor() ([]byte, []int) { 379 | return fileDescriptor_51c65cb1807988f9, []int{7} 380 | } 381 | func (m *ImageProgressResponse) XXX_Unmarshal(b []byte) error { 382 | return m.Unmarshal(b) 383 | } 384 | func (m *ImageProgressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 385 | if deterministic { 386 | return xxx_messageInfo_ImageProgressResponse.Marshal(b, m, deterministic) 387 | } else { 388 | b = b[:cap(b)] 389 | n, err := m.MarshalToSizedBuffer(b) 390 | if err != nil { 391 | return nil, err 392 | } 393 | return b[:n], nil 394 | } 395 | } 396 | func (m *ImageProgressResponse) XXX_Merge(src proto.Message) { 397 | xxx_messageInfo_ImageProgressResponse.Merge(m, src) 398 | } 399 | func (m *ImageProgressResponse) XXX_Size() int { 400 | return m.Size() 401 | } 402 | func (m *ImageProgressResponse) XXX_DiscardUnknown() { 403 | xxx_messageInfo_ImageProgressResponse.DiscardUnknown(m) 404 | } 405 | 406 | var xxx_messageInfo_ImageProgressResponse proto.InternalMessageInfo 407 | 408 | func (m *ImageProgressResponse) GetStatus() []ImageStatus { 409 | if m != nil { 410 | return m.Status 411 | } 412 | return nil 413 | } 414 | 415 | // lifted from github.com/containerd/containerd/api/services/content/v1/content.proto 416 | type ImageStatus struct { 417 | Ref string `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` 418 | Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` 419 | Offset int64 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"` 420 | Total int64 `protobuf:"varint,4,opt,name=total,proto3" json:"total,omitempty"` 421 | StartedAt time.Time `protobuf:"bytes,5,opt,name=started_at,json=startedAt,proto3,stdtime" json:"started_at"` 422 | UpdatedAt time.Time `protobuf:"bytes,6,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` 423 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 424 | XXX_sizecache int32 `json:"-"` 425 | } 426 | 427 | func (m *ImageStatus) Reset() { *m = ImageStatus{} } 428 | func (*ImageStatus) ProtoMessage() {} 429 | func (*ImageStatus) Descriptor() ([]byte, []int) { 430 | return fileDescriptor_51c65cb1807988f9, []int{8} 431 | } 432 | func (m *ImageStatus) XXX_Unmarshal(b []byte) error { 433 | return m.Unmarshal(b) 434 | } 435 | func (m *ImageStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 436 | if deterministic { 437 | return xxx_messageInfo_ImageStatus.Marshal(b, m, deterministic) 438 | } else { 439 | b = b[:cap(b)] 440 | n, err := m.MarshalToSizedBuffer(b) 441 | if err != nil { 442 | return nil, err 443 | } 444 | return b[:n], nil 445 | } 446 | } 447 | func (m *ImageStatus) XXX_Merge(src proto.Message) { 448 | xxx_messageInfo_ImageStatus.Merge(m, src) 449 | } 450 | func (m *ImageStatus) XXX_Size() int { 451 | return m.Size() 452 | } 453 | func (m *ImageStatus) XXX_DiscardUnknown() { 454 | xxx_messageInfo_ImageStatus.DiscardUnknown(m) 455 | } 456 | 457 | var xxx_messageInfo_ImageStatus proto.InternalMessageInfo 458 | 459 | func (m *ImageStatus) GetRef() string { 460 | if m != nil { 461 | return m.Ref 462 | } 463 | return "" 464 | } 465 | 466 | func (m *ImageStatus) GetStatus() string { 467 | if m != nil { 468 | return m.Status 469 | } 470 | return "" 471 | } 472 | 473 | func (m *ImageStatus) GetOffset() int64 { 474 | if m != nil { 475 | return m.Offset 476 | } 477 | return 0 478 | } 479 | 480 | func (m *ImageStatus) GetTotal() int64 { 481 | if m != nil { 482 | return m.Total 483 | } 484 | return 0 485 | } 486 | 487 | func (m *ImageStatus) GetStartedAt() time.Time { 488 | if m != nil { 489 | return m.StartedAt 490 | } 491 | return time.Time{} 492 | } 493 | 494 | func (m *ImageStatus) GetUpdatedAt() time.Time { 495 | if m != nil { 496 | return m.UpdatedAt 497 | } 498 | return time.Time{} 499 | } 500 | 501 | type ImageRemoveRequest struct { 502 | // Spec of the image to remove. 503 | Image *v1alpha2.ImageSpec `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` 504 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 505 | XXX_sizecache int32 `json:"-"` 506 | } 507 | 508 | func (m *ImageRemoveRequest) Reset() { *m = ImageRemoveRequest{} } 509 | func (*ImageRemoveRequest) ProtoMessage() {} 510 | func (*ImageRemoveRequest) Descriptor() ([]byte, []int) { 511 | return fileDescriptor_51c65cb1807988f9, []int{9} 512 | } 513 | func (m *ImageRemoveRequest) XXX_Unmarshal(b []byte) error { 514 | return m.Unmarshal(b) 515 | } 516 | func (m *ImageRemoveRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 517 | if deterministic { 518 | return xxx_messageInfo_ImageRemoveRequest.Marshal(b, m, deterministic) 519 | } else { 520 | b = b[:cap(b)] 521 | n, err := m.MarshalToSizedBuffer(b) 522 | if err != nil { 523 | return nil, err 524 | } 525 | return b[:n], nil 526 | } 527 | } 528 | func (m *ImageRemoveRequest) XXX_Merge(src proto.Message) { 529 | xxx_messageInfo_ImageRemoveRequest.Merge(m, src) 530 | } 531 | func (m *ImageRemoveRequest) XXX_Size() int { 532 | return m.Size() 533 | } 534 | func (m *ImageRemoveRequest) XXX_DiscardUnknown() { 535 | xxx_messageInfo_ImageRemoveRequest.DiscardUnknown(m) 536 | } 537 | 538 | var xxx_messageInfo_ImageRemoveRequest proto.InternalMessageInfo 539 | 540 | func (m *ImageRemoveRequest) GetImage() *v1alpha2.ImageSpec { 541 | if m != nil { 542 | return m.Image 543 | } 544 | return nil 545 | } 546 | 547 | type ImageRemoveResponse struct { 548 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 549 | XXX_sizecache int32 `json:"-"` 550 | } 551 | 552 | func (m *ImageRemoveResponse) Reset() { *m = ImageRemoveResponse{} } 553 | func (*ImageRemoveResponse) ProtoMessage() {} 554 | func (*ImageRemoveResponse) Descriptor() ([]byte, []int) { 555 | return fileDescriptor_51c65cb1807988f9, []int{10} 556 | } 557 | func (m *ImageRemoveResponse) XXX_Unmarshal(b []byte) error { 558 | return m.Unmarshal(b) 559 | } 560 | func (m *ImageRemoveResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 561 | if deterministic { 562 | return xxx_messageInfo_ImageRemoveResponse.Marshal(b, m, deterministic) 563 | } else { 564 | b = b[:cap(b)] 565 | n, err := m.MarshalToSizedBuffer(b) 566 | if err != nil { 567 | return nil, err 568 | } 569 | return b[:n], nil 570 | } 571 | } 572 | func (m *ImageRemoveResponse) XXX_Merge(src proto.Message) { 573 | xxx_messageInfo_ImageRemoveResponse.Merge(m, src) 574 | } 575 | func (m *ImageRemoveResponse) XXX_Size() int { 576 | return m.Size() 577 | } 578 | func (m *ImageRemoveResponse) XXX_DiscardUnknown() { 579 | xxx_messageInfo_ImageRemoveResponse.DiscardUnknown(m) 580 | } 581 | 582 | var xxx_messageInfo_ImageRemoveResponse proto.InternalMessageInfo 583 | 584 | type ImageStatusRequest struct { 585 | // Spec of the image. 586 | Image *v1alpha2.ImageSpec `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` 587 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 588 | XXX_sizecache int32 `json:"-"` 589 | } 590 | 591 | func (m *ImageStatusRequest) Reset() { *m = ImageStatusRequest{} } 592 | func (*ImageStatusRequest) ProtoMessage() {} 593 | func (*ImageStatusRequest) Descriptor() ([]byte, []int) { 594 | return fileDescriptor_51c65cb1807988f9, []int{11} 595 | } 596 | func (m *ImageStatusRequest) XXX_Unmarshal(b []byte) error { 597 | return m.Unmarshal(b) 598 | } 599 | func (m *ImageStatusRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 600 | if deterministic { 601 | return xxx_messageInfo_ImageStatusRequest.Marshal(b, m, deterministic) 602 | } else { 603 | b = b[:cap(b)] 604 | n, err := m.MarshalToSizedBuffer(b) 605 | if err != nil { 606 | return nil, err 607 | } 608 | return b[:n], nil 609 | } 610 | } 611 | func (m *ImageStatusRequest) XXX_Merge(src proto.Message) { 612 | xxx_messageInfo_ImageStatusRequest.Merge(m, src) 613 | } 614 | func (m *ImageStatusRequest) XXX_Size() int { 615 | return m.Size() 616 | } 617 | func (m *ImageStatusRequest) XXX_DiscardUnknown() { 618 | xxx_messageInfo_ImageStatusRequest.DiscardUnknown(m) 619 | } 620 | 621 | var xxx_messageInfo_ImageStatusRequest proto.InternalMessageInfo 622 | 623 | func (m *ImageStatusRequest) GetImage() *v1alpha2.ImageSpec { 624 | if m != nil { 625 | return m.Image 626 | } 627 | return nil 628 | } 629 | 630 | type ImageStatusResponse struct { 631 | // Status of the image. 632 | Image *v1alpha2.Image `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` 633 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 634 | XXX_sizecache int32 `json:"-"` 635 | } 636 | 637 | func (m *ImageStatusResponse) Reset() { *m = ImageStatusResponse{} } 638 | func (*ImageStatusResponse) ProtoMessage() {} 639 | func (*ImageStatusResponse) Descriptor() ([]byte, []int) { 640 | return fileDescriptor_51c65cb1807988f9, []int{12} 641 | } 642 | func (m *ImageStatusResponse) XXX_Unmarshal(b []byte) error { 643 | return m.Unmarshal(b) 644 | } 645 | func (m *ImageStatusResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 646 | if deterministic { 647 | return xxx_messageInfo_ImageStatusResponse.Marshal(b, m, deterministic) 648 | } else { 649 | b = b[:cap(b)] 650 | n, err := m.MarshalToSizedBuffer(b) 651 | if err != nil { 652 | return nil, err 653 | } 654 | return b[:n], nil 655 | } 656 | } 657 | func (m *ImageStatusResponse) XXX_Merge(src proto.Message) { 658 | xxx_messageInfo_ImageStatusResponse.Merge(m, src) 659 | } 660 | func (m *ImageStatusResponse) XXX_Size() int { 661 | return m.Size() 662 | } 663 | func (m *ImageStatusResponse) XXX_DiscardUnknown() { 664 | xxx_messageInfo_ImageStatusResponse.DiscardUnknown(m) 665 | } 666 | 667 | var xxx_messageInfo_ImageStatusResponse proto.InternalMessageInfo 668 | 669 | func (m *ImageStatusResponse) GetImage() *v1alpha2.Image { 670 | if m != nil { 671 | return m.Image 672 | } 673 | return nil 674 | } 675 | 676 | type ImageTagRequest struct { 677 | // Spec of the image to remove. 678 | Image *v1alpha2.ImageSpec `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` 679 | Tags []string `protobuf:"bytes,2,rep,name=tags,proto3" json:"tags,omitempty"` 680 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 681 | XXX_sizecache int32 `json:"-"` 682 | } 683 | 684 | func (m *ImageTagRequest) Reset() { *m = ImageTagRequest{} } 685 | func (*ImageTagRequest) ProtoMessage() {} 686 | func (*ImageTagRequest) Descriptor() ([]byte, []int) { 687 | return fileDescriptor_51c65cb1807988f9, []int{13} 688 | } 689 | func (m *ImageTagRequest) XXX_Unmarshal(b []byte) error { 690 | return m.Unmarshal(b) 691 | } 692 | func (m *ImageTagRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 693 | if deterministic { 694 | return xxx_messageInfo_ImageTagRequest.Marshal(b, m, deterministic) 695 | } else { 696 | b = b[:cap(b)] 697 | n, err := m.MarshalToSizedBuffer(b) 698 | if err != nil { 699 | return nil, err 700 | } 701 | return b[:n], nil 702 | } 703 | } 704 | func (m *ImageTagRequest) XXX_Merge(src proto.Message) { 705 | xxx_messageInfo_ImageTagRequest.Merge(m, src) 706 | } 707 | func (m *ImageTagRequest) XXX_Size() int { 708 | return m.Size() 709 | } 710 | func (m *ImageTagRequest) XXX_DiscardUnknown() { 711 | xxx_messageInfo_ImageTagRequest.DiscardUnknown(m) 712 | } 713 | 714 | var xxx_messageInfo_ImageTagRequest proto.InternalMessageInfo 715 | 716 | func (m *ImageTagRequest) GetImage() *v1alpha2.ImageSpec { 717 | if m != nil { 718 | return m.Image 719 | } 720 | return nil 721 | } 722 | 723 | func (m *ImageTagRequest) GetTags() []string { 724 | if m != nil { 725 | return m.Tags 726 | } 727 | return nil 728 | } 729 | 730 | type ImageTagResponse struct { 731 | // Status of the image. 732 | Image *v1alpha2.Image `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` 733 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 734 | XXX_sizecache int32 `json:"-"` 735 | } 736 | 737 | func (m *ImageTagResponse) Reset() { *m = ImageTagResponse{} } 738 | func (*ImageTagResponse) ProtoMessage() {} 739 | func (*ImageTagResponse) Descriptor() ([]byte, []int) { 740 | return fileDescriptor_51c65cb1807988f9, []int{14} 741 | } 742 | func (m *ImageTagResponse) XXX_Unmarshal(b []byte) error { 743 | return m.Unmarshal(b) 744 | } 745 | func (m *ImageTagResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 746 | if deterministic { 747 | return xxx_messageInfo_ImageTagResponse.Marshal(b, m, deterministic) 748 | } else { 749 | b = b[:cap(b)] 750 | n, err := m.MarshalToSizedBuffer(b) 751 | if err != nil { 752 | return nil, err 753 | } 754 | return b[:n], nil 755 | } 756 | } 757 | func (m *ImageTagResponse) XXX_Merge(src proto.Message) { 758 | xxx_messageInfo_ImageTagResponse.Merge(m, src) 759 | } 760 | func (m *ImageTagResponse) XXX_Size() int { 761 | return m.Size() 762 | } 763 | func (m *ImageTagResponse) XXX_DiscardUnknown() { 764 | xxx_messageInfo_ImageTagResponse.DiscardUnknown(m) 765 | } 766 | 767 | var xxx_messageInfo_ImageTagResponse proto.InternalMessageInfo 768 | 769 | func (m *ImageTagResponse) GetImage() *v1alpha2.Image { 770 | if m != nil { 771 | return m.Image 772 | } 773 | return nil 774 | } 775 | 776 | func init() { 777 | proto.RegisterType((*ImageListRequest)(nil), "k3c.services.images.v1alpha1.ImageListRequest") 778 | proto.RegisterType((*ImageListResponse)(nil), "k3c.services.images.v1alpha1.ImageListResponse") 779 | proto.RegisterType((*ImagePullRequest)(nil), "k3c.services.images.v1alpha1.ImagePullRequest") 780 | proto.RegisterType((*ImagePullResponse)(nil), "k3c.services.images.v1alpha1.ImagePullResponse") 781 | proto.RegisterType((*ImagePushRequest)(nil), "k3c.services.images.v1alpha1.ImagePushRequest") 782 | proto.RegisterType((*ImagePushResponse)(nil), "k3c.services.images.v1alpha1.ImagePushResponse") 783 | proto.RegisterType((*ImageProgressRequest)(nil), "k3c.services.images.v1alpha1.ImageProgressRequest") 784 | proto.RegisterType((*ImageProgressResponse)(nil), "k3c.services.images.v1alpha1.ImageProgressResponse") 785 | proto.RegisterType((*ImageStatus)(nil), "k3c.services.images.v1alpha1.ImageStatus") 786 | proto.RegisterType((*ImageRemoveRequest)(nil), "k3c.services.images.v1alpha1.ImageRemoveRequest") 787 | proto.RegisterType((*ImageRemoveResponse)(nil), "k3c.services.images.v1alpha1.ImageRemoveResponse") 788 | proto.RegisterType((*ImageStatusRequest)(nil), "k3c.services.images.v1alpha1.ImageStatusRequest") 789 | proto.RegisterType((*ImageStatusResponse)(nil), "k3c.services.images.v1alpha1.ImageStatusResponse") 790 | proto.RegisterType((*ImageTagRequest)(nil), "k3c.services.images.v1alpha1.ImageTagRequest") 791 | proto.RegisterType((*ImageTagResponse)(nil), "k3c.services.images.v1alpha1.ImageTagResponse") 792 | } 793 | 794 | func init() { 795 | proto.RegisterFile("pkg/apis/services/images/v1alpha1/images.proto", fileDescriptor_51c65cb1807988f9) 796 | } 797 | 798 | var fileDescriptor_51c65cb1807988f9 = []byte{ 799 | // 718 bytes of a gzipped FileDescriptorProto 800 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x41, 0x4f, 0xd4, 0x4e, 801 | 0x14, 0xdf, 0xb2, 0x4b, 0xf3, 0x67, 0xf8, 0x27, 0xe2, 0x08, 0xba, 0x59, 0xb1, 0x90, 0x9e, 0x96, 802 | 0xc4, 0x9d, 0xb2, 0x25, 0x26, 0x26, 0x9e, 0x16, 0x88, 0x04, 0xe3, 0xc1, 0x54, 0x0e, 0xc6, 0x8b, 803 | 0x0e, 0xcb, 0x6c, 0xdb, 0xb0, 0x65, 0x6a, 0x67, 0x8a, 0xf1, 0xe6, 0x47, 0xe0, 0xe8, 0x47, 0xe2, 804 | 0xe8, 0xd1, 0x93, 0xca, 0xf2, 0x01, 0xfc, 0x04, 0x26, 0x66, 0x66, 0x5e, 0x97, 0xae, 0x0a, 0x16, 805 | 0x38, 0x70, 0xeb, 0x9b, 0xf9, 0xfd, 0x7e, 0xef, 0xf7, 0x76, 0xde, 0x7b, 0x59, 0x44, 0xd2, 0xfd, 806 | 0xd0, 0xa3, 0x69, 0x2c, 0x3c, 0xc1, 0xb2, 0xc3, 0xb8, 0xcf, 0x84, 0x17, 0x27, 0x34, 0x64, 0xc2, 807 | 0x3b, 0xec, 0xd2, 0x61, 0x1a, 0xd1, 0x2e, 0xc4, 0x24, 0xcd, 0xb8, 0xe4, 0x78, 0x71, 0x7f, 0xad, 808 | 0x4f, 0x0a, 0x28, 0x81, 0xab, 0x02, 0xda, 0x5a, 0x0a, 0x39, 0x0f, 0x87, 0xcc, 0xd3, 0xd8, 0xdd, 809 | 0x7c, 0xe0, 0xc9, 0x38, 0x61, 0x42, 0xd2, 0x24, 0x35, 0xf4, 0x56, 0x27, 0x8c, 0x65, 0x94, 0xef, 810 | 0x92, 0x3e, 0x4f, 0xbc, 0x90, 0x87, 0xfc, 0x0c, 0xa9, 0x22, 0x1d, 0xe8, 0x2f, 0x80, 0xfb, 0xfb, 811 | 0x8f, 0x05, 0x89, 0xb9, 0xd7, 0xcf, 0xe2, 0x0e, 0x4d, 0x63, 0x6f, 0x6c, 0x36, 0xcb, 0x0f, 0x94, 812 | 0x74, 0x61, 0xd2, 0x57, 0xa7, 0x86, 0xe3, 0x6e, 0xa3, 0xb9, 0x6d, 0x65, 0xeb, 0x79, 0x2c, 0x64, 813 | 0xc0, 0xde, 0xe5, 0x4c, 0x48, 0xfc, 0x08, 0xd9, 0x83, 0x78, 0x28, 0x59, 0xd6, 0xb4, 0x96, 0xad, 814 | 0xf6, 0xac, 0xff, 0x80, 0x80, 0x40, 0x61, 0xdd, 0x27, 0x9a, 0xf3, 0x54, 0x83, 0x02, 0x00, 0xbb, 815 | 0x9b, 0xe8, 0x76, 0x49, 0x4a, 0xa4, 0xfc, 0x40, 0x30, 0xec, 0x21, 0xdb, 0x94, 0xdd, 0xb4, 0x96, 816 | 0xeb, 0xed, 0x59, 0xff, 0xde, 0x39, 0x5a, 0x01, 0xc0, 0xdc, 0xf7, 0x60, 0xe8, 0x45, 0x3e, 0x1c, 817 | 0x16, 0x86, 0xba, 0x68, 0x5a, 0xdf, 0x82, 0x9f, 0xfb, 0xe7, 0x68, 0xbc, 0x4c, 0x59, 0x3f, 0x30, 818 | 0x48, 0xbc, 0x8a, 0x1a, 0x34, 0x97, 0x51, 0x73, 0x4a, 0x33, 0x16, 0xff, 0x64, 0xf4, 0x72, 0x19, 819 | 0x6d, 0xf0, 0x83, 0x41, 0x1c, 0x06, 0x1a, 0xe9, 0xae, 0x80, 0x7d, 0x93, 0x18, 0xec, 0xcf, 0x97, 820 | 0x33, 0xcf, 0x80, 0x78, 0xc9, 0xa3, 0x88, 0x6e, 0xc8, 0xa3, 0x4a, 0x7c, 0xa1, 0xc7, 0x87, 0x68, 821 | 0xde, 0x40, 0x33, 0x1e, 0x66, 0x4c, 0x88, 0xc2, 0xe7, 0xdf, 0xd1, 0x6f, 0xd1, 0xc2, 0x6f, 0x68, 822 | 0x10, 0xdf, 0x42, 0xb6, 0x90, 0x54, 0xe6, 0xc5, 0xfb, 0xad, 0x90, 0x8b, 0x5a, 0x1a, 0x6a, 0xd4, 823 | 0x84, 0xf5, 0xc6, 0xf1, 0xd7, 0xa5, 0x5a, 0x00, 0x74, 0xf7, 0x87, 0x85, 0x66, 0x4b, 0xb7, 0x78, 824 | 0x0e, 0xd5, 0x33, 0x36, 0x00, 0x17, 0xea, 0x13, 0xdf, 0x1d, 0xa7, 0x9a, 0xd2, 0x87, 0x10, 0xa9, 825 | 0x73, 0x3e, 0x18, 0x08, 0x26, 0x9b, 0xf5, 0x65, 0xab, 0x5d, 0x0f, 0x20, 0x52, 0x95, 0x48, 0x2e, 826 | 0xe9, 0xb0, 0xd9, 0xd0, 0xc7, 0x26, 0xc0, 0x1b, 0x08, 0x09, 0x49, 0x33, 0xc9, 0xf6, 0xde, 0x50, 827 | 0xd9, 0x9c, 0xd6, 0x3f, 0x6d, 0x8b, 0x98, 0x49, 0x23, 0xc5, 0xfc, 0x90, 0x9d, 0x62, 0xd2, 0xd6, 828 | 0xff, 0x53, 0x2e, 0x8f, 0xbe, 0x2d, 0x59, 0xc1, 0x0c, 0xf0, 0x7a, 0x52, 0x89, 0xe4, 0xe9, 0x1e, 829 | 0x05, 0x11, 0xfb, 0x32, 0x22, 0xc0, 0xeb, 0x49, 0x77, 0x0b, 0x61, 0xd3, 0xda, 0x2c, 0xe1, 0x87, 830 | 0xec, 0xea, 0x7d, 0xe2, 0x2e, 0xa0, 0x3b, 0x13, 0x42, 0xe6, 0x69, 0xc6, 0xfa, 0xe6, 0x07, 0xbd, 831 | 0x86, 0xfe, 0x26, 0xe8, 0x17, 0x42, 0xf0, 0xf4, 0x9d, 0x49, 0xa5, 0x73, 0x27, 0x17, 0x54, 0x5e, 832 | 0xa1, 0x5b, 0x3a, 0xde, 0xa1, 0xe1, 0x35, 0x66, 0x02, 0xa3, 0x86, 0xa4, 0xa1, 0x6a, 0x81, 0x7a, 833 | 0x7b, 0x26, 0xd0, 0xdf, 0x6e, 0x0f, 0xc6, 0x4d, 0x2b, 0x5f, 0xc9, 0x9c, 0xff, 0xd3, 0x46, 0xb6, 834 | 0x3e, 0x10, 0x38, 0x41, 0x36, 0xb4, 0xe0, 0x6a, 0xe5, 0x5e, 0x86, 0x82, 0x5a, 0xdd, 0x4b, 0x30, 835 | 0xc0, 0x68, 0x88, 0x1a, 0x6a, 0x21, 0x62, 0x52, 0x81, 0x5a, 0x5a, 0xc2, 0x2d, 0xaf, 0x32, 0xfe, 836 | 0x2c, 0x91, 0x5a, 0x5d, 0x95, 0x12, 0x95, 0x96, 0x6b, 0xa5, 0x44, 0x13, 0x3b, 0xf1, 0x03, 0xfa, 837 | 0x5f, 0xc5, 0xc5, 0xaa, 0xc0, 0x7e, 0x15, 0x81, 0xc9, 0x2d, 0xd4, 0x5a, 0xbb, 0x14, 0xc7, 0x24, 838 | 0x5e, 0xb5, 0x4c, 0x8d, 0x22, 0xaa, 0x58, 0xe3, 0x78, 0x39, 0x57, 0xac, 0xb1, 0xb4, 0x53, 0x75, 839 | 0x8d, 0x22, 0xba, 0x89, 0x1a, 0x13, 0x64, 0x9b, 0x41, 0xaf, 0xd4, 0x9f, 0x13, 0xcb, 0xa5, 0x52, 840 | 0x7f, 0x4e, 0x6e, 0x11, 0xbc, 0x87, 0xea, 0x3b, 0x34, 0xc4, 0x9d, 0x0a, 0xcc, 0xb3, 0xc9, 0x6e, 841 | 0x91, 0xaa, 0x70, 0x93, 0x65, 0xfd, 0xd9, 0xf1, 0x89, 0x63, 0x7d, 0x39, 0x71, 0x6a, 0x1f, 0x47, 842 | 0x8e, 0x75, 0x3c, 0x72, 0xac, 0xcf, 0x23, 0xc7, 0xfa, 0x3e, 0x72, 0xac, 0xa3, 0x53, 0xa7, 0xf6, 843 | 0xe9, 0xd4, 0xa9, 0xbd, 0x6e, 0xff, 0xf3, 0xaf, 0xd5, 0x13, 0x13, 0xef, 0xda, 0x7a, 0x01, 0xaf, 844 | 0xfd, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x96, 0x98, 0xec, 0xc4, 0x8d, 0x09, 0x00, 0x00, 845 | } 846 | 847 | // Reference imports to suppress errors if they are not otherwise used. 848 | var _ context.Context 849 | var _ grpc.ClientConn 850 | 851 | // This is a compile-time assertion to ensure that this generated file 852 | // is compatible with the grpc package it is being compiled against. 853 | const _ = grpc.SupportPackageIsVersion4 854 | 855 | // ImagesClient is the client API for Images service. 856 | // 857 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. 858 | type ImagesClient interface { 859 | // Status of an image 860 | Status(ctx context.Context, in *ImageStatusRequest, opts ...grpc.CallOption) (*ImageStatusResponse, error) 861 | // List images 862 | List(ctx context.Context, in *ImageListRequest, opts ...grpc.CallOption) (*ImageListResponse, error) 863 | // Pull an image 864 | Pull(ctx context.Context, in *ImagePullRequest, opts ...grpc.CallOption) (*ImagePullResponse, error) 865 | PullProgress(ctx context.Context, in *ImageProgressRequest, opts ...grpc.CallOption) (Images_PullProgressClient, error) 866 | // Push an image 867 | Push(ctx context.Context, in *ImagePushRequest, opts ...grpc.CallOption) (*ImagePushResponse, error) 868 | PushProgress(ctx context.Context, in *ImageProgressRequest, opts ...grpc.CallOption) (Images_PushProgressClient, error) 869 | // Remove an image 870 | Remove(ctx context.Context, in *ImageRemoveRequest, opts ...grpc.CallOption) (*ImageRemoveResponse, error) 871 | // Tag an image 872 | Tag(ctx context.Context, in *ImageTagRequest, opts ...grpc.CallOption) (*ImageTagResponse, error) 873 | } 874 | 875 | type imagesClient struct { 876 | cc *grpc.ClientConn 877 | } 878 | 879 | func NewImagesClient(cc *grpc.ClientConn) ImagesClient { 880 | return &imagesClient{cc} 881 | } 882 | 883 | func (c *imagesClient) Status(ctx context.Context, in *ImageStatusRequest, opts ...grpc.CallOption) (*ImageStatusResponse, error) { 884 | out := new(ImageStatusResponse) 885 | err := c.cc.Invoke(ctx, "/k3c.services.images.v1alpha1.Images/Status", in, out, opts...) 886 | if err != nil { 887 | return nil, err 888 | } 889 | return out, nil 890 | } 891 | 892 | func (c *imagesClient) List(ctx context.Context, in *ImageListRequest, opts ...grpc.CallOption) (*ImageListResponse, error) { 893 | out := new(ImageListResponse) 894 | err := c.cc.Invoke(ctx, "/k3c.services.images.v1alpha1.Images/List", in, out, opts...) 895 | if err != nil { 896 | return nil, err 897 | } 898 | return out, nil 899 | } 900 | 901 | func (c *imagesClient) Pull(ctx context.Context, in *ImagePullRequest, opts ...grpc.CallOption) (*ImagePullResponse, error) { 902 | out := new(ImagePullResponse) 903 | err := c.cc.Invoke(ctx, "/k3c.services.images.v1alpha1.Images/Pull", in, out, opts...) 904 | if err != nil { 905 | return nil, err 906 | } 907 | return out, nil 908 | } 909 | 910 | func (c *imagesClient) PullProgress(ctx context.Context, in *ImageProgressRequest, opts ...grpc.CallOption) (Images_PullProgressClient, error) { 911 | stream, err := c.cc.NewStream(ctx, &_Images_serviceDesc.Streams[0], "/k3c.services.images.v1alpha1.Images/PullProgress", opts...) 912 | if err != nil { 913 | return nil, err 914 | } 915 | x := &imagesPullProgressClient{stream} 916 | if err := x.ClientStream.SendMsg(in); err != nil { 917 | return nil, err 918 | } 919 | if err := x.ClientStream.CloseSend(); err != nil { 920 | return nil, err 921 | } 922 | return x, nil 923 | } 924 | 925 | type Images_PullProgressClient interface { 926 | Recv() (*ImageProgressResponse, error) 927 | grpc.ClientStream 928 | } 929 | 930 | type imagesPullProgressClient struct { 931 | grpc.ClientStream 932 | } 933 | 934 | func (x *imagesPullProgressClient) Recv() (*ImageProgressResponse, error) { 935 | m := new(ImageProgressResponse) 936 | if err := x.ClientStream.RecvMsg(m); err != nil { 937 | return nil, err 938 | } 939 | return m, nil 940 | } 941 | 942 | func (c *imagesClient) Push(ctx context.Context, in *ImagePushRequest, opts ...grpc.CallOption) (*ImagePushResponse, error) { 943 | out := new(ImagePushResponse) 944 | err := c.cc.Invoke(ctx, "/k3c.services.images.v1alpha1.Images/Push", in, out, opts...) 945 | if err != nil { 946 | return nil, err 947 | } 948 | return out, nil 949 | } 950 | 951 | func (c *imagesClient) PushProgress(ctx context.Context, in *ImageProgressRequest, opts ...grpc.CallOption) (Images_PushProgressClient, error) { 952 | stream, err := c.cc.NewStream(ctx, &_Images_serviceDesc.Streams[1], "/k3c.services.images.v1alpha1.Images/PushProgress", opts...) 953 | if err != nil { 954 | return nil, err 955 | } 956 | x := &imagesPushProgressClient{stream} 957 | if err := x.ClientStream.SendMsg(in); err != nil { 958 | return nil, err 959 | } 960 | if err := x.ClientStream.CloseSend(); err != nil { 961 | return nil, err 962 | } 963 | return x, nil 964 | } 965 | 966 | type Images_PushProgressClient interface { 967 | Recv() (*ImageProgressResponse, error) 968 | grpc.ClientStream 969 | } 970 | 971 | type imagesPushProgressClient struct { 972 | grpc.ClientStream 973 | } 974 | 975 | func (x *imagesPushProgressClient) Recv() (*ImageProgressResponse, error) { 976 | m := new(ImageProgressResponse) 977 | if err := x.ClientStream.RecvMsg(m); err != nil { 978 | return nil, err 979 | } 980 | return m, nil 981 | } 982 | 983 | func (c *imagesClient) Remove(ctx context.Context, in *ImageRemoveRequest, opts ...grpc.CallOption) (*ImageRemoveResponse, error) { 984 | out := new(ImageRemoveResponse) 985 | err := c.cc.Invoke(ctx, "/k3c.services.images.v1alpha1.Images/Remove", in, out, opts...) 986 | if err != nil { 987 | return nil, err 988 | } 989 | return out, nil 990 | } 991 | 992 | func (c *imagesClient) Tag(ctx context.Context, in *ImageTagRequest, opts ...grpc.CallOption) (*ImageTagResponse, error) { 993 | out := new(ImageTagResponse) 994 | err := c.cc.Invoke(ctx, "/k3c.services.images.v1alpha1.Images/Tag", in, out, opts...) 995 | if err != nil { 996 | return nil, err 997 | } 998 | return out, nil 999 | } 1000 | 1001 | // ImagesServer is the server API for Images service. 1002 | type ImagesServer interface { 1003 | // Status of an image 1004 | Status(context.Context, *ImageStatusRequest) (*ImageStatusResponse, error) 1005 | // List images 1006 | List(context.Context, *ImageListRequest) (*ImageListResponse, error) 1007 | // Pull an image 1008 | Pull(context.Context, *ImagePullRequest) (*ImagePullResponse, error) 1009 | PullProgress(*ImageProgressRequest, Images_PullProgressServer) error 1010 | // Push an image 1011 | Push(context.Context, *ImagePushRequest) (*ImagePushResponse, error) 1012 | PushProgress(*ImageProgressRequest, Images_PushProgressServer) error 1013 | // Remove an image 1014 | Remove(context.Context, *ImageRemoveRequest) (*ImageRemoveResponse, error) 1015 | // Tag an image 1016 | Tag(context.Context, *ImageTagRequest) (*ImageTagResponse, error) 1017 | } 1018 | 1019 | // UnimplementedImagesServer can be embedded to have forward compatible implementations. 1020 | type UnimplementedImagesServer struct { 1021 | } 1022 | 1023 | func (*UnimplementedImagesServer) Status(ctx context.Context, req *ImageStatusRequest) (*ImageStatusResponse, error) { 1024 | return nil, status.Errorf(codes.Unimplemented, "method Status not implemented") 1025 | } 1026 | func (*UnimplementedImagesServer) List(ctx context.Context, req *ImageListRequest) (*ImageListResponse, error) { 1027 | return nil, status.Errorf(codes.Unimplemented, "method List not implemented") 1028 | } 1029 | func (*UnimplementedImagesServer) Pull(ctx context.Context, req *ImagePullRequest) (*ImagePullResponse, error) { 1030 | return nil, status.Errorf(codes.Unimplemented, "method Pull not implemented") 1031 | } 1032 | func (*UnimplementedImagesServer) PullProgress(req *ImageProgressRequest, srv Images_PullProgressServer) error { 1033 | return status.Errorf(codes.Unimplemented, "method PullProgress not implemented") 1034 | } 1035 | func (*UnimplementedImagesServer) Push(ctx context.Context, req *ImagePushRequest) (*ImagePushResponse, error) { 1036 | return nil, status.Errorf(codes.Unimplemented, "method Push not implemented") 1037 | } 1038 | func (*UnimplementedImagesServer) PushProgress(req *ImageProgressRequest, srv Images_PushProgressServer) error { 1039 | return status.Errorf(codes.Unimplemented, "method PushProgress not implemented") 1040 | } 1041 | func (*UnimplementedImagesServer) Remove(ctx context.Context, req *ImageRemoveRequest) (*ImageRemoveResponse, error) { 1042 | return nil, status.Errorf(codes.Unimplemented, "method Remove not implemented") 1043 | } 1044 | func (*UnimplementedImagesServer) Tag(ctx context.Context, req *ImageTagRequest) (*ImageTagResponse, error) { 1045 | return nil, status.Errorf(codes.Unimplemented, "method Tag not implemented") 1046 | } 1047 | 1048 | func RegisterImagesServer(s *grpc.Server, srv ImagesServer) { 1049 | s.RegisterService(&_Images_serviceDesc, srv) 1050 | } 1051 | 1052 | func _Images_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1053 | in := new(ImageStatusRequest) 1054 | if err := dec(in); err != nil { 1055 | return nil, err 1056 | } 1057 | if interceptor == nil { 1058 | return srv.(ImagesServer).Status(ctx, in) 1059 | } 1060 | info := &grpc.UnaryServerInfo{ 1061 | Server: srv, 1062 | FullMethod: "/k3c.services.images.v1alpha1.Images/Status", 1063 | } 1064 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1065 | return srv.(ImagesServer).Status(ctx, req.(*ImageStatusRequest)) 1066 | } 1067 | return interceptor(ctx, in, info, handler) 1068 | } 1069 | 1070 | func _Images_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1071 | in := new(ImageListRequest) 1072 | if err := dec(in); err != nil { 1073 | return nil, err 1074 | } 1075 | if interceptor == nil { 1076 | return srv.(ImagesServer).List(ctx, in) 1077 | } 1078 | info := &grpc.UnaryServerInfo{ 1079 | Server: srv, 1080 | FullMethod: "/k3c.services.images.v1alpha1.Images/List", 1081 | } 1082 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1083 | return srv.(ImagesServer).List(ctx, req.(*ImageListRequest)) 1084 | } 1085 | return interceptor(ctx, in, info, handler) 1086 | } 1087 | 1088 | func _Images_Pull_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1089 | in := new(ImagePullRequest) 1090 | if err := dec(in); err != nil { 1091 | return nil, err 1092 | } 1093 | if interceptor == nil { 1094 | return srv.(ImagesServer).Pull(ctx, in) 1095 | } 1096 | info := &grpc.UnaryServerInfo{ 1097 | Server: srv, 1098 | FullMethod: "/k3c.services.images.v1alpha1.Images/Pull", 1099 | } 1100 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1101 | return srv.(ImagesServer).Pull(ctx, req.(*ImagePullRequest)) 1102 | } 1103 | return interceptor(ctx, in, info, handler) 1104 | } 1105 | 1106 | func _Images_PullProgress_Handler(srv interface{}, stream grpc.ServerStream) error { 1107 | m := new(ImageProgressRequest) 1108 | if err := stream.RecvMsg(m); err != nil { 1109 | return err 1110 | } 1111 | return srv.(ImagesServer).PullProgress(m, &imagesPullProgressServer{stream}) 1112 | } 1113 | 1114 | type Images_PullProgressServer interface { 1115 | Send(*ImageProgressResponse) error 1116 | grpc.ServerStream 1117 | } 1118 | 1119 | type imagesPullProgressServer struct { 1120 | grpc.ServerStream 1121 | } 1122 | 1123 | func (x *imagesPullProgressServer) Send(m *ImageProgressResponse) error { 1124 | return x.ServerStream.SendMsg(m) 1125 | } 1126 | 1127 | func _Images_Push_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1128 | in := new(ImagePushRequest) 1129 | if err := dec(in); err != nil { 1130 | return nil, err 1131 | } 1132 | if interceptor == nil { 1133 | return srv.(ImagesServer).Push(ctx, in) 1134 | } 1135 | info := &grpc.UnaryServerInfo{ 1136 | Server: srv, 1137 | FullMethod: "/k3c.services.images.v1alpha1.Images/Push", 1138 | } 1139 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1140 | return srv.(ImagesServer).Push(ctx, req.(*ImagePushRequest)) 1141 | } 1142 | return interceptor(ctx, in, info, handler) 1143 | } 1144 | 1145 | func _Images_PushProgress_Handler(srv interface{}, stream grpc.ServerStream) error { 1146 | m := new(ImageProgressRequest) 1147 | if err := stream.RecvMsg(m); err != nil { 1148 | return err 1149 | } 1150 | return srv.(ImagesServer).PushProgress(m, &imagesPushProgressServer{stream}) 1151 | } 1152 | 1153 | type Images_PushProgressServer interface { 1154 | Send(*ImageProgressResponse) error 1155 | grpc.ServerStream 1156 | } 1157 | 1158 | type imagesPushProgressServer struct { 1159 | grpc.ServerStream 1160 | } 1161 | 1162 | func (x *imagesPushProgressServer) Send(m *ImageProgressResponse) error { 1163 | return x.ServerStream.SendMsg(m) 1164 | } 1165 | 1166 | func _Images_Remove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1167 | in := new(ImageRemoveRequest) 1168 | if err := dec(in); err != nil { 1169 | return nil, err 1170 | } 1171 | if interceptor == nil { 1172 | return srv.(ImagesServer).Remove(ctx, in) 1173 | } 1174 | info := &grpc.UnaryServerInfo{ 1175 | Server: srv, 1176 | FullMethod: "/k3c.services.images.v1alpha1.Images/Remove", 1177 | } 1178 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1179 | return srv.(ImagesServer).Remove(ctx, req.(*ImageRemoveRequest)) 1180 | } 1181 | return interceptor(ctx, in, info, handler) 1182 | } 1183 | 1184 | func _Images_Tag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1185 | in := new(ImageTagRequest) 1186 | if err := dec(in); err != nil { 1187 | return nil, err 1188 | } 1189 | if interceptor == nil { 1190 | return srv.(ImagesServer).Tag(ctx, in) 1191 | } 1192 | info := &grpc.UnaryServerInfo{ 1193 | Server: srv, 1194 | FullMethod: "/k3c.services.images.v1alpha1.Images/Tag", 1195 | } 1196 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1197 | return srv.(ImagesServer).Tag(ctx, req.(*ImageTagRequest)) 1198 | } 1199 | return interceptor(ctx, in, info, handler) 1200 | } 1201 | 1202 | var _Images_serviceDesc = grpc.ServiceDesc{ 1203 | ServiceName: "k3c.services.images.v1alpha1.Images", 1204 | HandlerType: (*ImagesServer)(nil), 1205 | Methods: []grpc.MethodDesc{ 1206 | { 1207 | MethodName: "Status", 1208 | Handler: _Images_Status_Handler, 1209 | }, 1210 | { 1211 | MethodName: "List", 1212 | Handler: _Images_List_Handler, 1213 | }, 1214 | { 1215 | MethodName: "Pull", 1216 | Handler: _Images_Pull_Handler, 1217 | }, 1218 | { 1219 | MethodName: "Push", 1220 | Handler: _Images_Push_Handler, 1221 | }, 1222 | { 1223 | MethodName: "Remove", 1224 | Handler: _Images_Remove_Handler, 1225 | }, 1226 | { 1227 | MethodName: "Tag", 1228 | Handler: _Images_Tag_Handler, 1229 | }, 1230 | }, 1231 | Streams: []grpc.StreamDesc{ 1232 | { 1233 | StreamName: "PullProgress", 1234 | Handler: _Images_PullProgress_Handler, 1235 | ServerStreams: true, 1236 | }, 1237 | { 1238 | StreamName: "PushProgress", 1239 | Handler: _Images_PushProgress_Handler, 1240 | ServerStreams: true, 1241 | }, 1242 | }, 1243 | Metadata: "pkg/apis/services/images/v1alpha1/images.proto", 1244 | } 1245 | 1246 | func (m *ImageListRequest) Marshal() (dAtA []byte, err error) { 1247 | size := m.Size() 1248 | dAtA = make([]byte, size) 1249 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1250 | if err != nil { 1251 | return nil, err 1252 | } 1253 | return dAtA[:n], nil 1254 | } 1255 | 1256 | func (m *ImageListRequest) MarshalTo(dAtA []byte) (int, error) { 1257 | size := m.Size() 1258 | return m.MarshalToSizedBuffer(dAtA[:size]) 1259 | } 1260 | 1261 | func (m *ImageListRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1262 | i := len(dAtA) 1263 | _ = i 1264 | var l int 1265 | _ = l 1266 | if m.Filter != nil { 1267 | { 1268 | size, err := m.Filter.MarshalToSizedBuffer(dAtA[:i]) 1269 | if err != nil { 1270 | return 0, err 1271 | } 1272 | i -= size 1273 | i = encodeVarintImages(dAtA, i, uint64(size)) 1274 | } 1275 | i-- 1276 | dAtA[i] = 0xa 1277 | } 1278 | return len(dAtA) - i, nil 1279 | } 1280 | 1281 | func (m *ImageListResponse) Marshal() (dAtA []byte, err error) { 1282 | size := m.Size() 1283 | dAtA = make([]byte, size) 1284 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1285 | if err != nil { 1286 | return nil, err 1287 | } 1288 | return dAtA[:n], nil 1289 | } 1290 | 1291 | func (m *ImageListResponse) MarshalTo(dAtA []byte) (int, error) { 1292 | size := m.Size() 1293 | return m.MarshalToSizedBuffer(dAtA[:size]) 1294 | } 1295 | 1296 | func (m *ImageListResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1297 | i := len(dAtA) 1298 | _ = i 1299 | var l int 1300 | _ = l 1301 | if len(m.Images) > 0 { 1302 | for iNdEx := len(m.Images) - 1; iNdEx >= 0; iNdEx-- { 1303 | { 1304 | size, err := m.Images[iNdEx].MarshalToSizedBuffer(dAtA[:i]) 1305 | if err != nil { 1306 | return 0, err 1307 | } 1308 | i -= size 1309 | i = encodeVarintImages(dAtA, i, uint64(size)) 1310 | } 1311 | i-- 1312 | dAtA[i] = 0xa 1313 | } 1314 | } 1315 | return len(dAtA) - i, nil 1316 | } 1317 | 1318 | func (m *ImagePullRequest) Marshal() (dAtA []byte, err error) { 1319 | size := m.Size() 1320 | dAtA = make([]byte, size) 1321 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1322 | if err != nil { 1323 | return nil, err 1324 | } 1325 | return dAtA[:n], nil 1326 | } 1327 | 1328 | func (m *ImagePullRequest) MarshalTo(dAtA []byte) (int, error) { 1329 | size := m.Size() 1330 | return m.MarshalToSizedBuffer(dAtA[:size]) 1331 | } 1332 | 1333 | func (m *ImagePullRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1334 | i := len(dAtA) 1335 | _ = i 1336 | var l int 1337 | _ = l 1338 | if m.Auth != nil { 1339 | { 1340 | size, err := m.Auth.MarshalToSizedBuffer(dAtA[:i]) 1341 | if err != nil { 1342 | return 0, err 1343 | } 1344 | i -= size 1345 | i = encodeVarintImages(dAtA, i, uint64(size)) 1346 | } 1347 | i-- 1348 | dAtA[i] = 0x12 1349 | } 1350 | if m.Image != nil { 1351 | { 1352 | size, err := m.Image.MarshalToSizedBuffer(dAtA[:i]) 1353 | if err != nil { 1354 | return 0, err 1355 | } 1356 | i -= size 1357 | i = encodeVarintImages(dAtA, i, uint64(size)) 1358 | } 1359 | i-- 1360 | dAtA[i] = 0xa 1361 | } 1362 | return len(dAtA) - i, nil 1363 | } 1364 | 1365 | func (m *ImagePullResponse) Marshal() (dAtA []byte, err error) { 1366 | size := m.Size() 1367 | dAtA = make([]byte, size) 1368 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1369 | if err != nil { 1370 | return nil, err 1371 | } 1372 | return dAtA[:n], nil 1373 | } 1374 | 1375 | func (m *ImagePullResponse) MarshalTo(dAtA []byte) (int, error) { 1376 | size := m.Size() 1377 | return m.MarshalToSizedBuffer(dAtA[:size]) 1378 | } 1379 | 1380 | func (m *ImagePullResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1381 | i := len(dAtA) 1382 | _ = i 1383 | var l int 1384 | _ = l 1385 | if len(m.Image) > 0 { 1386 | i -= len(m.Image) 1387 | copy(dAtA[i:], m.Image) 1388 | i = encodeVarintImages(dAtA, i, uint64(len(m.Image))) 1389 | i-- 1390 | dAtA[i] = 0xa 1391 | } 1392 | return len(dAtA) - i, nil 1393 | } 1394 | 1395 | func (m *ImagePushRequest) Marshal() (dAtA []byte, err error) { 1396 | size := m.Size() 1397 | dAtA = make([]byte, size) 1398 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1399 | if err != nil { 1400 | return nil, err 1401 | } 1402 | return dAtA[:n], nil 1403 | } 1404 | 1405 | func (m *ImagePushRequest) MarshalTo(dAtA []byte) (int, error) { 1406 | size := m.Size() 1407 | return m.MarshalToSizedBuffer(dAtA[:size]) 1408 | } 1409 | 1410 | func (m *ImagePushRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1411 | i := len(dAtA) 1412 | _ = i 1413 | var l int 1414 | _ = l 1415 | if m.Auth != nil { 1416 | { 1417 | size, err := m.Auth.MarshalToSizedBuffer(dAtA[:i]) 1418 | if err != nil { 1419 | return 0, err 1420 | } 1421 | i -= size 1422 | i = encodeVarintImages(dAtA, i, uint64(size)) 1423 | } 1424 | i-- 1425 | dAtA[i] = 0x12 1426 | } 1427 | if m.Image != nil { 1428 | { 1429 | size, err := m.Image.MarshalToSizedBuffer(dAtA[:i]) 1430 | if err != nil { 1431 | return 0, err 1432 | } 1433 | i -= size 1434 | i = encodeVarintImages(dAtA, i, uint64(size)) 1435 | } 1436 | i-- 1437 | dAtA[i] = 0xa 1438 | } 1439 | return len(dAtA) - i, nil 1440 | } 1441 | 1442 | func (m *ImagePushResponse) Marshal() (dAtA []byte, err error) { 1443 | size := m.Size() 1444 | dAtA = make([]byte, size) 1445 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1446 | if err != nil { 1447 | return nil, err 1448 | } 1449 | return dAtA[:n], nil 1450 | } 1451 | 1452 | func (m *ImagePushResponse) MarshalTo(dAtA []byte) (int, error) { 1453 | size := m.Size() 1454 | return m.MarshalToSizedBuffer(dAtA[:size]) 1455 | } 1456 | 1457 | func (m *ImagePushResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1458 | i := len(dAtA) 1459 | _ = i 1460 | var l int 1461 | _ = l 1462 | if len(m.Image) > 0 { 1463 | i -= len(m.Image) 1464 | copy(dAtA[i:], m.Image) 1465 | i = encodeVarintImages(dAtA, i, uint64(len(m.Image))) 1466 | i-- 1467 | dAtA[i] = 0xa 1468 | } 1469 | return len(dAtA) - i, nil 1470 | } 1471 | 1472 | func (m *ImageProgressRequest) Marshal() (dAtA []byte, err error) { 1473 | size := m.Size() 1474 | dAtA = make([]byte, size) 1475 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1476 | if err != nil { 1477 | return nil, err 1478 | } 1479 | return dAtA[:n], nil 1480 | } 1481 | 1482 | func (m *ImageProgressRequest) MarshalTo(dAtA []byte) (int, error) { 1483 | size := m.Size() 1484 | return m.MarshalToSizedBuffer(dAtA[:size]) 1485 | } 1486 | 1487 | func (m *ImageProgressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1488 | i := len(dAtA) 1489 | _ = i 1490 | var l int 1491 | _ = l 1492 | if len(m.Image) > 0 { 1493 | i -= len(m.Image) 1494 | copy(dAtA[i:], m.Image) 1495 | i = encodeVarintImages(dAtA, i, uint64(len(m.Image))) 1496 | i-- 1497 | dAtA[i] = 0xa 1498 | } 1499 | return len(dAtA) - i, nil 1500 | } 1501 | 1502 | func (m *ImageProgressResponse) Marshal() (dAtA []byte, err error) { 1503 | size := m.Size() 1504 | dAtA = make([]byte, size) 1505 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1506 | if err != nil { 1507 | return nil, err 1508 | } 1509 | return dAtA[:n], nil 1510 | } 1511 | 1512 | func (m *ImageProgressResponse) MarshalTo(dAtA []byte) (int, error) { 1513 | size := m.Size() 1514 | return m.MarshalToSizedBuffer(dAtA[:size]) 1515 | } 1516 | 1517 | func (m *ImageProgressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1518 | i := len(dAtA) 1519 | _ = i 1520 | var l int 1521 | _ = l 1522 | if len(m.Status) > 0 { 1523 | for iNdEx := len(m.Status) - 1; iNdEx >= 0; iNdEx-- { 1524 | { 1525 | size, err := m.Status[iNdEx].MarshalToSizedBuffer(dAtA[:i]) 1526 | if err != nil { 1527 | return 0, err 1528 | } 1529 | i -= size 1530 | i = encodeVarintImages(dAtA, i, uint64(size)) 1531 | } 1532 | i-- 1533 | dAtA[i] = 0xa 1534 | } 1535 | } 1536 | return len(dAtA) - i, nil 1537 | } 1538 | 1539 | func (m *ImageStatus) Marshal() (dAtA []byte, err error) { 1540 | size := m.Size() 1541 | dAtA = make([]byte, size) 1542 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1543 | if err != nil { 1544 | return nil, err 1545 | } 1546 | return dAtA[:n], nil 1547 | } 1548 | 1549 | func (m *ImageStatus) MarshalTo(dAtA []byte) (int, error) { 1550 | size := m.Size() 1551 | return m.MarshalToSizedBuffer(dAtA[:size]) 1552 | } 1553 | 1554 | func (m *ImageStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1555 | i := len(dAtA) 1556 | _ = i 1557 | var l int 1558 | _ = l 1559 | n6, err6 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt):]) 1560 | if err6 != nil { 1561 | return 0, err6 1562 | } 1563 | i -= n6 1564 | i = encodeVarintImages(dAtA, i, uint64(n6)) 1565 | i-- 1566 | dAtA[i] = 0x32 1567 | n7, err7 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartedAt, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartedAt):]) 1568 | if err7 != nil { 1569 | return 0, err7 1570 | } 1571 | i -= n7 1572 | i = encodeVarintImages(dAtA, i, uint64(n7)) 1573 | i-- 1574 | dAtA[i] = 0x2a 1575 | if m.Total != 0 { 1576 | i = encodeVarintImages(dAtA, i, uint64(m.Total)) 1577 | i-- 1578 | dAtA[i] = 0x20 1579 | } 1580 | if m.Offset != 0 { 1581 | i = encodeVarintImages(dAtA, i, uint64(m.Offset)) 1582 | i-- 1583 | dAtA[i] = 0x18 1584 | } 1585 | if len(m.Status) > 0 { 1586 | i -= len(m.Status) 1587 | copy(dAtA[i:], m.Status) 1588 | i = encodeVarintImages(dAtA, i, uint64(len(m.Status))) 1589 | i-- 1590 | dAtA[i] = 0x12 1591 | } 1592 | if len(m.Ref) > 0 { 1593 | i -= len(m.Ref) 1594 | copy(dAtA[i:], m.Ref) 1595 | i = encodeVarintImages(dAtA, i, uint64(len(m.Ref))) 1596 | i-- 1597 | dAtA[i] = 0xa 1598 | } 1599 | return len(dAtA) - i, nil 1600 | } 1601 | 1602 | func (m *ImageRemoveRequest) Marshal() (dAtA []byte, err error) { 1603 | size := m.Size() 1604 | dAtA = make([]byte, size) 1605 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1606 | if err != nil { 1607 | return nil, err 1608 | } 1609 | return dAtA[:n], nil 1610 | } 1611 | 1612 | func (m *ImageRemoveRequest) MarshalTo(dAtA []byte) (int, error) { 1613 | size := m.Size() 1614 | return m.MarshalToSizedBuffer(dAtA[:size]) 1615 | } 1616 | 1617 | func (m *ImageRemoveRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1618 | i := len(dAtA) 1619 | _ = i 1620 | var l int 1621 | _ = l 1622 | if m.Image != nil { 1623 | { 1624 | size, err := m.Image.MarshalToSizedBuffer(dAtA[:i]) 1625 | if err != nil { 1626 | return 0, err 1627 | } 1628 | i -= size 1629 | i = encodeVarintImages(dAtA, i, uint64(size)) 1630 | } 1631 | i-- 1632 | dAtA[i] = 0xa 1633 | } 1634 | return len(dAtA) - i, nil 1635 | } 1636 | 1637 | func (m *ImageRemoveResponse) Marshal() (dAtA []byte, err error) { 1638 | size := m.Size() 1639 | dAtA = make([]byte, size) 1640 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1641 | if err != nil { 1642 | return nil, err 1643 | } 1644 | return dAtA[:n], nil 1645 | } 1646 | 1647 | func (m *ImageRemoveResponse) MarshalTo(dAtA []byte) (int, error) { 1648 | size := m.Size() 1649 | return m.MarshalToSizedBuffer(dAtA[:size]) 1650 | } 1651 | 1652 | func (m *ImageRemoveResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1653 | i := len(dAtA) 1654 | _ = i 1655 | var l int 1656 | _ = l 1657 | return len(dAtA) - i, nil 1658 | } 1659 | 1660 | func (m *ImageStatusRequest) Marshal() (dAtA []byte, err error) { 1661 | size := m.Size() 1662 | dAtA = make([]byte, size) 1663 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1664 | if err != nil { 1665 | return nil, err 1666 | } 1667 | return dAtA[:n], nil 1668 | } 1669 | 1670 | func (m *ImageStatusRequest) MarshalTo(dAtA []byte) (int, error) { 1671 | size := m.Size() 1672 | return m.MarshalToSizedBuffer(dAtA[:size]) 1673 | } 1674 | 1675 | func (m *ImageStatusRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1676 | i := len(dAtA) 1677 | _ = i 1678 | var l int 1679 | _ = l 1680 | if m.Image != nil { 1681 | { 1682 | size, err := m.Image.MarshalToSizedBuffer(dAtA[:i]) 1683 | if err != nil { 1684 | return 0, err 1685 | } 1686 | i -= size 1687 | i = encodeVarintImages(dAtA, i, uint64(size)) 1688 | } 1689 | i-- 1690 | dAtA[i] = 0xa 1691 | } 1692 | return len(dAtA) - i, nil 1693 | } 1694 | 1695 | func (m *ImageStatusResponse) Marshal() (dAtA []byte, err error) { 1696 | size := m.Size() 1697 | dAtA = make([]byte, size) 1698 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1699 | if err != nil { 1700 | return nil, err 1701 | } 1702 | return dAtA[:n], nil 1703 | } 1704 | 1705 | func (m *ImageStatusResponse) MarshalTo(dAtA []byte) (int, error) { 1706 | size := m.Size() 1707 | return m.MarshalToSizedBuffer(dAtA[:size]) 1708 | } 1709 | 1710 | func (m *ImageStatusResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1711 | i := len(dAtA) 1712 | _ = i 1713 | var l int 1714 | _ = l 1715 | if m.Image != nil { 1716 | { 1717 | size, err := m.Image.MarshalToSizedBuffer(dAtA[:i]) 1718 | if err != nil { 1719 | return 0, err 1720 | } 1721 | i -= size 1722 | i = encodeVarintImages(dAtA, i, uint64(size)) 1723 | } 1724 | i-- 1725 | dAtA[i] = 0xa 1726 | } 1727 | return len(dAtA) - i, nil 1728 | } 1729 | 1730 | func (m *ImageTagRequest) Marshal() (dAtA []byte, err error) { 1731 | size := m.Size() 1732 | dAtA = make([]byte, size) 1733 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1734 | if err != nil { 1735 | return nil, err 1736 | } 1737 | return dAtA[:n], nil 1738 | } 1739 | 1740 | func (m *ImageTagRequest) MarshalTo(dAtA []byte) (int, error) { 1741 | size := m.Size() 1742 | return m.MarshalToSizedBuffer(dAtA[:size]) 1743 | } 1744 | 1745 | func (m *ImageTagRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1746 | i := len(dAtA) 1747 | _ = i 1748 | var l int 1749 | _ = l 1750 | if len(m.Tags) > 0 { 1751 | for iNdEx := len(m.Tags) - 1; iNdEx >= 0; iNdEx-- { 1752 | i -= len(m.Tags[iNdEx]) 1753 | copy(dAtA[i:], m.Tags[iNdEx]) 1754 | i = encodeVarintImages(dAtA, i, uint64(len(m.Tags[iNdEx]))) 1755 | i-- 1756 | dAtA[i] = 0x12 1757 | } 1758 | } 1759 | if m.Image != nil { 1760 | { 1761 | size, err := m.Image.MarshalToSizedBuffer(dAtA[:i]) 1762 | if err != nil { 1763 | return 0, err 1764 | } 1765 | i -= size 1766 | i = encodeVarintImages(dAtA, i, uint64(size)) 1767 | } 1768 | i-- 1769 | dAtA[i] = 0xa 1770 | } 1771 | return len(dAtA) - i, nil 1772 | } 1773 | 1774 | func (m *ImageTagResponse) Marshal() (dAtA []byte, err error) { 1775 | size := m.Size() 1776 | dAtA = make([]byte, size) 1777 | n, err := m.MarshalToSizedBuffer(dAtA[:size]) 1778 | if err != nil { 1779 | return nil, err 1780 | } 1781 | return dAtA[:n], nil 1782 | } 1783 | 1784 | func (m *ImageTagResponse) MarshalTo(dAtA []byte) (int, error) { 1785 | size := m.Size() 1786 | return m.MarshalToSizedBuffer(dAtA[:size]) 1787 | } 1788 | 1789 | func (m *ImageTagResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { 1790 | i := len(dAtA) 1791 | _ = i 1792 | var l int 1793 | _ = l 1794 | if m.Image != nil { 1795 | { 1796 | size, err := m.Image.MarshalToSizedBuffer(dAtA[:i]) 1797 | if err != nil { 1798 | return 0, err 1799 | } 1800 | i -= size 1801 | i = encodeVarintImages(dAtA, i, uint64(size)) 1802 | } 1803 | i-- 1804 | dAtA[i] = 0xa 1805 | } 1806 | return len(dAtA) - i, nil 1807 | } 1808 | 1809 | func encodeVarintImages(dAtA []byte, offset int, v uint64) int { 1810 | offset -= sovImages(v) 1811 | base := offset 1812 | for v >= 1<<7 { 1813 | dAtA[offset] = uint8(v&0x7f | 0x80) 1814 | v >>= 7 1815 | offset++ 1816 | } 1817 | dAtA[offset] = uint8(v) 1818 | return base 1819 | } 1820 | func (m *ImageListRequest) Size() (n int) { 1821 | if m == nil { 1822 | return 0 1823 | } 1824 | var l int 1825 | _ = l 1826 | if m.Filter != nil { 1827 | l = m.Filter.Size() 1828 | n += 1 + l + sovImages(uint64(l)) 1829 | } 1830 | return n 1831 | } 1832 | 1833 | func (m *ImageListResponse) Size() (n int) { 1834 | if m == nil { 1835 | return 0 1836 | } 1837 | var l int 1838 | _ = l 1839 | if len(m.Images) > 0 { 1840 | for _, e := range m.Images { 1841 | l = e.Size() 1842 | n += 1 + l + sovImages(uint64(l)) 1843 | } 1844 | } 1845 | return n 1846 | } 1847 | 1848 | func (m *ImagePullRequest) Size() (n int) { 1849 | if m == nil { 1850 | return 0 1851 | } 1852 | var l int 1853 | _ = l 1854 | if m.Image != nil { 1855 | l = m.Image.Size() 1856 | n += 1 + l + sovImages(uint64(l)) 1857 | } 1858 | if m.Auth != nil { 1859 | l = m.Auth.Size() 1860 | n += 1 + l + sovImages(uint64(l)) 1861 | } 1862 | return n 1863 | } 1864 | 1865 | func (m *ImagePullResponse) Size() (n int) { 1866 | if m == nil { 1867 | return 0 1868 | } 1869 | var l int 1870 | _ = l 1871 | l = len(m.Image) 1872 | if l > 0 { 1873 | n += 1 + l + sovImages(uint64(l)) 1874 | } 1875 | return n 1876 | } 1877 | 1878 | func (m *ImagePushRequest) Size() (n int) { 1879 | if m == nil { 1880 | return 0 1881 | } 1882 | var l int 1883 | _ = l 1884 | if m.Image != nil { 1885 | l = m.Image.Size() 1886 | n += 1 + l + sovImages(uint64(l)) 1887 | } 1888 | if m.Auth != nil { 1889 | l = m.Auth.Size() 1890 | n += 1 + l + sovImages(uint64(l)) 1891 | } 1892 | return n 1893 | } 1894 | 1895 | func (m *ImagePushResponse) Size() (n int) { 1896 | if m == nil { 1897 | return 0 1898 | } 1899 | var l int 1900 | _ = l 1901 | l = len(m.Image) 1902 | if l > 0 { 1903 | n += 1 + l + sovImages(uint64(l)) 1904 | } 1905 | return n 1906 | } 1907 | 1908 | func (m *ImageProgressRequest) Size() (n int) { 1909 | if m == nil { 1910 | return 0 1911 | } 1912 | var l int 1913 | _ = l 1914 | l = len(m.Image) 1915 | if l > 0 { 1916 | n += 1 + l + sovImages(uint64(l)) 1917 | } 1918 | return n 1919 | } 1920 | 1921 | func (m *ImageProgressResponse) Size() (n int) { 1922 | if m == nil { 1923 | return 0 1924 | } 1925 | var l int 1926 | _ = l 1927 | if len(m.Status) > 0 { 1928 | for _, e := range m.Status { 1929 | l = e.Size() 1930 | n += 1 + l + sovImages(uint64(l)) 1931 | } 1932 | } 1933 | return n 1934 | } 1935 | 1936 | func (m *ImageStatus) Size() (n int) { 1937 | if m == nil { 1938 | return 0 1939 | } 1940 | var l int 1941 | _ = l 1942 | l = len(m.Ref) 1943 | if l > 0 { 1944 | n += 1 + l + sovImages(uint64(l)) 1945 | } 1946 | l = len(m.Status) 1947 | if l > 0 { 1948 | n += 1 + l + sovImages(uint64(l)) 1949 | } 1950 | if m.Offset != 0 { 1951 | n += 1 + sovImages(uint64(m.Offset)) 1952 | } 1953 | if m.Total != 0 { 1954 | n += 1 + sovImages(uint64(m.Total)) 1955 | } 1956 | l = github_com_gogo_protobuf_types.SizeOfStdTime(m.StartedAt) 1957 | n += 1 + l + sovImages(uint64(l)) 1958 | l = github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt) 1959 | n += 1 + l + sovImages(uint64(l)) 1960 | return n 1961 | } 1962 | 1963 | func (m *ImageRemoveRequest) Size() (n int) { 1964 | if m == nil { 1965 | return 0 1966 | } 1967 | var l int 1968 | _ = l 1969 | if m.Image != nil { 1970 | l = m.Image.Size() 1971 | n += 1 + l + sovImages(uint64(l)) 1972 | } 1973 | return n 1974 | } 1975 | 1976 | func (m *ImageRemoveResponse) Size() (n int) { 1977 | if m == nil { 1978 | return 0 1979 | } 1980 | var l int 1981 | _ = l 1982 | return n 1983 | } 1984 | 1985 | func (m *ImageStatusRequest) Size() (n int) { 1986 | if m == nil { 1987 | return 0 1988 | } 1989 | var l int 1990 | _ = l 1991 | if m.Image != nil { 1992 | l = m.Image.Size() 1993 | n += 1 + l + sovImages(uint64(l)) 1994 | } 1995 | return n 1996 | } 1997 | 1998 | func (m *ImageStatusResponse) Size() (n int) { 1999 | if m == nil { 2000 | return 0 2001 | } 2002 | var l int 2003 | _ = l 2004 | if m.Image != nil { 2005 | l = m.Image.Size() 2006 | n += 1 + l + sovImages(uint64(l)) 2007 | } 2008 | return n 2009 | } 2010 | 2011 | func (m *ImageTagRequest) Size() (n int) { 2012 | if m == nil { 2013 | return 0 2014 | } 2015 | var l int 2016 | _ = l 2017 | if m.Image != nil { 2018 | l = m.Image.Size() 2019 | n += 1 + l + sovImages(uint64(l)) 2020 | } 2021 | if len(m.Tags) > 0 { 2022 | for _, s := range m.Tags { 2023 | l = len(s) 2024 | n += 1 + l + sovImages(uint64(l)) 2025 | } 2026 | } 2027 | return n 2028 | } 2029 | 2030 | func (m *ImageTagResponse) Size() (n int) { 2031 | if m == nil { 2032 | return 0 2033 | } 2034 | var l int 2035 | _ = l 2036 | if m.Image != nil { 2037 | l = m.Image.Size() 2038 | n += 1 + l + sovImages(uint64(l)) 2039 | } 2040 | return n 2041 | } 2042 | 2043 | func sovImages(x uint64) (n int) { 2044 | return (math_bits.Len64(x|1) + 6) / 7 2045 | } 2046 | func sozImages(x uint64) (n int) { 2047 | return sovImages(uint64((x << 1) ^ uint64((int64(x) >> 63)))) 2048 | } 2049 | func (this *ImageListRequest) String() string { 2050 | if this == nil { 2051 | return "nil" 2052 | } 2053 | s := strings.Join([]string{`&ImageListRequest{`, 2054 | `Filter:` + strings.Replace(fmt.Sprintf("%v", this.Filter), "ImageFilter", "v1alpha2.ImageFilter", 1) + `,`, 2055 | `}`, 2056 | }, "") 2057 | return s 2058 | } 2059 | func (this *ImageListResponse) String() string { 2060 | if this == nil { 2061 | return "nil" 2062 | } 2063 | repeatedStringForImages := "[]*Image{" 2064 | for _, f := range this.Images { 2065 | repeatedStringForImages += strings.Replace(fmt.Sprintf("%v", f), "Image", "v1alpha2.Image", 1) + "," 2066 | } 2067 | repeatedStringForImages += "}" 2068 | s := strings.Join([]string{`&ImageListResponse{`, 2069 | `Images:` + repeatedStringForImages + `,`, 2070 | `}`, 2071 | }, "") 2072 | return s 2073 | } 2074 | func (this *ImagePullRequest) String() string { 2075 | if this == nil { 2076 | return "nil" 2077 | } 2078 | s := strings.Join([]string{`&ImagePullRequest{`, 2079 | `Image:` + strings.Replace(fmt.Sprintf("%v", this.Image), "ImageSpec", "v1alpha2.ImageSpec", 1) + `,`, 2080 | `Auth:` + strings.Replace(fmt.Sprintf("%v", this.Auth), "AuthConfig", "v1alpha2.AuthConfig", 1) + `,`, 2081 | `}`, 2082 | }, "") 2083 | return s 2084 | } 2085 | func (this *ImagePullResponse) String() string { 2086 | if this == nil { 2087 | return "nil" 2088 | } 2089 | s := strings.Join([]string{`&ImagePullResponse{`, 2090 | `Image:` + fmt.Sprintf("%v", this.Image) + `,`, 2091 | `}`, 2092 | }, "") 2093 | return s 2094 | } 2095 | func (this *ImagePushRequest) String() string { 2096 | if this == nil { 2097 | return "nil" 2098 | } 2099 | s := strings.Join([]string{`&ImagePushRequest{`, 2100 | `Image:` + strings.Replace(fmt.Sprintf("%v", this.Image), "ImageSpec", "v1alpha2.ImageSpec", 1) + `,`, 2101 | `Auth:` + strings.Replace(fmt.Sprintf("%v", this.Auth), "AuthConfig", "v1alpha2.AuthConfig", 1) + `,`, 2102 | `}`, 2103 | }, "") 2104 | return s 2105 | } 2106 | func (this *ImagePushResponse) String() string { 2107 | if this == nil { 2108 | return "nil" 2109 | } 2110 | s := strings.Join([]string{`&ImagePushResponse{`, 2111 | `Image:` + fmt.Sprintf("%v", this.Image) + `,`, 2112 | `}`, 2113 | }, "") 2114 | return s 2115 | } 2116 | func (this *ImageProgressRequest) String() string { 2117 | if this == nil { 2118 | return "nil" 2119 | } 2120 | s := strings.Join([]string{`&ImageProgressRequest{`, 2121 | `Image:` + fmt.Sprintf("%v", this.Image) + `,`, 2122 | `}`, 2123 | }, "") 2124 | return s 2125 | } 2126 | func (this *ImageProgressResponse) String() string { 2127 | if this == nil { 2128 | return "nil" 2129 | } 2130 | repeatedStringForStatus := "[]ImageStatus{" 2131 | for _, f := range this.Status { 2132 | repeatedStringForStatus += strings.Replace(strings.Replace(f.String(), "ImageStatus", "ImageStatus", 1), `&`, ``, 1) + "," 2133 | } 2134 | repeatedStringForStatus += "}" 2135 | s := strings.Join([]string{`&ImageProgressResponse{`, 2136 | `Status:` + repeatedStringForStatus + `,`, 2137 | `}`, 2138 | }, "") 2139 | return s 2140 | } 2141 | func (this *ImageStatus) String() string { 2142 | if this == nil { 2143 | return "nil" 2144 | } 2145 | s := strings.Join([]string{`&ImageStatus{`, 2146 | `Ref:` + fmt.Sprintf("%v", this.Ref) + `,`, 2147 | `Status:` + fmt.Sprintf("%v", this.Status) + `,`, 2148 | `Offset:` + fmt.Sprintf("%v", this.Offset) + `,`, 2149 | `Total:` + fmt.Sprintf("%v", this.Total) + `,`, 2150 | `StartedAt:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.StartedAt), "Timestamp", "timestamp.Timestamp", 1), `&`, ``, 1) + `,`, 2151 | `UpdatedAt:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.UpdatedAt), "Timestamp", "timestamp.Timestamp", 1), `&`, ``, 1) + `,`, 2152 | `}`, 2153 | }, "") 2154 | return s 2155 | } 2156 | func (this *ImageRemoveRequest) String() string { 2157 | if this == nil { 2158 | return "nil" 2159 | } 2160 | s := strings.Join([]string{`&ImageRemoveRequest{`, 2161 | `Image:` + strings.Replace(fmt.Sprintf("%v", this.Image), "ImageSpec", "v1alpha2.ImageSpec", 1) + `,`, 2162 | `}`, 2163 | }, "") 2164 | return s 2165 | } 2166 | func (this *ImageRemoveResponse) String() string { 2167 | if this == nil { 2168 | return "nil" 2169 | } 2170 | s := strings.Join([]string{`&ImageRemoveResponse{`, 2171 | `}`, 2172 | }, "") 2173 | return s 2174 | } 2175 | func (this *ImageStatusRequest) String() string { 2176 | if this == nil { 2177 | return "nil" 2178 | } 2179 | s := strings.Join([]string{`&ImageStatusRequest{`, 2180 | `Image:` + strings.Replace(fmt.Sprintf("%v", this.Image), "ImageSpec", "v1alpha2.ImageSpec", 1) + `,`, 2181 | `}`, 2182 | }, "") 2183 | return s 2184 | } 2185 | func (this *ImageStatusResponse) String() string { 2186 | if this == nil { 2187 | return "nil" 2188 | } 2189 | s := strings.Join([]string{`&ImageStatusResponse{`, 2190 | `Image:` + strings.Replace(fmt.Sprintf("%v", this.Image), "Image", "v1alpha2.Image", 1) + `,`, 2191 | `}`, 2192 | }, "") 2193 | return s 2194 | } 2195 | func (this *ImageTagRequest) String() string { 2196 | if this == nil { 2197 | return "nil" 2198 | } 2199 | s := strings.Join([]string{`&ImageTagRequest{`, 2200 | `Image:` + strings.Replace(fmt.Sprintf("%v", this.Image), "ImageSpec", "v1alpha2.ImageSpec", 1) + `,`, 2201 | `Tags:` + fmt.Sprintf("%v", this.Tags) + `,`, 2202 | `}`, 2203 | }, "") 2204 | return s 2205 | } 2206 | func (this *ImageTagResponse) String() string { 2207 | if this == nil { 2208 | return "nil" 2209 | } 2210 | s := strings.Join([]string{`&ImageTagResponse{`, 2211 | `Image:` + strings.Replace(fmt.Sprintf("%v", this.Image), "Image", "v1alpha2.Image", 1) + `,`, 2212 | `}`, 2213 | }, "") 2214 | return s 2215 | } 2216 | func valueToStringImages(v interface{}) string { 2217 | rv := reflect.ValueOf(v) 2218 | if rv.IsNil() { 2219 | return "nil" 2220 | } 2221 | pv := reflect.Indirect(rv).Interface() 2222 | return fmt.Sprintf("*%v", pv) 2223 | } 2224 | func (m *ImageListRequest) Unmarshal(dAtA []byte) error { 2225 | l := len(dAtA) 2226 | iNdEx := 0 2227 | for iNdEx < l { 2228 | preIndex := iNdEx 2229 | var wire uint64 2230 | for shift := uint(0); ; shift += 7 { 2231 | if shift >= 64 { 2232 | return ErrIntOverflowImages 2233 | } 2234 | if iNdEx >= l { 2235 | return io.ErrUnexpectedEOF 2236 | } 2237 | b := dAtA[iNdEx] 2238 | iNdEx++ 2239 | wire |= uint64(b&0x7F) << shift 2240 | if b < 0x80 { 2241 | break 2242 | } 2243 | } 2244 | fieldNum := int32(wire >> 3) 2245 | wireType := int(wire & 0x7) 2246 | if wireType == 4 { 2247 | return fmt.Errorf("proto: ImageListRequest: wiretype end group for non-group") 2248 | } 2249 | if fieldNum <= 0 { 2250 | return fmt.Errorf("proto: ImageListRequest: illegal tag %d (wire type %d)", fieldNum, wire) 2251 | } 2252 | switch fieldNum { 2253 | case 1: 2254 | if wireType != 2 { 2255 | return fmt.Errorf("proto: wrong wireType = %d for field Filter", wireType) 2256 | } 2257 | var msglen int 2258 | for shift := uint(0); ; shift += 7 { 2259 | if shift >= 64 { 2260 | return ErrIntOverflowImages 2261 | } 2262 | if iNdEx >= l { 2263 | return io.ErrUnexpectedEOF 2264 | } 2265 | b := dAtA[iNdEx] 2266 | iNdEx++ 2267 | msglen |= int(b&0x7F) << shift 2268 | if b < 0x80 { 2269 | break 2270 | } 2271 | } 2272 | if msglen < 0 { 2273 | return ErrInvalidLengthImages 2274 | } 2275 | postIndex := iNdEx + msglen 2276 | if postIndex < 0 { 2277 | return ErrInvalidLengthImages 2278 | } 2279 | if postIndex > l { 2280 | return io.ErrUnexpectedEOF 2281 | } 2282 | if m.Filter == nil { 2283 | m.Filter = &v1alpha2.ImageFilter{} 2284 | } 2285 | if err := m.Filter.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { 2286 | return err 2287 | } 2288 | iNdEx = postIndex 2289 | default: 2290 | iNdEx = preIndex 2291 | skippy, err := skipImages(dAtA[iNdEx:]) 2292 | if err != nil { 2293 | return err 2294 | } 2295 | if (skippy < 0) || (iNdEx+skippy) < 0 { 2296 | return ErrInvalidLengthImages 2297 | } 2298 | if (iNdEx + skippy) > l { 2299 | return io.ErrUnexpectedEOF 2300 | } 2301 | iNdEx += skippy 2302 | } 2303 | } 2304 | 2305 | if iNdEx > l { 2306 | return io.ErrUnexpectedEOF 2307 | } 2308 | return nil 2309 | } 2310 | func (m *ImageListResponse) Unmarshal(dAtA []byte) error { 2311 | l := len(dAtA) 2312 | iNdEx := 0 2313 | for iNdEx < l { 2314 | preIndex := iNdEx 2315 | var wire uint64 2316 | for shift := uint(0); ; shift += 7 { 2317 | if shift >= 64 { 2318 | return ErrIntOverflowImages 2319 | } 2320 | if iNdEx >= l { 2321 | return io.ErrUnexpectedEOF 2322 | } 2323 | b := dAtA[iNdEx] 2324 | iNdEx++ 2325 | wire |= uint64(b&0x7F) << shift 2326 | if b < 0x80 { 2327 | break 2328 | } 2329 | } 2330 | fieldNum := int32(wire >> 3) 2331 | wireType := int(wire & 0x7) 2332 | if wireType == 4 { 2333 | return fmt.Errorf("proto: ImageListResponse: wiretype end group for non-group") 2334 | } 2335 | if fieldNum <= 0 { 2336 | return fmt.Errorf("proto: ImageListResponse: illegal tag %d (wire type %d)", fieldNum, wire) 2337 | } 2338 | switch fieldNum { 2339 | case 1: 2340 | if wireType != 2 { 2341 | return fmt.Errorf("proto: wrong wireType = %d for field Images", wireType) 2342 | } 2343 | var msglen int 2344 | for shift := uint(0); ; shift += 7 { 2345 | if shift >= 64 { 2346 | return ErrIntOverflowImages 2347 | } 2348 | if iNdEx >= l { 2349 | return io.ErrUnexpectedEOF 2350 | } 2351 | b := dAtA[iNdEx] 2352 | iNdEx++ 2353 | msglen |= int(b&0x7F) << shift 2354 | if b < 0x80 { 2355 | break 2356 | } 2357 | } 2358 | if msglen < 0 { 2359 | return ErrInvalidLengthImages 2360 | } 2361 | postIndex := iNdEx + msglen 2362 | if postIndex < 0 { 2363 | return ErrInvalidLengthImages 2364 | } 2365 | if postIndex > l { 2366 | return io.ErrUnexpectedEOF 2367 | } 2368 | m.Images = append(m.Images, &v1alpha2.Image{}) 2369 | if err := m.Images[len(m.Images)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { 2370 | return err 2371 | } 2372 | iNdEx = postIndex 2373 | default: 2374 | iNdEx = preIndex 2375 | skippy, err := skipImages(dAtA[iNdEx:]) 2376 | if err != nil { 2377 | return err 2378 | } 2379 | if (skippy < 0) || (iNdEx+skippy) < 0 { 2380 | return ErrInvalidLengthImages 2381 | } 2382 | if (iNdEx + skippy) > l { 2383 | return io.ErrUnexpectedEOF 2384 | } 2385 | iNdEx += skippy 2386 | } 2387 | } 2388 | 2389 | if iNdEx > l { 2390 | return io.ErrUnexpectedEOF 2391 | } 2392 | return nil 2393 | } 2394 | func (m *ImagePullRequest) Unmarshal(dAtA []byte) error { 2395 | l := len(dAtA) 2396 | iNdEx := 0 2397 | for iNdEx < l { 2398 | preIndex := iNdEx 2399 | var wire uint64 2400 | for shift := uint(0); ; shift += 7 { 2401 | if shift >= 64 { 2402 | return ErrIntOverflowImages 2403 | } 2404 | if iNdEx >= l { 2405 | return io.ErrUnexpectedEOF 2406 | } 2407 | b := dAtA[iNdEx] 2408 | iNdEx++ 2409 | wire |= uint64(b&0x7F) << shift 2410 | if b < 0x80 { 2411 | break 2412 | } 2413 | } 2414 | fieldNum := int32(wire >> 3) 2415 | wireType := int(wire & 0x7) 2416 | if wireType == 4 { 2417 | return fmt.Errorf("proto: ImagePullRequest: wiretype end group for non-group") 2418 | } 2419 | if fieldNum <= 0 { 2420 | return fmt.Errorf("proto: ImagePullRequest: illegal tag %d (wire type %d)", fieldNum, wire) 2421 | } 2422 | switch fieldNum { 2423 | case 1: 2424 | if wireType != 2 { 2425 | return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) 2426 | } 2427 | var msglen int 2428 | for shift := uint(0); ; shift += 7 { 2429 | if shift >= 64 { 2430 | return ErrIntOverflowImages 2431 | } 2432 | if iNdEx >= l { 2433 | return io.ErrUnexpectedEOF 2434 | } 2435 | b := dAtA[iNdEx] 2436 | iNdEx++ 2437 | msglen |= int(b&0x7F) << shift 2438 | if b < 0x80 { 2439 | break 2440 | } 2441 | } 2442 | if msglen < 0 { 2443 | return ErrInvalidLengthImages 2444 | } 2445 | postIndex := iNdEx + msglen 2446 | if postIndex < 0 { 2447 | return ErrInvalidLengthImages 2448 | } 2449 | if postIndex > l { 2450 | return io.ErrUnexpectedEOF 2451 | } 2452 | if m.Image == nil { 2453 | m.Image = &v1alpha2.ImageSpec{} 2454 | } 2455 | if err := m.Image.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { 2456 | return err 2457 | } 2458 | iNdEx = postIndex 2459 | case 2: 2460 | if wireType != 2 { 2461 | return fmt.Errorf("proto: wrong wireType = %d for field Auth", wireType) 2462 | } 2463 | var msglen int 2464 | for shift := uint(0); ; shift += 7 { 2465 | if shift >= 64 { 2466 | return ErrIntOverflowImages 2467 | } 2468 | if iNdEx >= l { 2469 | return io.ErrUnexpectedEOF 2470 | } 2471 | b := dAtA[iNdEx] 2472 | iNdEx++ 2473 | msglen |= int(b&0x7F) << shift 2474 | if b < 0x80 { 2475 | break 2476 | } 2477 | } 2478 | if msglen < 0 { 2479 | return ErrInvalidLengthImages 2480 | } 2481 | postIndex := iNdEx + msglen 2482 | if postIndex < 0 { 2483 | return ErrInvalidLengthImages 2484 | } 2485 | if postIndex > l { 2486 | return io.ErrUnexpectedEOF 2487 | } 2488 | if m.Auth == nil { 2489 | m.Auth = &v1alpha2.AuthConfig{} 2490 | } 2491 | if err := m.Auth.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { 2492 | return err 2493 | } 2494 | iNdEx = postIndex 2495 | default: 2496 | iNdEx = preIndex 2497 | skippy, err := skipImages(dAtA[iNdEx:]) 2498 | if err != nil { 2499 | return err 2500 | } 2501 | if (skippy < 0) || (iNdEx+skippy) < 0 { 2502 | return ErrInvalidLengthImages 2503 | } 2504 | if (iNdEx + skippy) > l { 2505 | return io.ErrUnexpectedEOF 2506 | } 2507 | iNdEx += skippy 2508 | } 2509 | } 2510 | 2511 | if iNdEx > l { 2512 | return io.ErrUnexpectedEOF 2513 | } 2514 | return nil 2515 | } 2516 | func (m *ImagePullResponse) Unmarshal(dAtA []byte) error { 2517 | l := len(dAtA) 2518 | iNdEx := 0 2519 | for iNdEx < l { 2520 | preIndex := iNdEx 2521 | var wire uint64 2522 | for shift := uint(0); ; shift += 7 { 2523 | if shift >= 64 { 2524 | return ErrIntOverflowImages 2525 | } 2526 | if iNdEx >= l { 2527 | return io.ErrUnexpectedEOF 2528 | } 2529 | b := dAtA[iNdEx] 2530 | iNdEx++ 2531 | wire |= uint64(b&0x7F) << shift 2532 | if b < 0x80 { 2533 | break 2534 | } 2535 | } 2536 | fieldNum := int32(wire >> 3) 2537 | wireType := int(wire & 0x7) 2538 | if wireType == 4 { 2539 | return fmt.Errorf("proto: ImagePullResponse: wiretype end group for non-group") 2540 | } 2541 | if fieldNum <= 0 { 2542 | return fmt.Errorf("proto: ImagePullResponse: illegal tag %d (wire type %d)", fieldNum, wire) 2543 | } 2544 | switch fieldNum { 2545 | case 1: 2546 | if wireType != 2 { 2547 | return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) 2548 | } 2549 | var stringLen uint64 2550 | for shift := uint(0); ; shift += 7 { 2551 | if shift >= 64 { 2552 | return ErrIntOverflowImages 2553 | } 2554 | if iNdEx >= l { 2555 | return io.ErrUnexpectedEOF 2556 | } 2557 | b := dAtA[iNdEx] 2558 | iNdEx++ 2559 | stringLen |= uint64(b&0x7F) << shift 2560 | if b < 0x80 { 2561 | break 2562 | } 2563 | } 2564 | intStringLen := int(stringLen) 2565 | if intStringLen < 0 { 2566 | return ErrInvalidLengthImages 2567 | } 2568 | postIndex := iNdEx + intStringLen 2569 | if postIndex < 0 { 2570 | return ErrInvalidLengthImages 2571 | } 2572 | if postIndex > l { 2573 | return io.ErrUnexpectedEOF 2574 | } 2575 | m.Image = string(dAtA[iNdEx:postIndex]) 2576 | iNdEx = postIndex 2577 | default: 2578 | iNdEx = preIndex 2579 | skippy, err := skipImages(dAtA[iNdEx:]) 2580 | if err != nil { 2581 | return err 2582 | } 2583 | if (skippy < 0) || (iNdEx+skippy) < 0 { 2584 | return ErrInvalidLengthImages 2585 | } 2586 | if (iNdEx + skippy) > l { 2587 | return io.ErrUnexpectedEOF 2588 | } 2589 | iNdEx += skippy 2590 | } 2591 | } 2592 | 2593 | if iNdEx > l { 2594 | return io.ErrUnexpectedEOF 2595 | } 2596 | return nil 2597 | } 2598 | func (m *ImagePushRequest) Unmarshal(dAtA []byte) error { 2599 | l := len(dAtA) 2600 | iNdEx := 0 2601 | for iNdEx < l { 2602 | preIndex := iNdEx 2603 | var wire uint64 2604 | for shift := uint(0); ; shift += 7 { 2605 | if shift >= 64 { 2606 | return ErrIntOverflowImages 2607 | } 2608 | if iNdEx >= l { 2609 | return io.ErrUnexpectedEOF 2610 | } 2611 | b := dAtA[iNdEx] 2612 | iNdEx++ 2613 | wire |= uint64(b&0x7F) << shift 2614 | if b < 0x80 { 2615 | break 2616 | } 2617 | } 2618 | fieldNum := int32(wire >> 3) 2619 | wireType := int(wire & 0x7) 2620 | if wireType == 4 { 2621 | return fmt.Errorf("proto: ImagePushRequest: wiretype end group for non-group") 2622 | } 2623 | if fieldNum <= 0 { 2624 | return fmt.Errorf("proto: ImagePushRequest: illegal tag %d (wire type %d)", fieldNum, wire) 2625 | } 2626 | switch fieldNum { 2627 | case 1: 2628 | if wireType != 2 { 2629 | return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) 2630 | } 2631 | var msglen int 2632 | for shift := uint(0); ; shift += 7 { 2633 | if shift >= 64 { 2634 | return ErrIntOverflowImages 2635 | } 2636 | if iNdEx >= l { 2637 | return io.ErrUnexpectedEOF 2638 | } 2639 | b := dAtA[iNdEx] 2640 | iNdEx++ 2641 | msglen |= int(b&0x7F) << shift 2642 | if b < 0x80 { 2643 | break 2644 | } 2645 | } 2646 | if msglen < 0 { 2647 | return ErrInvalidLengthImages 2648 | } 2649 | postIndex := iNdEx + msglen 2650 | if postIndex < 0 { 2651 | return ErrInvalidLengthImages 2652 | } 2653 | if postIndex > l { 2654 | return io.ErrUnexpectedEOF 2655 | } 2656 | if m.Image == nil { 2657 | m.Image = &v1alpha2.ImageSpec{} 2658 | } 2659 | if err := m.Image.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { 2660 | return err 2661 | } 2662 | iNdEx = postIndex 2663 | case 2: 2664 | if wireType != 2 { 2665 | return fmt.Errorf("proto: wrong wireType = %d for field Auth", wireType) 2666 | } 2667 | var msglen int 2668 | for shift := uint(0); ; shift += 7 { 2669 | if shift >= 64 { 2670 | return ErrIntOverflowImages 2671 | } 2672 | if iNdEx >= l { 2673 | return io.ErrUnexpectedEOF 2674 | } 2675 | b := dAtA[iNdEx] 2676 | iNdEx++ 2677 | msglen |= int(b&0x7F) << shift 2678 | if b < 0x80 { 2679 | break 2680 | } 2681 | } 2682 | if msglen < 0 { 2683 | return ErrInvalidLengthImages 2684 | } 2685 | postIndex := iNdEx + msglen 2686 | if postIndex < 0 { 2687 | return ErrInvalidLengthImages 2688 | } 2689 | if postIndex > l { 2690 | return io.ErrUnexpectedEOF 2691 | } 2692 | if m.Auth == nil { 2693 | m.Auth = &v1alpha2.AuthConfig{} 2694 | } 2695 | if err := m.Auth.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { 2696 | return err 2697 | } 2698 | iNdEx = postIndex 2699 | default: 2700 | iNdEx = preIndex 2701 | skippy, err := skipImages(dAtA[iNdEx:]) 2702 | if err != nil { 2703 | return err 2704 | } 2705 | if (skippy < 0) || (iNdEx+skippy) < 0 { 2706 | return ErrInvalidLengthImages 2707 | } 2708 | if (iNdEx + skippy) > l { 2709 | return io.ErrUnexpectedEOF 2710 | } 2711 | iNdEx += skippy 2712 | } 2713 | } 2714 | 2715 | if iNdEx > l { 2716 | return io.ErrUnexpectedEOF 2717 | } 2718 | return nil 2719 | } 2720 | func (m *ImagePushResponse) Unmarshal(dAtA []byte) error { 2721 | l := len(dAtA) 2722 | iNdEx := 0 2723 | for iNdEx < l { 2724 | preIndex := iNdEx 2725 | var wire uint64 2726 | for shift := uint(0); ; shift += 7 { 2727 | if shift >= 64 { 2728 | return ErrIntOverflowImages 2729 | } 2730 | if iNdEx >= l { 2731 | return io.ErrUnexpectedEOF 2732 | } 2733 | b := dAtA[iNdEx] 2734 | iNdEx++ 2735 | wire |= uint64(b&0x7F) << shift 2736 | if b < 0x80 { 2737 | break 2738 | } 2739 | } 2740 | fieldNum := int32(wire >> 3) 2741 | wireType := int(wire & 0x7) 2742 | if wireType == 4 { 2743 | return fmt.Errorf("proto: ImagePushResponse: wiretype end group for non-group") 2744 | } 2745 | if fieldNum <= 0 { 2746 | return fmt.Errorf("proto: ImagePushResponse: illegal tag %d (wire type %d)", fieldNum, wire) 2747 | } 2748 | switch fieldNum { 2749 | case 1: 2750 | if wireType != 2 { 2751 | return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) 2752 | } 2753 | var stringLen uint64 2754 | for shift := uint(0); ; shift += 7 { 2755 | if shift >= 64 { 2756 | return ErrIntOverflowImages 2757 | } 2758 | if iNdEx >= l { 2759 | return io.ErrUnexpectedEOF 2760 | } 2761 | b := dAtA[iNdEx] 2762 | iNdEx++ 2763 | stringLen |= uint64(b&0x7F) << shift 2764 | if b < 0x80 { 2765 | break 2766 | } 2767 | } 2768 | intStringLen := int(stringLen) 2769 | if intStringLen < 0 { 2770 | return ErrInvalidLengthImages 2771 | } 2772 | postIndex := iNdEx + intStringLen 2773 | if postIndex < 0 { 2774 | return ErrInvalidLengthImages 2775 | } 2776 | if postIndex > l { 2777 | return io.ErrUnexpectedEOF 2778 | } 2779 | m.Image = string(dAtA[iNdEx:postIndex]) 2780 | iNdEx = postIndex 2781 | default: 2782 | iNdEx = preIndex 2783 | skippy, err := skipImages(dAtA[iNdEx:]) 2784 | if err != nil { 2785 | return err 2786 | } 2787 | if (skippy < 0) || (iNdEx+skippy) < 0 { 2788 | return ErrInvalidLengthImages 2789 | } 2790 | if (iNdEx + skippy) > l { 2791 | return io.ErrUnexpectedEOF 2792 | } 2793 | iNdEx += skippy 2794 | } 2795 | } 2796 | 2797 | if iNdEx > l { 2798 | return io.ErrUnexpectedEOF 2799 | } 2800 | return nil 2801 | } 2802 | func (m *ImageProgressRequest) Unmarshal(dAtA []byte) error { 2803 | l := len(dAtA) 2804 | iNdEx := 0 2805 | for iNdEx < l { 2806 | preIndex := iNdEx 2807 | var wire uint64 2808 | for shift := uint(0); ; shift += 7 { 2809 | if shift >= 64 { 2810 | return ErrIntOverflowImages 2811 | } 2812 | if iNdEx >= l { 2813 | return io.ErrUnexpectedEOF 2814 | } 2815 | b := dAtA[iNdEx] 2816 | iNdEx++ 2817 | wire |= uint64(b&0x7F) << shift 2818 | if b < 0x80 { 2819 | break 2820 | } 2821 | } 2822 | fieldNum := int32(wire >> 3) 2823 | wireType := int(wire & 0x7) 2824 | if wireType == 4 { 2825 | return fmt.Errorf("proto: ImageProgressRequest: wiretype end group for non-group") 2826 | } 2827 | if fieldNum <= 0 { 2828 | return fmt.Errorf("proto: ImageProgressRequest: illegal tag %d (wire type %d)", fieldNum, wire) 2829 | } 2830 | switch fieldNum { 2831 | case 1: 2832 | if wireType != 2 { 2833 | return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) 2834 | } 2835 | var stringLen uint64 2836 | for shift := uint(0); ; shift += 7 { 2837 | if shift >= 64 { 2838 | return ErrIntOverflowImages 2839 | } 2840 | if iNdEx >= l { 2841 | return io.ErrUnexpectedEOF 2842 | } 2843 | b := dAtA[iNdEx] 2844 | iNdEx++ 2845 | stringLen |= uint64(b&0x7F) << shift 2846 | if b < 0x80 { 2847 | break 2848 | } 2849 | } 2850 | intStringLen := int(stringLen) 2851 | if intStringLen < 0 { 2852 | return ErrInvalidLengthImages 2853 | } 2854 | postIndex := iNdEx + intStringLen 2855 | if postIndex < 0 { 2856 | return ErrInvalidLengthImages 2857 | } 2858 | if postIndex > l { 2859 | return io.ErrUnexpectedEOF 2860 | } 2861 | m.Image = string(dAtA[iNdEx:postIndex]) 2862 | iNdEx = postIndex 2863 | default: 2864 | iNdEx = preIndex 2865 | skippy, err := skipImages(dAtA[iNdEx:]) 2866 | if err != nil { 2867 | return err 2868 | } 2869 | if (skippy < 0) || (iNdEx+skippy) < 0 { 2870 | return ErrInvalidLengthImages 2871 | } 2872 | if (iNdEx + skippy) > l { 2873 | return io.ErrUnexpectedEOF 2874 | } 2875 | iNdEx += skippy 2876 | } 2877 | } 2878 | 2879 | if iNdEx > l { 2880 | return io.ErrUnexpectedEOF 2881 | } 2882 | return nil 2883 | } 2884 | func (m *ImageProgressResponse) Unmarshal(dAtA []byte) error { 2885 | l := len(dAtA) 2886 | iNdEx := 0 2887 | for iNdEx < l { 2888 | preIndex := iNdEx 2889 | var wire uint64 2890 | for shift := uint(0); ; shift += 7 { 2891 | if shift >= 64 { 2892 | return ErrIntOverflowImages 2893 | } 2894 | if iNdEx >= l { 2895 | return io.ErrUnexpectedEOF 2896 | } 2897 | b := dAtA[iNdEx] 2898 | iNdEx++ 2899 | wire |= uint64(b&0x7F) << shift 2900 | if b < 0x80 { 2901 | break 2902 | } 2903 | } 2904 | fieldNum := int32(wire >> 3) 2905 | wireType := int(wire & 0x7) 2906 | if wireType == 4 { 2907 | return fmt.Errorf("proto: ImageProgressResponse: wiretype end group for non-group") 2908 | } 2909 | if fieldNum <= 0 { 2910 | return fmt.Errorf("proto: ImageProgressResponse: illegal tag %d (wire type %d)", fieldNum, wire) 2911 | } 2912 | switch fieldNum { 2913 | case 1: 2914 | if wireType != 2 { 2915 | return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) 2916 | } 2917 | var msglen int 2918 | for shift := uint(0); ; shift += 7 { 2919 | if shift >= 64 { 2920 | return ErrIntOverflowImages 2921 | } 2922 | if iNdEx >= l { 2923 | return io.ErrUnexpectedEOF 2924 | } 2925 | b := dAtA[iNdEx] 2926 | iNdEx++ 2927 | msglen |= int(b&0x7F) << shift 2928 | if b < 0x80 { 2929 | break 2930 | } 2931 | } 2932 | if msglen < 0 { 2933 | return ErrInvalidLengthImages 2934 | } 2935 | postIndex := iNdEx + msglen 2936 | if postIndex < 0 { 2937 | return ErrInvalidLengthImages 2938 | } 2939 | if postIndex > l { 2940 | return io.ErrUnexpectedEOF 2941 | } 2942 | m.Status = append(m.Status, ImageStatus{}) 2943 | if err := m.Status[len(m.Status)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { 2944 | return err 2945 | } 2946 | iNdEx = postIndex 2947 | default: 2948 | iNdEx = preIndex 2949 | skippy, err := skipImages(dAtA[iNdEx:]) 2950 | if err != nil { 2951 | return err 2952 | } 2953 | if (skippy < 0) || (iNdEx+skippy) < 0 { 2954 | return ErrInvalidLengthImages 2955 | } 2956 | if (iNdEx + skippy) > l { 2957 | return io.ErrUnexpectedEOF 2958 | } 2959 | iNdEx += skippy 2960 | } 2961 | } 2962 | 2963 | if iNdEx > l { 2964 | return io.ErrUnexpectedEOF 2965 | } 2966 | return nil 2967 | } 2968 | func (m *ImageStatus) Unmarshal(dAtA []byte) error { 2969 | l := len(dAtA) 2970 | iNdEx := 0 2971 | for iNdEx < l { 2972 | preIndex := iNdEx 2973 | var wire uint64 2974 | for shift := uint(0); ; shift += 7 { 2975 | if shift >= 64 { 2976 | return ErrIntOverflowImages 2977 | } 2978 | if iNdEx >= l { 2979 | return io.ErrUnexpectedEOF 2980 | } 2981 | b := dAtA[iNdEx] 2982 | iNdEx++ 2983 | wire |= uint64(b&0x7F) << shift 2984 | if b < 0x80 { 2985 | break 2986 | } 2987 | } 2988 | fieldNum := int32(wire >> 3) 2989 | wireType := int(wire & 0x7) 2990 | if wireType == 4 { 2991 | return fmt.Errorf("proto: ImageStatus: wiretype end group for non-group") 2992 | } 2993 | if fieldNum <= 0 { 2994 | return fmt.Errorf("proto: ImageStatus: illegal tag %d (wire type %d)", fieldNum, wire) 2995 | } 2996 | switch fieldNum { 2997 | case 1: 2998 | if wireType != 2 { 2999 | return fmt.Errorf("proto: wrong wireType = %d for field Ref", wireType) 3000 | } 3001 | var stringLen uint64 3002 | for shift := uint(0); ; shift += 7 { 3003 | if shift >= 64 { 3004 | return ErrIntOverflowImages 3005 | } 3006 | if iNdEx >= l { 3007 | return io.ErrUnexpectedEOF 3008 | } 3009 | b := dAtA[iNdEx] 3010 | iNdEx++ 3011 | stringLen |= uint64(b&0x7F) << shift 3012 | if b < 0x80 { 3013 | break 3014 | } 3015 | } 3016 | intStringLen := int(stringLen) 3017 | if intStringLen < 0 { 3018 | return ErrInvalidLengthImages 3019 | } 3020 | postIndex := iNdEx + intStringLen 3021 | if postIndex < 0 { 3022 | return ErrInvalidLengthImages 3023 | } 3024 | if postIndex > l { 3025 | return io.ErrUnexpectedEOF 3026 | } 3027 | m.Ref = string(dAtA[iNdEx:postIndex]) 3028 | iNdEx = postIndex 3029 | case 2: 3030 | if wireType != 2 { 3031 | return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) 3032 | } 3033 | var stringLen uint64 3034 | for shift := uint(0); ; shift += 7 { 3035 | if shift >= 64 { 3036 | return ErrIntOverflowImages 3037 | } 3038 | if iNdEx >= l { 3039 | return io.ErrUnexpectedEOF 3040 | } 3041 | b := dAtA[iNdEx] 3042 | iNdEx++ 3043 | stringLen |= uint64(b&0x7F) << shift 3044 | if b < 0x80 { 3045 | break 3046 | } 3047 | } 3048 | intStringLen := int(stringLen) 3049 | if intStringLen < 0 { 3050 | return ErrInvalidLengthImages 3051 | } 3052 | postIndex := iNdEx + intStringLen 3053 | if postIndex < 0 { 3054 | return ErrInvalidLengthImages 3055 | } 3056 | if postIndex > l { 3057 | return io.ErrUnexpectedEOF 3058 | } 3059 | m.Status = string(dAtA[iNdEx:postIndex]) 3060 | iNdEx = postIndex 3061 | case 3: 3062 | if wireType != 0 { 3063 | return fmt.Errorf("proto: wrong wireType = %d for field Offset", wireType) 3064 | } 3065 | m.Offset = 0 3066 | for shift := uint(0); ; shift += 7 { 3067 | if shift >= 64 { 3068 | return ErrIntOverflowImages 3069 | } 3070 | if iNdEx >= l { 3071 | return io.ErrUnexpectedEOF 3072 | } 3073 | b := dAtA[iNdEx] 3074 | iNdEx++ 3075 | m.Offset |= int64(b&0x7F) << shift 3076 | if b < 0x80 { 3077 | break 3078 | } 3079 | } 3080 | case 4: 3081 | if wireType != 0 { 3082 | return fmt.Errorf("proto: wrong wireType = %d for field Total", wireType) 3083 | } 3084 | m.Total = 0 3085 | for shift := uint(0); ; shift += 7 { 3086 | if shift >= 64 { 3087 | return ErrIntOverflowImages 3088 | } 3089 | if iNdEx >= l { 3090 | return io.ErrUnexpectedEOF 3091 | } 3092 | b := dAtA[iNdEx] 3093 | iNdEx++ 3094 | m.Total |= int64(b&0x7F) << shift 3095 | if b < 0x80 { 3096 | break 3097 | } 3098 | } 3099 | case 5: 3100 | if wireType != 2 { 3101 | return fmt.Errorf("proto: wrong wireType = %d for field StartedAt", wireType) 3102 | } 3103 | var msglen int 3104 | for shift := uint(0); ; shift += 7 { 3105 | if shift >= 64 { 3106 | return ErrIntOverflowImages 3107 | } 3108 | if iNdEx >= l { 3109 | return io.ErrUnexpectedEOF 3110 | } 3111 | b := dAtA[iNdEx] 3112 | iNdEx++ 3113 | msglen |= int(b&0x7F) << shift 3114 | if b < 0x80 { 3115 | break 3116 | } 3117 | } 3118 | if msglen < 0 { 3119 | return ErrInvalidLengthImages 3120 | } 3121 | postIndex := iNdEx + msglen 3122 | if postIndex < 0 { 3123 | return ErrInvalidLengthImages 3124 | } 3125 | if postIndex > l { 3126 | return io.ErrUnexpectedEOF 3127 | } 3128 | if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.StartedAt, dAtA[iNdEx:postIndex]); err != nil { 3129 | return err 3130 | } 3131 | iNdEx = postIndex 3132 | case 6: 3133 | if wireType != 2 { 3134 | return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAt", wireType) 3135 | } 3136 | var msglen int 3137 | for shift := uint(0); ; shift += 7 { 3138 | if shift >= 64 { 3139 | return ErrIntOverflowImages 3140 | } 3141 | if iNdEx >= l { 3142 | return io.ErrUnexpectedEOF 3143 | } 3144 | b := dAtA[iNdEx] 3145 | iNdEx++ 3146 | msglen |= int(b&0x7F) << shift 3147 | if b < 0x80 { 3148 | break 3149 | } 3150 | } 3151 | if msglen < 0 { 3152 | return ErrInvalidLengthImages 3153 | } 3154 | postIndex := iNdEx + msglen 3155 | if postIndex < 0 { 3156 | return ErrInvalidLengthImages 3157 | } 3158 | if postIndex > l { 3159 | return io.ErrUnexpectedEOF 3160 | } 3161 | if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.UpdatedAt, dAtA[iNdEx:postIndex]); err != nil { 3162 | return err 3163 | } 3164 | iNdEx = postIndex 3165 | default: 3166 | iNdEx = preIndex 3167 | skippy, err := skipImages(dAtA[iNdEx:]) 3168 | if err != nil { 3169 | return err 3170 | } 3171 | if (skippy < 0) || (iNdEx+skippy) < 0 { 3172 | return ErrInvalidLengthImages 3173 | } 3174 | if (iNdEx + skippy) > l { 3175 | return io.ErrUnexpectedEOF 3176 | } 3177 | iNdEx += skippy 3178 | } 3179 | } 3180 | 3181 | if iNdEx > l { 3182 | return io.ErrUnexpectedEOF 3183 | } 3184 | return nil 3185 | } 3186 | func (m *ImageRemoveRequest) Unmarshal(dAtA []byte) error { 3187 | l := len(dAtA) 3188 | iNdEx := 0 3189 | for iNdEx < l { 3190 | preIndex := iNdEx 3191 | var wire uint64 3192 | for shift := uint(0); ; shift += 7 { 3193 | if shift >= 64 { 3194 | return ErrIntOverflowImages 3195 | } 3196 | if iNdEx >= l { 3197 | return io.ErrUnexpectedEOF 3198 | } 3199 | b := dAtA[iNdEx] 3200 | iNdEx++ 3201 | wire |= uint64(b&0x7F) << shift 3202 | if b < 0x80 { 3203 | break 3204 | } 3205 | } 3206 | fieldNum := int32(wire >> 3) 3207 | wireType := int(wire & 0x7) 3208 | if wireType == 4 { 3209 | return fmt.Errorf("proto: ImageRemoveRequest: wiretype end group for non-group") 3210 | } 3211 | if fieldNum <= 0 { 3212 | return fmt.Errorf("proto: ImageRemoveRequest: illegal tag %d (wire type %d)", fieldNum, wire) 3213 | } 3214 | switch fieldNum { 3215 | case 1: 3216 | if wireType != 2 { 3217 | return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) 3218 | } 3219 | var msglen int 3220 | for shift := uint(0); ; shift += 7 { 3221 | if shift >= 64 { 3222 | return ErrIntOverflowImages 3223 | } 3224 | if iNdEx >= l { 3225 | return io.ErrUnexpectedEOF 3226 | } 3227 | b := dAtA[iNdEx] 3228 | iNdEx++ 3229 | msglen |= int(b&0x7F) << shift 3230 | if b < 0x80 { 3231 | break 3232 | } 3233 | } 3234 | if msglen < 0 { 3235 | return ErrInvalidLengthImages 3236 | } 3237 | postIndex := iNdEx + msglen 3238 | if postIndex < 0 { 3239 | return ErrInvalidLengthImages 3240 | } 3241 | if postIndex > l { 3242 | return io.ErrUnexpectedEOF 3243 | } 3244 | if m.Image == nil { 3245 | m.Image = &v1alpha2.ImageSpec{} 3246 | } 3247 | if err := m.Image.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { 3248 | return err 3249 | } 3250 | iNdEx = postIndex 3251 | default: 3252 | iNdEx = preIndex 3253 | skippy, err := skipImages(dAtA[iNdEx:]) 3254 | if err != nil { 3255 | return err 3256 | } 3257 | if (skippy < 0) || (iNdEx+skippy) < 0 { 3258 | return ErrInvalidLengthImages 3259 | } 3260 | if (iNdEx + skippy) > l { 3261 | return io.ErrUnexpectedEOF 3262 | } 3263 | iNdEx += skippy 3264 | } 3265 | } 3266 | 3267 | if iNdEx > l { 3268 | return io.ErrUnexpectedEOF 3269 | } 3270 | return nil 3271 | } 3272 | func (m *ImageRemoveResponse) Unmarshal(dAtA []byte) error { 3273 | l := len(dAtA) 3274 | iNdEx := 0 3275 | for iNdEx < l { 3276 | preIndex := iNdEx 3277 | var wire uint64 3278 | for shift := uint(0); ; shift += 7 { 3279 | if shift >= 64 { 3280 | return ErrIntOverflowImages 3281 | } 3282 | if iNdEx >= l { 3283 | return io.ErrUnexpectedEOF 3284 | } 3285 | b := dAtA[iNdEx] 3286 | iNdEx++ 3287 | wire |= uint64(b&0x7F) << shift 3288 | if b < 0x80 { 3289 | break 3290 | } 3291 | } 3292 | fieldNum := int32(wire >> 3) 3293 | wireType := int(wire & 0x7) 3294 | if wireType == 4 { 3295 | return fmt.Errorf("proto: ImageRemoveResponse: wiretype end group for non-group") 3296 | } 3297 | if fieldNum <= 0 { 3298 | return fmt.Errorf("proto: ImageRemoveResponse: illegal tag %d (wire type %d)", fieldNum, wire) 3299 | } 3300 | switch fieldNum { 3301 | default: 3302 | iNdEx = preIndex 3303 | skippy, err := skipImages(dAtA[iNdEx:]) 3304 | if err != nil { 3305 | return err 3306 | } 3307 | if (skippy < 0) || (iNdEx+skippy) < 0 { 3308 | return ErrInvalidLengthImages 3309 | } 3310 | if (iNdEx + skippy) > l { 3311 | return io.ErrUnexpectedEOF 3312 | } 3313 | iNdEx += skippy 3314 | } 3315 | } 3316 | 3317 | if iNdEx > l { 3318 | return io.ErrUnexpectedEOF 3319 | } 3320 | return nil 3321 | } 3322 | func (m *ImageStatusRequest) Unmarshal(dAtA []byte) error { 3323 | l := len(dAtA) 3324 | iNdEx := 0 3325 | for iNdEx < l { 3326 | preIndex := iNdEx 3327 | var wire uint64 3328 | for shift := uint(0); ; shift += 7 { 3329 | if shift >= 64 { 3330 | return ErrIntOverflowImages 3331 | } 3332 | if iNdEx >= l { 3333 | return io.ErrUnexpectedEOF 3334 | } 3335 | b := dAtA[iNdEx] 3336 | iNdEx++ 3337 | wire |= uint64(b&0x7F) << shift 3338 | if b < 0x80 { 3339 | break 3340 | } 3341 | } 3342 | fieldNum := int32(wire >> 3) 3343 | wireType := int(wire & 0x7) 3344 | if wireType == 4 { 3345 | return fmt.Errorf("proto: ImageStatusRequest: wiretype end group for non-group") 3346 | } 3347 | if fieldNum <= 0 { 3348 | return fmt.Errorf("proto: ImageStatusRequest: illegal tag %d (wire type %d)", fieldNum, wire) 3349 | } 3350 | switch fieldNum { 3351 | case 1: 3352 | if wireType != 2 { 3353 | return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) 3354 | } 3355 | var msglen int 3356 | for shift := uint(0); ; shift += 7 { 3357 | if shift >= 64 { 3358 | return ErrIntOverflowImages 3359 | } 3360 | if iNdEx >= l { 3361 | return io.ErrUnexpectedEOF 3362 | } 3363 | b := dAtA[iNdEx] 3364 | iNdEx++ 3365 | msglen |= int(b&0x7F) << shift 3366 | if b < 0x80 { 3367 | break 3368 | } 3369 | } 3370 | if msglen < 0 { 3371 | return ErrInvalidLengthImages 3372 | } 3373 | postIndex := iNdEx + msglen 3374 | if postIndex < 0 { 3375 | return ErrInvalidLengthImages 3376 | } 3377 | if postIndex > l { 3378 | return io.ErrUnexpectedEOF 3379 | } 3380 | if m.Image == nil { 3381 | m.Image = &v1alpha2.ImageSpec{} 3382 | } 3383 | if err := m.Image.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { 3384 | return err 3385 | } 3386 | iNdEx = postIndex 3387 | default: 3388 | iNdEx = preIndex 3389 | skippy, err := skipImages(dAtA[iNdEx:]) 3390 | if err != nil { 3391 | return err 3392 | } 3393 | if (skippy < 0) || (iNdEx+skippy) < 0 { 3394 | return ErrInvalidLengthImages 3395 | } 3396 | if (iNdEx + skippy) > l { 3397 | return io.ErrUnexpectedEOF 3398 | } 3399 | iNdEx += skippy 3400 | } 3401 | } 3402 | 3403 | if iNdEx > l { 3404 | return io.ErrUnexpectedEOF 3405 | } 3406 | return nil 3407 | } 3408 | func (m *ImageStatusResponse) Unmarshal(dAtA []byte) error { 3409 | l := len(dAtA) 3410 | iNdEx := 0 3411 | for iNdEx < l { 3412 | preIndex := iNdEx 3413 | var wire uint64 3414 | for shift := uint(0); ; shift += 7 { 3415 | if shift >= 64 { 3416 | return ErrIntOverflowImages 3417 | } 3418 | if iNdEx >= l { 3419 | return io.ErrUnexpectedEOF 3420 | } 3421 | b := dAtA[iNdEx] 3422 | iNdEx++ 3423 | wire |= uint64(b&0x7F) << shift 3424 | if b < 0x80 { 3425 | break 3426 | } 3427 | } 3428 | fieldNum := int32(wire >> 3) 3429 | wireType := int(wire & 0x7) 3430 | if wireType == 4 { 3431 | return fmt.Errorf("proto: ImageStatusResponse: wiretype end group for non-group") 3432 | } 3433 | if fieldNum <= 0 { 3434 | return fmt.Errorf("proto: ImageStatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) 3435 | } 3436 | switch fieldNum { 3437 | case 1: 3438 | if wireType != 2 { 3439 | return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) 3440 | } 3441 | var msglen int 3442 | for shift := uint(0); ; shift += 7 { 3443 | if shift >= 64 { 3444 | return ErrIntOverflowImages 3445 | } 3446 | if iNdEx >= l { 3447 | return io.ErrUnexpectedEOF 3448 | } 3449 | b := dAtA[iNdEx] 3450 | iNdEx++ 3451 | msglen |= int(b&0x7F) << shift 3452 | if b < 0x80 { 3453 | break 3454 | } 3455 | } 3456 | if msglen < 0 { 3457 | return ErrInvalidLengthImages 3458 | } 3459 | postIndex := iNdEx + msglen 3460 | if postIndex < 0 { 3461 | return ErrInvalidLengthImages 3462 | } 3463 | if postIndex > l { 3464 | return io.ErrUnexpectedEOF 3465 | } 3466 | if m.Image == nil { 3467 | m.Image = &v1alpha2.Image{} 3468 | } 3469 | if err := m.Image.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { 3470 | return err 3471 | } 3472 | iNdEx = postIndex 3473 | default: 3474 | iNdEx = preIndex 3475 | skippy, err := skipImages(dAtA[iNdEx:]) 3476 | if err != nil { 3477 | return err 3478 | } 3479 | if (skippy < 0) || (iNdEx+skippy) < 0 { 3480 | return ErrInvalidLengthImages 3481 | } 3482 | if (iNdEx + skippy) > l { 3483 | return io.ErrUnexpectedEOF 3484 | } 3485 | iNdEx += skippy 3486 | } 3487 | } 3488 | 3489 | if iNdEx > l { 3490 | return io.ErrUnexpectedEOF 3491 | } 3492 | return nil 3493 | } 3494 | func (m *ImageTagRequest) Unmarshal(dAtA []byte) error { 3495 | l := len(dAtA) 3496 | iNdEx := 0 3497 | for iNdEx < l { 3498 | preIndex := iNdEx 3499 | var wire uint64 3500 | for shift := uint(0); ; shift += 7 { 3501 | if shift >= 64 { 3502 | return ErrIntOverflowImages 3503 | } 3504 | if iNdEx >= l { 3505 | return io.ErrUnexpectedEOF 3506 | } 3507 | b := dAtA[iNdEx] 3508 | iNdEx++ 3509 | wire |= uint64(b&0x7F) << shift 3510 | if b < 0x80 { 3511 | break 3512 | } 3513 | } 3514 | fieldNum := int32(wire >> 3) 3515 | wireType := int(wire & 0x7) 3516 | if wireType == 4 { 3517 | return fmt.Errorf("proto: ImageTagRequest: wiretype end group for non-group") 3518 | } 3519 | if fieldNum <= 0 { 3520 | return fmt.Errorf("proto: ImageTagRequest: illegal tag %d (wire type %d)", fieldNum, wire) 3521 | } 3522 | switch fieldNum { 3523 | case 1: 3524 | if wireType != 2 { 3525 | return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) 3526 | } 3527 | var msglen int 3528 | for shift := uint(0); ; shift += 7 { 3529 | if shift >= 64 { 3530 | return ErrIntOverflowImages 3531 | } 3532 | if iNdEx >= l { 3533 | return io.ErrUnexpectedEOF 3534 | } 3535 | b := dAtA[iNdEx] 3536 | iNdEx++ 3537 | msglen |= int(b&0x7F) << shift 3538 | if b < 0x80 { 3539 | break 3540 | } 3541 | } 3542 | if msglen < 0 { 3543 | return ErrInvalidLengthImages 3544 | } 3545 | postIndex := iNdEx + msglen 3546 | if postIndex < 0 { 3547 | return ErrInvalidLengthImages 3548 | } 3549 | if postIndex > l { 3550 | return io.ErrUnexpectedEOF 3551 | } 3552 | if m.Image == nil { 3553 | m.Image = &v1alpha2.ImageSpec{} 3554 | } 3555 | if err := m.Image.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { 3556 | return err 3557 | } 3558 | iNdEx = postIndex 3559 | case 2: 3560 | if wireType != 2 { 3561 | return fmt.Errorf("proto: wrong wireType = %d for field Tags", wireType) 3562 | } 3563 | var stringLen uint64 3564 | for shift := uint(0); ; shift += 7 { 3565 | if shift >= 64 { 3566 | return ErrIntOverflowImages 3567 | } 3568 | if iNdEx >= l { 3569 | return io.ErrUnexpectedEOF 3570 | } 3571 | b := dAtA[iNdEx] 3572 | iNdEx++ 3573 | stringLen |= uint64(b&0x7F) << shift 3574 | if b < 0x80 { 3575 | break 3576 | } 3577 | } 3578 | intStringLen := int(stringLen) 3579 | if intStringLen < 0 { 3580 | return ErrInvalidLengthImages 3581 | } 3582 | postIndex := iNdEx + intStringLen 3583 | if postIndex < 0 { 3584 | return ErrInvalidLengthImages 3585 | } 3586 | if postIndex > l { 3587 | return io.ErrUnexpectedEOF 3588 | } 3589 | m.Tags = append(m.Tags, string(dAtA[iNdEx:postIndex])) 3590 | iNdEx = postIndex 3591 | default: 3592 | iNdEx = preIndex 3593 | skippy, err := skipImages(dAtA[iNdEx:]) 3594 | if err != nil { 3595 | return err 3596 | } 3597 | if (skippy < 0) || (iNdEx+skippy) < 0 { 3598 | return ErrInvalidLengthImages 3599 | } 3600 | if (iNdEx + skippy) > l { 3601 | return io.ErrUnexpectedEOF 3602 | } 3603 | iNdEx += skippy 3604 | } 3605 | } 3606 | 3607 | if iNdEx > l { 3608 | return io.ErrUnexpectedEOF 3609 | } 3610 | return nil 3611 | } 3612 | func (m *ImageTagResponse) Unmarshal(dAtA []byte) error { 3613 | l := len(dAtA) 3614 | iNdEx := 0 3615 | for iNdEx < l { 3616 | preIndex := iNdEx 3617 | var wire uint64 3618 | for shift := uint(0); ; shift += 7 { 3619 | if shift >= 64 { 3620 | return ErrIntOverflowImages 3621 | } 3622 | if iNdEx >= l { 3623 | return io.ErrUnexpectedEOF 3624 | } 3625 | b := dAtA[iNdEx] 3626 | iNdEx++ 3627 | wire |= uint64(b&0x7F) << shift 3628 | if b < 0x80 { 3629 | break 3630 | } 3631 | } 3632 | fieldNum := int32(wire >> 3) 3633 | wireType := int(wire & 0x7) 3634 | if wireType == 4 { 3635 | return fmt.Errorf("proto: ImageTagResponse: wiretype end group for non-group") 3636 | } 3637 | if fieldNum <= 0 { 3638 | return fmt.Errorf("proto: ImageTagResponse: illegal tag %d (wire type %d)", fieldNum, wire) 3639 | } 3640 | switch fieldNum { 3641 | case 1: 3642 | if wireType != 2 { 3643 | return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) 3644 | } 3645 | var msglen int 3646 | for shift := uint(0); ; shift += 7 { 3647 | if shift >= 64 { 3648 | return ErrIntOverflowImages 3649 | } 3650 | if iNdEx >= l { 3651 | return io.ErrUnexpectedEOF 3652 | } 3653 | b := dAtA[iNdEx] 3654 | iNdEx++ 3655 | msglen |= int(b&0x7F) << shift 3656 | if b < 0x80 { 3657 | break 3658 | } 3659 | } 3660 | if msglen < 0 { 3661 | return ErrInvalidLengthImages 3662 | } 3663 | postIndex := iNdEx + msglen 3664 | if postIndex < 0 { 3665 | return ErrInvalidLengthImages 3666 | } 3667 | if postIndex > l { 3668 | return io.ErrUnexpectedEOF 3669 | } 3670 | if m.Image == nil { 3671 | m.Image = &v1alpha2.Image{} 3672 | } 3673 | if err := m.Image.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { 3674 | return err 3675 | } 3676 | iNdEx = postIndex 3677 | default: 3678 | iNdEx = preIndex 3679 | skippy, err := skipImages(dAtA[iNdEx:]) 3680 | if err != nil { 3681 | return err 3682 | } 3683 | if (skippy < 0) || (iNdEx+skippy) < 0 { 3684 | return ErrInvalidLengthImages 3685 | } 3686 | if (iNdEx + skippy) > l { 3687 | return io.ErrUnexpectedEOF 3688 | } 3689 | iNdEx += skippy 3690 | } 3691 | } 3692 | 3693 | if iNdEx > l { 3694 | return io.ErrUnexpectedEOF 3695 | } 3696 | return nil 3697 | } 3698 | func skipImages(dAtA []byte) (n int, err error) { 3699 | l := len(dAtA) 3700 | iNdEx := 0 3701 | depth := 0 3702 | for iNdEx < l { 3703 | var wire uint64 3704 | for shift := uint(0); ; shift += 7 { 3705 | if shift >= 64 { 3706 | return 0, ErrIntOverflowImages 3707 | } 3708 | if iNdEx >= l { 3709 | return 0, io.ErrUnexpectedEOF 3710 | } 3711 | b := dAtA[iNdEx] 3712 | iNdEx++ 3713 | wire |= (uint64(b) & 0x7F) << shift 3714 | if b < 0x80 { 3715 | break 3716 | } 3717 | } 3718 | wireType := int(wire & 0x7) 3719 | switch wireType { 3720 | case 0: 3721 | for shift := uint(0); ; shift += 7 { 3722 | if shift >= 64 { 3723 | return 0, ErrIntOverflowImages 3724 | } 3725 | if iNdEx >= l { 3726 | return 0, io.ErrUnexpectedEOF 3727 | } 3728 | iNdEx++ 3729 | if dAtA[iNdEx-1] < 0x80 { 3730 | break 3731 | } 3732 | } 3733 | case 1: 3734 | iNdEx += 8 3735 | case 2: 3736 | var length int 3737 | for shift := uint(0); ; shift += 7 { 3738 | if shift >= 64 { 3739 | return 0, ErrIntOverflowImages 3740 | } 3741 | if iNdEx >= l { 3742 | return 0, io.ErrUnexpectedEOF 3743 | } 3744 | b := dAtA[iNdEx] 3745 | iNdEx++ 3746 | length |= (int(b) & 0x7F) << shift 3747 | if b < 0x80 { 3748 | break 3749 | } 3750 | } 3751 | if length < 0 { 3752 | return 0, ErrInvalidLengthImages 3753 | } 3754 | iNdEx += length 3755 | case 3: 3756 | depth++ 3757 | case 4: 3758 | if depth == 0 { 3759 | return 0, ErrUnexpectedEndOfGroupImages 3760 | } 3761 | depth-- 3762 | case 5: 3763 | iNdEx += 4 3764 | default: 3765 | return 0, fmt.Errorf("proto: illegal wireType %d", wireType) 3766 | } 3767 | if iNdEx < 0 { 3768 | return 0, ErrInvalidLengthImages 3769 | } 3770 | if depth == 0 { 3771 | return iNdEx, nil 3772 | } 3773 | } 3774 | return 0, io.ErrUnexpectedEOF 3775 | } 3776 | 3777 | var ( 3778 | ErrInvalidLengthImages = fmt.Errorf("proto: negative length found during unmarshaling") 3779 | ErrIntOverflowImages = fmt.Errorf("proto: integer overflow") 3780 | ErrUnexpectedEndOfGroupImages = fmt.Errorf("proto: unexpected end of group") 3781 | ) 3782 | -------------------------------------------------------------------------------- /pkg/apis/services/images/v1alpha1/images.proto: -------------------------------------------------------------------------------- 1 | syntax = 'proto3'; 2 | 3 | package k3c.services.images.v1alpha1; 4 | option go_package = "pkg/apis/services/images/v1alpha1;images"; 5 | 6 | import "google/protobuf/timestamp.proto"; 7 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 8 | import "k8s.io/cri-api/pkg/apis/runtime/v1alpha2/api.proto"; 9 | //import "github.com/moby/buildkit/solver/pb/ops.proto"; 10 | //import "github.com/moby/buildkit/api/services/control/control.proto"; 11 | 12 | option (gogoproto.goproto_stringer_all) = false; 13 | option (gogoproto.stringer_all) = true; 14 | option (gogoproto.goproto_getters_all) = true; 15 | option (gogoproto.marshaler_all) = true; 16 | option (gogoproto.sizer_all) = true; 17 | option (gogoproto.unmarshaler_all) = true; 18 | option (gogoproto.goproto_unrecognized_all) = false; 19 | 20 | service Images { 21 | // // Build an image 22 | // rpc Build (ImageBuildRequest) returns (ImageBuildResponse); 23 | 24 | // // BuildStatus 25 | // rpc BuildStatus (ImageBuildStatusRequest) returns (stream ImageBuildStatusResponse); 26 | 27 | // Status of an image 28 | rpc Status (ImageStatusRequest) returns (ImageStatusResponse); 29 | 30 | // List images 31 | rpc List (ImageListRequest) returns (ImageListResponse); 32 | 33 | // Pull an image 34 | rpc Pull (ImagePullRequest) returns (ImagePullResponse); 35 | rpc PullProgress (ImageProgressRequest) returns (stream ImageProgressResponse); 36 | 37 | // Push an image 38 | rpc Push (ImagePushRequest) returns (ImagePushResponse); 39 | rpc PushProgress (ImageProgressRequest) returns (stream ImageProgressResponse); 40 | 41 | // Remove an image 42 | rpc Remove (ImageRemoveRequest) returns (ImageRemoveResponse); 43 | 44 | // Tag an image 45 | rpc Tag(ImageTagRequest) returns (ImageTagResponse); 46 | } 47 | 48 | //message ImageBuildRequest { 49 | // string Ref = 1; 50 | // pb.Definition Definition = 2; 51 | // string Exporter = 3; 52 | // map ExporterAttrs = 4; 53 | // string Session = 5; 54 | // string Frontend = 6; 55 | // map FrontendAttrs = 7; 56 | // moby.buildkit.v1.CacheOptions Cache = 8 [(gogoproto.nullable) = false]; 57 | // repeated string Entitlements = 9 [(gogoproto.customtype) = "github.com/moby/buildkit/util/entitlements.Entitlement" ]; 58 | // map FrontendInputs = 10; 59 | //} 60 | 61 | //message ImageBuildResponse { 62 | // map ExporterResponse = 1; 63 | //} 64 | 65 | //message ImageBuildStatusRequest { 66 | // string Ref = 1; 67 | //} 68 | 69 | //message ImageBuildStatusResponse { 70 | // repeated moby.buildkit.v1.Vertex vertexes = 1; 71 | // repeated moby.buildkit.v1.VertexStatus statuses = 2; 72 | // repeated moby.buildkit.v1.VertexLog logs = 3; 73 | //} 74 | 75 | message ImageListRequest { 76 | // Filter to list images. 77 | runtime.v1alpha2.ImageFilter filter = 1; 78 | } 79 | 80 | message ImageListResponse { 81 | // List of images. 82 | repeated runtime.v1alpha2.Image images = 1; 83 | } 84 | 85 | message ImagePullRequest { 86 | runtime.v1alpha2.ImageSpec image = 1; 87 | runtime.v1alpha2.AuthConfig auth = 2; 88 | } 89 | message ImagePullResponse { 90 | string image = 1; 91 | } 92 | 93 | message ImagePushRequest { 94 | runtime.v1alpha2.ImageSpec image = 1; 95 | runtime.v1alpha2.AuthConfig auth = 2; 96 | } 97 | message ImagePushResponse { 98 | string image = 1; 99 | } 100 | 101 | message ImageProgressRequest { 102 | string image = 1; 103 | } 104 | message ImageProgressResponse { 105 | repeated ImageStatus status = 1 [(gogoproto.nullable) = false]; 106 | } 107 | 108 | // lifted from github.com/containerd/containerd/api/services/content/v1/content.proto 109 | message ImageStatus { 110 | string ref = 1; 111 | string status = 2; 112 | int64 offset = 3; 113 | int64 total = 4; 114 | google.protobuf.Timestamp started_at = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; 115 | google.protobuf.Timestamp updated_at = 6 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; 116 | } 117 | 118 | message ImageRemoveRequest { 119 | // Spec of the image to remove. 120 | runtime.v1alpha2.ImageSpec image = 1; 121 | } 122 | 123 | message ImageRemoveResponse { 124 | } 125 | 126 | message ImageStatusRequest { 127 | // Spec of the image. 128 | runtime.v1alpha2.ImageSpec image = 1; 129 | } 130 | 131 | message ImageStatusResponse { 132 | // Status of the image. 133 | runtime.v1alpha2.Image image = 1; 134 | } 135 | 136 | message ImageTagRequest { 137 | // Spec of the image to remove. 138 | runtime.v1alpha2.ImageSpec image = 1; 139 | repeated string tags = 2; 140 | } 141 | 142 | message ImageTagResponse { 143 | // Status of the image. 144 | runtime.v1alpha2.Image image = 1; 145 | } 146 | -------------------------------------------------------------------------------- /pkg/auth/auth.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "encoding/base64" 5 | "net/url" 6 | "strings" 7 | 8 | "github.com/pkg/errors" 9 | criv1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 10 | ) 11 | 12 | // Parse parses AuthConfig and returns username and password/secret required by containerd. 13 | func Parse(auth *criv1.AuthConfig, host string) (string, string, error) { 14 | if auth == nil { 15 | return "", "", nil 16 | } 17 | if auth.ServerAddress != "" { 18 | // Do not return the auth info when server address doesn't match. 19 | u, err := url.Parse(auth.ServerAddress) 20 | if err != nil { 21 | return "", "", errors.Wrap(err, "parse server address") 22 | } 23 | if host != u.Host { 24 | return "", "", nil 25 | } 26 | } 27 | if auth.Username != "" { 28 | return auth.Username, auth.Password, nil 29 | } 30 | if auth.IdentityToken != "" { 31 | return "", auth.IdentityToken, nil 32 | } 33 | if auth.Auth != "" { 34 | decLen := base64.StdEncoding.DecodedLen(len(auth.Auth)) 35 | decoded := make([]byte, decLen) 36 | _, err := base64.StdEncoding.Decode(decoded, []byte(auth.Auth)) 37 | if err != nil { 38 | return "", "", err 39 | } 40 | fields := strings.SplitN(string(decoded), ":", 2) 41 | if len(fields) != 2 { 42 | return "", "", errors.Errorf("invalid decoded auth: %q", decoded) 43 | } 44 | user, passwd := fields[0], fields[1] 45 | return user, strings.Trim(passwd, "\x00"), nil 46 | } 47 | // TODO(random-liu): Support RegistryToken. 48 | // An empty auth config is valid for anonymous registry 49 | return "", "", nil 50 | } 51 | -------------------------------------------------------------------------------- /pkg/cli/cli.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "github.com/rancher/k3c/pkg/cli/commands/agent" 5 | "github.com/rancher/k3c/pkg/cli/commands/build" 6 | "github.com/rancher/k3c/pkg/cli/commands/images" 7 | "github.com/rancher/k3c/pkg/cli/commands/info" 8 | "github.com/rancher/k3c/pkg/cli/commands/install" 9 | "github.com/rancher/k3c/pkg/cli/commands/pull" 10 | "github.com/rancher/k3c/pkg/cli/commands/push" 11 | "github.com/rancher/k3c/pkg/cli/commands/rmi" 12 | "github.com/rancher/k3c/pkg/cli/commands/tag" 13 | "github.com/rancher/k3c/pkg/cli/commands/uninstall" 14 | "github.com/rancher/k3c/pkg/client" 15 | "github.com/rancher/k3c/pkg/version" 16 | wrangler "github.com/rancher/wrangler-cli" 17 | "github.com/spf13/cobra" 18 | ) 19 | 20 | var ( 21 | DebugConfig wrangler.DebugConfig 22 | ) 23 | 24 | func Main() *cobra.Command { 25 | root := wrangler.Command(&App{}, cobra.Command{ 26 | Use: "k3c", 27 | Version: version.FriendlyVersion(), 28 | }) 29 | root.AddCommand( 30 | agent.Command(), 31 | info.Command(), 32 | images.Command(), 33 | install.Command(), 34 | uninstall.Command(), 35 | build.Command(), 36 | pull.Command(), 37 | push.Command(), 38 | rmi.Command(), 39 | tag.Command(), 40 | ) 41 | return root 42 | } 43 | 44 | type App struct { 45 | wrangler.DebugConfig 46 | client.Config 47 | } 48 | 49 | func (s *App) Run(cmd *cobra.Command, _ []string) error { 50 | return cmd.Help() 51 | } 52 | 53 | func (s *App) PersistentPre(_ *cobra.Command, _ []string) error { 54 | s.MustSetupDebug() 55 | DebugConfig = s.DebugConfig 56 | client.DefaultConfig = s.Config 57 | return nil 58 | } 59 | -------------------------------------------------------------------------------- /pkg/cli/commands/agent/agent.go: -------------------------------------------------------------------------------- 1 | package agent 2 | 3 | import ( 4 | "github.com/rancher/k3c/pkg/server/action" 5 | wrangler "github.com/rancher/wrangler-cli" 6 | "github.com/spf13/cobra" 7 | ) 8 | 9 | func Command() *cobra.Command { 10 | return wrangler.Command(&CommandSpec{}, cobra.Command{ 11 | Use: "agent [OPTIONS]", 12 | Short: "Run the controller daemon", 13 | Hidden: true, 14 | DisableFlagsInUseLine: true, 15 | }) 16 | } 17 | 18 | type CommandSpec struct { 19 | action.Agent 20 | } 21 | 22 | func (s *CommandSpec) Run(cmd *cobra.Command, args []string) error { 23 | return s.Agent.Run(cmd.Context()) 24 | } 25 | -------------------------------------------------------------------------------- /pkg/cli/commands/build/build.go: -------------------------------------------------------------------------------- 1 | package build 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | 7 | "github.com/rancher/k3c/pkg/client" 8 | "github.com/rancher/k3c/pkg/client/action" 9 | wrangler "github.com/rancher/wrangler-cli" 10 | "github.com/spf13/cobra" 11 | ) 12 | 13 | func Command() *cobra.Command { 14 | return wrangler.Command(&CommandSpec{}, cobra.Command{ 15 | Use: "build [OPTIONS] PATH", 16 | Short: "Build an image", 17 | DisableFlagsInUseLine: true, 18 | }) 19 | } 20 | 21 | type CommandSpec struct { 22 | action.BuildImage 23 | } 24 | 25 | func (c *CommandSpec) Run(cmd *cobra.Command, args []string) error { 26 | if len(args) != 1 { 27 | return errors.New("exactly one argument is required") 28 | } 29 | 30 | k8s, err := client.DefaultConfig.Interface() 31 | if err != nil { 32 | return err 33 | } 34 | path := args[0] 35 | if path == "" || path == "." { 36 | path, err = os.Getwd() 37 | } 38 | if err != nil { 39 | return err 40 | } 41 | return c.BuildImage.Invoke(cmd.Context(), k8s, path) 42 | } 43 | -------------------------------------------------------------------------------- /pkg/cli/commands/images/images.go: -------------------------------------------------------------------------------- 1 | package images 2 | 3 | import ( 4 | "github.com/rancher/k3c/pkg/client" 5 | "github.com/rancher/k3c/pkg/client/action" 6 | wrangler "github.com/rancher/wrangler-cli" 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | func Command() *cobra.Command { 11 | return wrangler.Command(&CommandSpec{}, cobra.Command{ 12 | Use: "images [OPTIONS] [REPOSITORY[:TAG]]", 13 | Short: "List images", 14 | DisableFlagsInUseLine: true, 15 | }) 16 | } 17 | 18 | type CommandSpec struct { 19 | action.ListImages 20 | } 21 | 22 | func (s *CommandSpec) Run(cmd *cobra.Command, args []string) error { 23 | k8s, err := client.DefaultConfig.Interface() 24 | if err != nil { 25 | return err 26 | } 27 | 28 | return s.ListImages.Invoke(cmd.Context(), k8s, args) 29 | } 30 | -------------------------------------------------------------------------------- /pkg/cli/commands/info/info.go: -------------------------------------------------------------------------------- 1 | package info 2 | 3 | import ( 4 | "github.com/pkg/errors" 5 | wrangler "github.com/rancher/wrangler-cli" 6 | "github.com/spf13/cobra" 7 | ) 8 | 9 | func Command() *cobra.Command { 10 | return wrangler.Command(&CommandSpec{}, cobra.Command{ 11 | Use: "info [OPTIONS]", 12 | Short: "Display builder information", 13 | }) 14 | } 15 | 16 | type CommandSpec struct { 17 | } 18 | 19 | func (s *CommandSpec) Run(cmd *cobra.Command, args []string) error { 20 | return errors.New("not implemented") // TODO 21 | } 22 | -------------------------------------------------------------------------------- /pkg/cli/commands/install/install.go: -------------------------------------------------------------------------------- 1 | package install 2 | 3 | import ( 4 | "github.com/rancher/k3c/pkg/client" 5 | "github.com/rancher/k3c/pkg/client/action" 6 | wrangler "github.com/rancher/wrangler-cli" 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | func Command() *cobra.Command { 11 | return wrangler.Command(&CommandSpec{}, cobra.Command{ 12 | Use: "install [OPTIONS]", 13 | Short: "Install builder component(s)", 14 | DisableFlagsInUseLine: true, 15 | }) 16 | } 17 | 18 | type CommandSpec struct { 19 | action.InstallBuilder 20 | } 21 | 22 | func (s *CommandSpec) Run(cmd *cobra.Command, args []string) error { 23 | k8s, err := client.DefaultConfig.Interface() 24 | if err != nil { 25 | return err 26 | } 27 | ctx := cmd.Context() 28 | // assert namespace 29 | err = s.InstallBuilder.Namespace(ctx, k8s) 30 | if err != nil { 31 | return err 32 | } 33 | // assert service 34 | err = s.InstallBuilder.Service(ctx, k8s) 35 | if err != nil { 36 | return err 37 | } 38 | // assert daemonset 39 | err = s.InstallBuilder.DaemonSet(ctx, k8s) 40 | if err != nil { 41 | return err 42 | } 43 | // label the node(s) 44 | return s.InstallBuilder.NodeRole(ctx, k8s) 45 | } 46 | -------------------------------------------------------------------------------- /pkg/cli/commands/pull/pull.go: -------------------------------------------------------------------------------- 1 | package pull 2 | 3 | import ( 4 | "github.com/pkg/errors" 5 | "github.com/rancher/k3c/pkg/client" 6 | "github.com/rancher/k3c/pkg/client/action" 7 | wrangler "github.com/rancher/wrangler-cli" 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | func Command() *cobra.Command { 12 | return wrangler.Command(&CommandSpec{}, cobra.Command{ 13 | Use: "pull [OPTIONS] IMAGE", 14 | Short: "Pull an image", 15 | }) 16 | } 17 | 18 | type CommandSpec struct { 19 | action.PullImage 20 | } 21 | 22 | func (s *CommandSpec) Run(cmd *cobra.Command, args []string) error { 23 | if len(args) != 1 { 24 | return errors.New("exactly one argument is required") 25 | } 26 | 27 | k8s, err := client.DefaultConfig.Interface() 28 | if err != nil { 29 | return err 30 | } 31 | return s.PullImage.Invoke(cmd.Context(), k8s, args[0]) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/cli/commands/push/push.go: -------------------------------------------------------------------------------- 1 | package push 2 | 3 | import ( 4 | "github.com/pkg/errors" 5 | "github.com/rancher/k3c/pkg/client" 6 | "github.com/rancher/k3c/pkg/client/action" 7 | wrangler "github.com/rancher/wrangler-cli" 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | func Command() *cobra.Command { 12 | return wrangler.Command(&CommandSpec{}, cobra.Command{ 13 | Use: "push [OPTIONS] IMAGE", 14 | Short: "Push an image", 15 | }) 16 | } 17 | 18 | type CommandSpec struct { 19 | action.PushImage 20 | } 21 | 22 | func (s *CommandSpec) Run(cmd *cobra.Command, args []string) error { 23 | if len(args) != 1 { 24 | return errors.New("exactly one argument is required") 25 | } 26 | 27 | k8s, err := client.DefaultConfig.Interface() 28 | if err != nil { 29 | return err 30 | } 31 | return s.PushImage.Invoke(cmd.Context(), k8s, args[0]) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/cli/commands/rmi/rmi.go: -------------------------------------------------------------------------------- 1 | package rmi 2 | 3 | import ( 4 | "github.com/pkg/errors" 5 | "github.com/rancher/k3c/pkg/client" 6 | "github.com/rancher/k3c/pkg/client/action" 7 | wrangler "github.com/rancher/wrangler-cli" 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | func Command() *cobra.Command { 12 | return wrangler.Command(&CommandSpec{}, cobra.Command{ 13 | Use: "rmi REF", 14 | Short: "Remove an image", 15 | }) 16 | } 17 | 18 | type CommandSpec struct { 19 | action.RemoveImage 20 | } 21 | 22 | func (c *CommandSpec) Run(cmd *cobra.Command, args []string) error { 23 | if len(args) != 1 { 24 | return errors.New("exactly one argument is required") 25 | } 26 | 27 | k8s, err := client.DefaultConfig.Interface() 28 | if err != nil { 29 | return err 30 | } 31 | return c.RemoveImage.Invoke(cmd.Context(), k8s, args[0]) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/cli/commands/tag/tag.go: -------------------------------------------------------------------------------- 1 | package tag 2 | 3 | import ( 4 | "github.com/pkg/errors" 5 | "github.com/rancher/k3c/pkg/client" 6 | "github.com/rancher/k3c/pkg/client/action" 7 | wrangler "github.com/rancher/wrangler-cli" 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | func Command() *cobra.Command { 12 | return wrangler.Command(&CommandSpec{}, cobra.Command{ 13 | Use: "tag SOURCE_REF TARGET_REF [TARGET_REF, ...]", 14 | Short: "Tag an image", 15 | }) 16 | } 17 | 18 | type CommandSpec struct { 19 | action.TagImage 20 | } 21 | 22 | func (c *CommandSpec) Run(cmd *cobra.Command, args []string) error { 23 | if len(args) < 2 { 24 | return errors.New("at least two arguments are required") 25 | } 26 | 27 | k8s, err := client.DefaultConfig.Interface() 28 | if err != nil { 29 | return err 30 | } 31 | return c.TagImage.Invoke(cmd.Context(), k8s, args[0], args[1:]) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/cli/commands/uninstall/uninstall.go: -------------------------------------------------------------------------------- 1 | package uninstall 2 | 3 | import ( 4 | "github.com/rancher/k3c/pkg/client" 5 | "github.com/rancher/k3c/pkg/client/action" 6 | wrangler "github.com/rancher/wrangler-cli" 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | func Command() *cobra.Command { 11 | return wrangler.Command(&CommandSpec{}, cobra.Command{ 12 | Use: "uninstall [OPTIONS]", 13 | Short: "Uninstall builder component(s)", 14 | DisableFlagsInUseLine: true, 15 | }) 16 | } 17 | 18 | type CommandSpec struct { 19 | action.UninstallBuilder 20 | } 21 | 22 | func (s *CommandSpec) Run(cmd *cobra.Command, args []string) error { 23 | k8s, err := client.DefaultConfig.Interface() 24 | if err != nil { 25 | return err 26 | } 27 | ctx := cmd.Context() 28 | err = s.UninstallBuilder.Namespace(ctx, k8s) 29 | if err != nil { 30 | return err 31 | } 32 | return s.UninstallBuilder.NodeRole(ctx, k8s) 33 | } 34 | -------------------------------------------------------------------------------- /pkg/client/action/action-build.go: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | "path/filepath" 8 | "strings" 9 | 10 | "github.com/containerd/console" 11 | buildkit "github.com/moby/buildkit/client" 12 | "github.com/moby/buildkit/util/progress/progressui" 13 | "github.com/rancher/k3c/pkg/client" 14 | "github.com/sirupsen/logrus" 15 | "golang.org/x/sync/errgroup" 16 | ) 17 | 18 | type BuildImage struct { 19 | AddHost []string `usage:"Add a custom host-to-IP mapping (host:ip)"` 20 | BuildArg []string `usage:"Set build-time variables"` 21 | //CacheFrom []string `usage:"Images to consider as cache sources"` 22 | File string `usage:"Name of the Dockerfile (Default is 'PATH/Dockerfile')" short:"f"` 23 | Label []string `usage:"Set metadata for an image"` 24 | //NoCache bool `usage:"Do not use cache when building the image"` 25 | //Output string `usage:"Output directory or - for stdout. (adv. format: type=local,dest=path)" short:"o"` 26 | Progress string `usage:"Set type of progress output (auto, plain, tty). Use plain to show container output" default:"auto"` 27 | //Quiet bool `usage:"Suppress the build output and print image ID on success" short:"q"` 28 | //Secret []string `usage:"Secret file to expose to the build (only if Buildkit enabled): id=mysecret,src=/local/secret"` 29 | Tag []string `usage:"Name and optionally a tag in the 'name:tag' format" short:"t"` 30 | Target string `usage:"Set the target build stage to build."` 31 | //Ssh []string `usage:"SSH agent socket or keys to expose to the build (only if Buildkit enabled) (format: default|[=|[,]])"` 32 | Pull bool `usage:"Always attempt to pull a newer version of the image"` 33 | } 34 | 35 | func (s *BuildImage) Invoke(ctx context.Context, k8s *client.Interface, path string) error { 36 | return DoControl(ctx, k8s, func(ctx context.Context, bkc *buildkit.Client) error { 37 | options := buildkit.SolveOpt{ 38 | Frontend: s.Frontend(), 39 | FrontendAttrs: s.FrontendAttrs(), 40 | LocalDirs: s.LocalDirs(path), 41 | } 42 | if len(s.Tag) > 0 { 43 | options.Exports = defaultExporter(s.Tag[0]) 44 | } 45 | eg := errgroup.Group{} 46 | res, err := bkc.Solve(ctx, nil, options, s.progress(&eg)) 47 | if err != nil { 48 | return err 49 | } 50 | if err := eg.Wait(); err != nil { 51 | return err 52 | } 53 | logrus.Debugf("%#v", res) 54 | return nil 55 | }) 56 | } 57 | 58 | func (s *BuildImage) Frontend() string { 59 | return "dockerfile.v0" 60 | } 61 | 62 | func (s *BuildImage) FrontendAttrs() map[string]string { 63 | // --target 64 | m := map[string]string{ 65 | "target": s.Target, 66 | } 67 | // --build-arg 68 | for _, b := range s.BuildArg { 69 | p := strings.SplitN(b, "=", 2) 70 | k := fmt.Sprintf("build-arg:%s", p[0]) 71 | v := strings.Join(p[1:], "=") 72 | m[k] = v 73 | } 74 | // --label 75 | for _, l := range s.Label { 76 | p := strings.SplitN(l, "=", 2) 77 | k := fmt.Sprintf("label:%s", p[0]) 78 | v := strings.Join(p[1:], "=") 79 | m[k] = v 80 | } 81 | // --add-host 82 | h := strings.Join(s.AddHost, ",") 83 | if h != "" { 84 | m["add-hosts"] = h 85 | } 86 | // --file 87 | if s.File == "" { 88 | m["filename"] = "Dockerfile" 89 | } else { 90 | m["filename"] = filepath.Base(s.File) 91 | } 92 | // --pull 93 | if s.Pull { 94 | m["image-resolve-mode"] = "pull" 95 | } 96 | return m 97 | } 98 | 99 | func (s *BuildImage) LocalDirs(path string) map[string]string { 100 | m := map[string]string{ 101 | "context": path, 102 | } 103 | if s.File == "" { 104 | m["dockerfile"] = path 105 | } else { 106 | m["dockerfile"] = filepath.Dir(s.File) 107 | } 108 | return m 109 | } 110 | 111 | func (s *BuildImage) progress(group *errgroup.Group) chan *buildkit.SolveStatus { 112 | var ( 113 | c console.Console 114 | err error 115 | ) 116 | 117 | switch s.Progress { 118 | case "none": 119 | return nil 120 | case "plain": 121 | default: 122 | c, err = console.ConsoleFromFile(os.Stderr) 123 | if err != nil { 124 | c = nil 125 | } 126 | } 127 | 128 | ch := make(chan *buildkit.SolveStatus, 1) 129 | group.Go(func() error { 130 | return progressui.DisplaySolveStatus(context.TODO(), "", c, os.Stdout, ch) 131 | }) 132 | return ch 133 | } 134 | 135 | func defaultExporter(tag string) []buildkit.ExportEntry { 136 | exp := buildkit.ExportEntry{ 137 | Type: buildkit.ExporterImage, 138 | Attrs: map[string]string{}, 139 | } 140 | if tag != "" { 141 | exp.Attrs["name"] = tag 142 | exp.Attrs["name-canonical"] = "" 143 | } 144 | return []buildkit.ExportEntry{exp} 145 | } 146 | -------------------------------------------------------------------------------- /pkg/client/action/action-images.go: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | "strings" 8 | "text/tabwriter" 9 | 10 | "github.com/docker/go-units" 11 | "github.com/rancher/k3c/pkg/apis/services/images" 12 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 13 | "github.com/rancher/k3c/pkg/client" 14 | criv1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 15 | ) 16 | 17 | type ListImages struct { 18 | All bool `usage:"Show all images (default hides tag-less images)" short:"a"` 19 | Digests bool `usage:"Show digests"` 20 | //Filter string `usage:"Filter output based on conditions provided" short:"f"` 21 | //Format string `usage:"Pretty-print images using a Go template"` 22 | NoTrunc bool `usage:"Don't truncate output"` 23 | Quiet bool `usage:"Only show image IDs" short:"q"` 24 | } 25 | 26 | func (s *ListImages) Invoke(ctx context.Context, k8s *client.Interface, names []string) error { 27 | return DoImages(ctx, k8s, func(ctx context.Context, imagesClient imagesv1.ImagesClient) error { 28 | req := &imagesv1.ImageListRequest{} 29 | // TODO filtering not working as expected 30 | if len(names) > 0 { 31 | req.Filter = &criv1.ImageFilter{ 32 | Image: &criv1.ImageSpec{ 33 | Image: names[0], 34 | }, 35 | } 36 | } 37 | res, err := imagesClient.List(ctx, req) 38 | if err != nil { 39 | return err 40 | } 41 | images.Sort(res.Images) 42 | 43 | // output in table format by default. 44 | display := newTableDisplay(20, 1, 3, ' ', 0) 45 | if !s.Quiet { 46 | if s.Digests { 47 | display.AddRow([]string{columnImage, columnTag, columnDigest, columnImageID, columnSize}) 48 | } else { 49 | display.AddRow([]string{columnImage, columnTag, columnImageID, columnSize}) 50 | } 51 | } 52 | for _, image := range res.Images { 53 | if s.Quiet { 54 | fmt.Printf("%s\n", image.Id) 55 | continue 56 | } 57 | imageName, repoDigest := images.NormalizeRepoDigest(image.RepoDigests) 58 | repoTagPairs := images.NormalizeRepoTagPair(image.RepoTags, imageName) 59 | size := units.HumanSizeWithPrecision(float64(image.GetSize_()), 3) 60 | id := image.Id 61 | if !s.NoTrunc { 62 | id = images.TruncateID(id, "sha256:", 13) 63 | repoDigest = images.TruncateID(repoDigest, "sha256:", 13) 64 | } 65 | for _, repoTagPair := range repoTagPairs { 66 | if !s.All && repoDigest == "" { 67 | continue 68 | } 69 | if s.Digests { 70 | display.AddRow([]string{repoTagPair[0], repoTagPair[1], repoDigest, id, size}) 71 | } else { 72 | display.AddRow([]string{repoTagPair[0], repoTagPair[1], id, size}) 73 | } 74 | } 75 | continue 76 | fmt.Printf("ID: %s\n", image.Id) 77 | for _, tag := range image.RepoTags { 78 | fmt.Printf("RepoTags: %s\n", tag) 79 | } 80 | for _, digest := range image.RepoDigests { 81 | fmt.Printf("RepoDigests: %s\n", digest) 82 | } 83 | if image.Size_ != 0 { 84 | fmt.Printf("Size: %d\n", image.Size_) 85 | } 86 | if image.Uid != nil { 87 | fmt.Printf("Uid: %v\n", image.Uid) 88 | } 89 | if image.Username != "" { 90 | fmt.Printf("Username: %v\n", image.Username) 91 | } 92 | fmt.Printf("\n") 93 | } 94 | display.Flush() 95 | return nil 96 | }) 97 | } 98 | 99 | const ( 100 | columnImage = "IMAGE" 101 | columnImageID = "IMAGE ID" 102 | columnSize = "SIZE" 103 | columnTag = "TAG" 104 | columnDigest = "DIGEST" 105 | ) 106 | 107 | // display use to output something on screen with table format. 108 | type display struct { 109 | w *tabwriter.Writer 110 | } 111 | 112 | // newTableDisplay creates a display instance, and uses to format output with table. 113 | func newTableDisplay(minwidth, tabwidth, padding int, padchar byte, flags uint) *display { 114 | w := tabwriter.NewWriter(os.Stdout, minwidth, tabwidth, padding, padchar, 0) 115 | return &display{w} 116 | } 117 | 118 | // AddRow add a row of data. 119 | func (d *display) AddRow(row []string) { 120 | fmt.Fprintln(d.w, strings.Join(row, "\t")) 121 | } 122 | 123 | // Flush output all rows on screen. 124 | func (d *display) Flush() error { 125 | return d.w.Flush() 126 | } 127 | 128 | // ClearScreen clear all output on screen. 129 | func (d *display) ClearScreen() { 130 | fmt.Fprint(os.Stdout, "\033[2J") 131 | fmt.Fprint(os.Stdout, "\033[H") 132 | } 133 | -------------------------------------------------------------------------------- /pkg/client/action/action-install.go: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/pkg/errors" 8 | "github.com/rancher/k3c/pkg/client" 9 | "github.com/rancher/k3c/pkg/server" 10 | appsv1 "k8s.io/api/apps/v1" 11 | corev1 "k8s.io/api/core/v1" 12 | apierr "k8s.io/apimachinery/pkg/api/errors" 13 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 14 | "k8s.io/apimachinery/pkg/labels" 15 | "k8s.io/client-go/util/retry" 16 | ) 17 | 18 | type InstallBuilder struct { 19 | Force bool `usage:"Force installation by deleting existing builder"` 20 | Selector string `usage:"Selector for nodes (label query) to apply builder role"` 21 | server.Config 22 | } 23 | 24 | func (_ *InstallBuilder) Namespace(_ context.Context, k *client.Interface) error { 25 | return retry.RetryOnConflict(retry.DefaultRetry, func() error { 26 | ns, err := k.Core.Namespace().Get(k.Namespace, metav1.GetOptions{}) 27 | if apierr.IsNotFound(err) { 28 | ns = &corev1.Namespace{ 29 | ObjectMeta: metav1.ObjectMeta{ 30 | Name: k.Namespace, 31 | Labels: labels.Set{ 32 | "app.kubernetes.io/managed-by": "k3c", 33 | }, 34 | }, 35 | } 36 | ns, err = k.Core.Namespace().Create(ns) 37 | return err 38 | } 39 | if ns.Labels == nil { 40 | ns.Labels = labels.Set{} 41 | } 42 | if _, ok := ns.Labels["app.kubernetes.io/managed-by"]; !ok { 43 | ns.Labels["app.kubernetes.io/managed-by"] = "k3c" 44 | } 45 | ns, err = k.Core.Namespace().Update(ns) 46 | return err 47 | }) 48 | } 49 | 50 | func (a *InstallBuilder) containerPort(name string) corev1.ContainerPort { 51 | switch name { 52 | case "buildkit": 53 | return corev1.ContainerPort{ 54 | Name: name, 55 | ContainerPort: int32(a.BuildkitPort), 56 | Protocol: corev1.ProtocolTCP, 57 | } 58 | case "k3c": 59 | return corev1.ContainerPort{ 60 | Name: name, 61 | ContainerPort: int32(a.AgentPort), 62 | Protocol: corev1.ProtocolTCP, 63 | } 64 | default: 65 | return corev1.ContainerPort{Name: name} 66 | } 67 | } 68 | 69 | func (a *InstallBuilder) servicePort(name string) corev1.ServicePort { 70 | switch name { 71 | case "buildkit": 72 | return corev1.ServicePort{ 73 | Name: name, 74 | Port: int32(a.BuildkitPort), 75 | Protocol: corev1.ProtocolTCP, 76 | } 77 | case "k3c": 78 | return corev1.ServicePort{ 79 | Name: name, 80 | Port: int32(a.AgentPort), 81 | Protocol: corev1.ProtocolTCP, 82 | } 83 | default: 84 | return corev1.ServicePort{Name: name} 85 | } 86 | } 87 | 88 | func (a *InstallBuilder) Service(_ context.Context, k *client.Interface) error { 89 | if a.Force { 90 | deletePropagation := metav1.DeletePropagationBackground 91 | deleteOptions := metav1.DeleteOptions{ 92 | PropagationPolicy: &deletePropagation, 93 | } 94 | k.Core.Service().Delete(k.Namespace, "builder", &deleteOptions) 95 | } 96 | if a.AgentPort <= 0 { 97 | a.AgentPort = server.DefaultAgentPort 98 | } 99 | return retry.RetryOnConflict(retry.DefaultRetry, func() error { 100 | svc, err := k.Core.Service().Get(k.Namespace, "builder", metav1.GetOptions{}) 101 | if apierr.IsNotFound(err) { 102 | svc = &corev1.Service{ 103 | ObjectMeta: metav1.ObjectMeta{ 104 | Name: "builder", 105 | Namespace: k.Namespace, 106 | Labels: labels.Set{ 107 | "app.kubernetes.io/managed-by": "k3c", 108 | }, 109 | }, 110 | Spec: corev1.ServiceSpec{ 111 | Type: corev1.ServiceTypeNodePort, 112 | Selector: labels.Set{ 113 | "app.kubernetes.io/name": "k3c", 114 | "app.kubernetes.io/component": "builder", 115 | }, 116 | Ports: []corev1.ServicePort{ 117 | a.servicePort("buildkit"), 118 | a.servicePort("k3c"), 119 | }, 120 | }, 121 | } 122 | svc, err = k.Core.Service().Create(svc) 123 | return err 124 | } 125 | if svc.Labels == nil { 126 | svc.Labels = labels.Set{} 127 | } 128 | if _, ok := svc.Labels["app.kubernetes.io/managed-by"]; !ok { 129 | svc.Labels["app.kubernetes.io/managed-by"] = "k3c" 130 | } 131 | svc, err = k.Core.Service().Update(svc) 132 | return err 133 | }) 134 | } 135 | 136 | func (a *InstallBuilder) DaemonSet(_ context.Context, k *client.Interface) error { 137 | if a.Force { 138 | deletePropagation := metav1.DeletePropagationBackground 139 | deleteOptions := metav1.DeleteOptions{ 140 | PropagationPolicy: &deletePropagation, 141 | } 142 | k.Apps.DaemonSet().Delete(k.Namespace, "builder", &deleteOptions) 143 | } 144 | privileged := true 145 | hostPathDirectory := corev1.HostPathDirectory 146 | hostPathDirectoryOrCreate := corev1.HostPathDirectoryOrCreate 147 | mountPropagationBidirectional := corev1.MountPropagationBidirectional 148 | containerProbe := corev1.Probe{ 149 | Handler: corev1.Handler{ 150 | Exec: &corev1.ExecAction{ 151 | Command: []string{"buildctl", "debug", "workers"}, 152 | }, 153 | }, 154 | InitialDelaySeconds: 5, 155 | PeriodSeconds: 20, 156 | } 157 | 158 | daemon := &appsv1.DaemonSet{ 159 | ObjectMeta: metav1.ObjectMeta{ 160 | Name: "builder", 161 | Namespace: k.Namespace, 162 | Labels: labels.Set{ 163 | "app.kubernetes.io/name": "k3c", 164 | "app.kubernetes.io/component": "builder", 165 | "app.kubernetes.io/managed-by": "k3c", 166 | }, 167 | }, 168 | Spec: appsv1.DaemonSetSpec{ 169 | Selector: &metav1.LabelSelector{ 170 | MatchLabels: labels.Set{ 171 | "app": "k3c", 172 | "component": "builder", 173 | }, 174 | }, 175 | Template: corev1.PodTemplateSpec{ 176 | ObjectMeta: metav1.ObjectMeta{ 177 | Labels: labels.Set{ 178 | "app": "k3c", 179 | "component": "builder", 180 | "app.kubernetes.io/name": "k3c", 181 | "app.kubernetes.io/component": "builder", 182 | "app.kubernetes.io/managed-by": "k3c", 183 | }, 184 | }, 185 | Spec: corev1.PodSpec{ 186 | HostNetwork: true, 187 | HostPID: true, 188 | HostIPC: true, 189 | NodeSelector: labels.Set{ 190 | "node-role.kubernetes.io/builder": "true", 191 | }, 192 | DNSPolicy: corev1.DNSClusterFirstWithHostNet, 193 | Containers: []corev1.Container{{ 194 | Name: "buildkit", 195 | Image: a.GetBuildkitImage(), 196 | Args: []string{ 197 | fmt.Sprintf("--addr=%s", a.BuildkitSocket), 198 | fmt.Sprintf("--addr=tcp://0.0.0.0:%d", a.BuildkitPort), 199 | "--containerd-worker=true", 200 | fmt.Sprintf("--containerd-worker-addr=%s", a.ContainerdSocket), 201 | "--containerd-worker-gc", 202 | "--oci-worker=false", 203 | }, 204 | Ports: []corev1.ContainerPort{ 205 | a.containerPort("buildkit"), 206 | }, 207 | SecurityContext: &corev1.SecurityContext{ 208 | Privileged: &privileged, 209 | }, 210 | VolumeMounts: []corev1.VolumeMount{ 211 | {Name: "cgroup", MountPath: "/sys/fs/cgroup"}, 212 | {Name: "run", MountPath: "/run", MountPropagation: &mountPropagationBidirectional}, 213 | {Name: "tmp", MountPath: "/tmp", MountPropagation: &mountPropagationBidirectional}, 214 | {Name: "var-lib-buildkit", MountPath: "/var/lib/buildkit", MountPropagation: &mountPropagationBidirectional}, 215 | {Name: "var-lib-rancher", MountPath: "/var/lib/rancher", MountPropagation: &mountPropagationBidirectional}, 216 | }, 217 | ReadinessProbe: &containerProbe, 218 | LivenessProbe: &containerProbe, 219 | }, { 220 | Name: "agent", 221 | Image: a.GetAgentImage(), 222 | Command: []string{"k3c", "--debug", "agent"}, 223 | Args: []string{ 224 | fmt.Sprintf("--agent-port=%d", a.AgentPort), 225 | fmt.Sprintf("--buildkit-socket=%s", a.BuildkitSocket), 226 | fmt.Sprintf("--buildkit-port=%d", a.BuildkitPort), 227 | fmt.Sprintf("--containerd-socket=%s", a.ContainerdSocket), 228 | }, 229 | Ports: []corev1.ContainerPort{ 230 | a.containerPort("k3c"), 231 | }, 232 | SecurityContext: &corev1.SecurityContext{ 233 | Privileged: &privileged, 234 | }, 235 | VolumeMounts: []corev1.VolumeMount{ 236 | {Name: "etc-pki", MountPath: "/etc/pki", ReadOnly: true}, 237 | {Name: "etc-ssl", MountPath: "/etc/ssl", ReadOnly: true}, 238 | {Name: "run", MountPath: "/run", MountPropagation: &mountPropagationBidirectional}, 239 | {Name: "var-lib-rancher", MountPath: "/var/lib/rancher", MountPropagation: &mountPropagationBidirectional}, 240 | }, 241 | }}, 242 | Volumes: []corev1.Volume{ 243 | { 244 | Name: "etc-pki", VolumeSource: corev1.VolumeSource{ 245 | HostPath: &corev1.HostPathVolumeSource{ 246 | Path: "/etc/pki", Type: &hostPathDirectoryOrCreate, 247 | }, 248 | }, 249 | }, 250 | { 251 | Name: "etc-ssl", VolumeSource: corev1.VolumeSource{ 252 | HostPath: &corev1.HostPathVolumeSource{ 253 | Path: "/etc/ssl", Type: &hostPathDirectoryOrCreate, 254 | }, 255 | }, 256 | }, 257 | { 258 | Name: "cgroup", VolumeSource: corev1.VolumeSource{ 259 | HostPath: &corev1.HostPathVolumeSource{ 260 | Path: "/sys/fs/cgroup", Type: &hostPathDirectory, 261 | }, 262 | }, 263 | }, 264 | { 265 | Name: "run", VolumeSource: corev1.VolumeSource{ 266 | HostPath: &corev1.HostPathVolumeSource{ 267 | Path: "/run", Type: &hostPathDirectory, 268 | }, 269 | }, 270 | }, 271 | { 272 | Name: "tmp", VolumeSource: corev1.VolumeSource{ 273 | HostPath: &corev1.HostPathVolumeSource{ 274 | Path: "/tmp", Type: &hostPathDirectory, 275 | }, 276 | }, 277 | }, 278 | { 279 | Name: "var-lib-buildkit", VolumeSource: corev1.VolumeSource{ 280 | HostPath: &corev1.HostPathVolumeSource{ 281 | Path: "/var/lib/buildkit", Type: &hostPathDirectory, 282 | }, 283 | }, 284 | }, 285 | { 286 | Name: "var-lib-rancher", VolumeSource: corev1.VolumeSource{ 287 | HostPath: &corev1.HostPathVolumeSource{ 288 | Path: "/var/lib/rancher", Type: &hostPathDirectoryOrCreate, 289 | }, 290 | }, 291 | }, 292 | }, 293 | }, 294 | }, 295 | }, 296 | } 297 | _, err := k.Apps.DaemonSet().Create(daemon) 298 | if apierr.IsAlreadyExists(err) { 299 | return errors.Errorf("buildkit already installed, pass the --force option to recreate") 300 | } 301 | return err 302 | } 303 | 304 | func (a *InstallBuilder) NodeRole(_ context.Context, k *client.Interface) error { 305 | nodeList, err := k.Core.Node().List(metav1.ListOptions{ 306 | LabelSelector: a.Selector, 307 | }) 308 | if err != nil { 309 | return err 310 | } 311 | if len(nodeList.Items) == 1 { 312 | return retry.RetryOnConflict(retry.DefaultRetry, func() error { 313 | node, err := k.Core.Node().Get(nodeList.Items[0].Name, metav1.GetOptions{}) 314 | if err != nil { 315 | return err 316 | } 317 | node.Labels = labels.Merge(node.Labels, labels.Set{ 318 | "node-role.kubernetes.io/builder": "true", 319 | }) 320 | _, err = k.Core.Node().Update(node) 321 | return err 322 | }) 323 | } 324 | return errors.Errorf("too many nodes, please specify a selector, e.g. k3s.io/hostname=%s", nodeList.Items[0].Name) 325 | } 326 | -------------------------------------------------------------------------------- /pkg/client/action/action-pull.go: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import ( 4 | "context" 5 | "io" 6 | "os" 7 | 8 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 9 | "github.com/rancher/k3c/pkg/client" 10 | "github.com/rancher/k3c/pkg/progress" 11 | "github.com/sirupsen/logrus" 12 | "golang.org/x/sync/errgroup" 13 | criv1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 14 | "k8s.io/kubernetes/pkg/credentialprovider" 15 | ) 16 | 17 | type PullImage struct { 18 | Platform string `usage:"Set platform if server is multi-platform capable"` 19 | } 20 | 21 | func (s *PullImage) Invoke(ctx context.Context, k8s *client.Interface, image string) error { 22 | return DoImages(ctx, k8s, func(ctx context.Context, imagesClient imagesv1.ImagesClient) error { 23 | ch := make(chan []imagesv1.ImageStatus) 24 | eg, ctx := errgroup.WithContext(ctx) 25 | // render output from the channel 26 | eg.Go(func() error { 27 | return progress.Display(ch, os.Stdout) 28 | }) 29 | // render progress to the channel 30 | eg.Go(func() error { 31 | defer close(ch) 32 | ppc, err := imagesClient.PullProgress(ctx, &imagesv1.ImageProgressRequest{Image: image}) 33 | if err != nil { 34 | return err 35 | } 36 | for { 37 | info, err := ppc.Recv() 38 | if err == io.EOF { 39 | return nil 40 | } 41 | if err != nil { 42 | return err 43 | } 44 | ch <- info.Status 45 | } 46 | return nil 47 | }) 48 | // initiate the pull 49 | eg.Go(func() error { 50 | req := &imagesv1.ImagePullRequest{ 51 | Image: &criv1.ImageSpec{ 52 | Image: image, 53 | }, 54 | } 55 | keyring := credentialprovider.NewDockerKeyring() 56 | if auth, ok := keyring.Lookup(image); ok { 57 | req.Auth = &criv1.AuthConfig{ 58 | Username: auth[0].Username, 59 | Password: auth[0].Password, 60 | Auth: auth[0].Auth, 61 | ServerAddress: auth[0].ServerAddress, 62 | IdentityToken: auth[0].IdentityToken, 63 | RegistryToken: auth[0].RegistryToken, 64 | } 65 | } 66 | res, err := imagesClient.Pull(ctx, req) 67 | logrus.Debugf("image-pull: %v", res) 68 | return err 69 | }) 70 | return eg.Wait() 71 | }) 72 | } 73 | -------------------------------------------------------------------------------- /pkg/client/action/action-push.go: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import ( 4 | "context" 5 | "io" 6 | "os" 7 | 8 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 9 | "github.com/rancher/k3c/pkg/client" 10 | "github.com/rancher/k3c/pkg/progress" 11 | "github.com/sirupsen/logrus" 12 | "golang.org/x/sync/errgroup" 13 | criv1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 14 | "k8s.io/kubernetes/pkg/credentialprovider" 15 | ) 16 | 17 | type PushImage struct { 18 | } 19 | 20 | func (s *PushImage) Invoke(ctx context.Context, k8s *client.Interface, image string) error { 21 | return DoImages(ctx, k8s, func(ctx context.Context, imagesClient imagesv1.ImagesClient) error { 22 | ch := make(chan []imagesv1.ImageStatus) 23 | eg, ctx := errgroup.WithContext(ctx) 24 | // render output from the channel 25 | eg.Go(func() error { 26 | return progress.Display(ch, os.Stdout) 27 | }) 28 | // render progress to the channel 29 | eg.Go(func() error { 30 | defer close(ch) 31 | ppc, err := imagesClient.PushProgress(ctx, &imagesv1.ImageProgressRequest{Image: image}) 32 | if err != nil { 33 | return err 34 | } 35 | for { 36 | info, err := ppc.Recv() 37 | if err == io.EOF { 38 | return nil 39 | } 40 | if err != nil { 41 | return err 42 | } 43 | ch <- info.Status 44 | } 45 | return nil 46 | }) 47 | // initiate the push 48 | eg.Go(func() error { 49 | req := &imagesv1.ImagePushRequest{ 50 | Image: &criv1.ImageSpec{ 51 | Image: image, 52 | }, 53 | } 54 | keyring := credentialprovider.NewDockerKeyring() 55 | if auth, ok := keyring.Lookup(image); ok { 56 | req.Auth = &criv1.AuthConfig{ 57 | Username: auth[0].Username, 58 | Password: auth[0].Password, 59 | Auth: auth[0].Auth, 60 | ServerAddress: auth[0].ServerAddress, 61 | IdentityToken: auth[0].IdentityToken, 62 | RegistryToken: auth[0].RegistryToken, 63 | } 64 | } 65 | res, err := imagesClient.Push(ctx, req) 66 | logrus.Debugf("image-push: %v", res) 67 | return err 68 | }) 69 | return eg.Wait() 70 | }) 71 | } 72 | -------------------------------------------------------------------------------- /pkg/client/action/action-rmi.go: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import ( 4 | "context" 5 | 6 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 7 | "github.com/rancher/k3c/pkg/client" 8 | "github.com/sirupsen/logrus" 9 | criv1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 10 | ) 11 | 12 | type RemoveImage struct { 13 | } 14 | 15 | func (s *RemoveImage) Invoke(ctx context.Context, k8s *client.Interface, image string) error { 16 | return DoImages(ctx, k8s, func(ctx context.Context, imagesClient imagesv1.ImagesClient) error { 17 | req := &imagesv1.ImageRemoveRequest{ 18 | Image: &criv1.ImageSpec{ 19 | Image: image, 20 | }, 21 | } 22 | res, err := imagesClient.Remove(ctx, req) 23 | if err != nil { 24 | return err 25 | } 26 | logrus.Debugf("%#v", res) 27 | return nil 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /pkg/client/action/action-tag.go: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import ( 4 | "context" 5 | 6 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 7 | "github.com/rancher/k3c/pkg/client" 8 | "github.com/sirupsen/logrus" 9 | criv1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 10 | ) 11 | 12 | type TagImage struct { 13 | } 14 | 15 | func (s *TagImage) Invoke(ctx context.Context, k8s *client.Interface, image string, tags []string) error { 16 | return DoImages(ctx, k8s, func(ctx context.Context, imagesClient imagesv1.ImagesClient) error { 17 | req := &imagesv1.ImageTagRequest{ 18 | Image: &criv1.ImageSpec{ 19 | Image: image, 20 | }, 21 | Tags: tags, 22 | } 23 | res, err := imagesClient.Tag(ctx, req) 24 | if err != nil { 25 | return err 26 | } 27 | logrus.Debugf("%#v", res) 28 | return nil 29 | }) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/client/action/action-uninstall.go: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | "github.com/pkg/errors" 8 | "github.com/rancher/k3c/pkg/client" 9 | "github.com/sirupsen/logrus" 10 | apierr "k8s.io/apimachinery/pkg/api/errors" 11 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 12 | "k8s.io/client-go/tools/cache" 13 | "k8s.io/client-go/util/retry" 14 | ) 15 | 16 | type UninstallBuilder struct { 17 | } 18 | 19 | func (_ *UninstallBuilder) Namespace(ctx context.Context, k *client.Interface) error { 20 | ns, err := k.Core.Namespace().Get(k.Namespace, metav1.GetOptions{}) 21 | if err != nil { 22 | return err 23 | } 24 | if ns.Labels == nil || ns.Labels["app.kubernetes.io/managed-by"] != "k3c" { 25 | return errors.Errorf("namespace not managed by k3c") 26 | } 27 | deletePropagation := metav1.DeletePropagationForeground 28 | deleteOptions := metav1.DeleteOptions{ 29 | PropagationPolicy: &deletePropagation, 30 | } 31 | // is there a better way to wait for the namespace to actually be deleted? 32 | done := make(chan struct{}) 33 | informer := k.Core.Namespace().Informer() 34 | informer.AddEventHandler(cache.ResourceEventHandlerFuncs{ 35 | DeleteFunc: func(obj interface{}) { 36 | close(done) 37 | }, 38 | }) 39 | go informer.Run(done) 40 | err = k.Core.Namespace().Delete(k.Namespace, &deleteOptions) 41 | if err != nil { 42 | return err 43 | } 44 | for { 45 | select { 46 | case <-ctx.Done(): 47 | return ctx.Err() 48 | case <-done: 49 | return nil 50 | case <-time.After(5 * time.Second): 51 | _, err = k.Core.Namespace().Get(k.Namespace, metav1.GetOptions{}) 52 | if !apierr.IsNotFound(err) { 53 | continue 54 | } 55 | return nil 56 | } 57 | } 58 | } 59 | 60 | func (a *UninstallBuilder) NodeRole(_ context.Context, k *client.Interface) error { 61 | nodeList, err := k.Core.Node().List(metav1.ListOptions{ 62 | LabelSelector: "node-role.kubernetes.io/builder", 63 | }) 64 | if err != nil { 65 | return err 66 | } 67 | for _, node := range nodeList.Items { 68 | if err = retry.RetryOnConflict(retry.DefaultRetry, removeBuilderRole(k, node.Name)); err != nil { 69 | logrus.Warnf("failed to remove builder label from %s", node.Name) 70 | } 71 | } 72 | return nil 73 | } 74 | 75 | func removeBuilderRole(k *client.Interface, nodeName string) func() error { 76 | return func() error { 77 | return retry.RetryOnConflict(retry.DefaultRetry, func() error { 78 | node, err := k.Core.Node().Get(nodeName, metav1.GetOptions{}) 79 | if err != nil { 80 | return err 81 | } 82 | if node.Labels == nil { 83 | return nil 84 | } 85 | delete(node.Labels, "node-role.kubernetes.io/builder") 86 | _, err = k.Core.Node().Update(node) 87 | return err 88 | }) 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /pkg/client/action/action.go: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "fmt" 7 | "net" 8 | "strconv" 9 | 10 | buildkit "github.com/moby/buildkit/client" 11 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 12 | "github.com/rancher/k3c/pkg/client" 13 | "google.golang.org/grpc" 14 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 15 | ) 16 | 17 | type DoImagesFunc func(context.Context, imagesv1.ImagesClient) error 18 | type DoControlFunc func(context.Context, *buildkit.Client) error 19 | 20 | func DoImages(ctx context.Context, k8s *client.Interface, fn DoImagesFunc) error { 21 | addr, err := GetServiceAddress(ctx, k8s, "k3c") 22 | if err != nil { 23 | return err 24 | } 25 | conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure()) 26 | if err != nil { 27 | return err 28 | } 29 | defer conn.Close() 30 | return fn(ctx, imagesv1.NewImagesClient(conn)) 31 | } 32 | 33 | func DoControl(ctx context.Context, k8s *client.Interface, fn DoControlFunc) error { 34 | addr, err := GetServiceAddress(ctx, k8s, "buildkit") 35 | if err != nil { 36 | return err 37 | } 38 | bkc, err := buildkit.New(ctx, fmt.Sprintf("tcp://%s", addr)) 39 | if err != nil { 40 | return err 41 | } 42 | defer bkc.Close() 43 | return fn(ctx, bkc) 44 | } 45 | 46 | func GetServiceAddress(_ context.Context, k8s *client.Interface, port string) (string, error) { 47 | // TODO handle multiple addresses 48 | endpoints, err := k8s.Core.Endpoints().Get(k8s.Namespace, "builder", metav1.GetOptions{}) 49 | if err != nil { 50 | return "", err 51 | } 52 | for _, sub := range endpoints.Subsets { 53 | if len(sub.Addresses) > 0 { 54 | for _, p := range sub.Ports { 55 | if p.Name == port { 56 | return net.JoinHostPort(sub.Addresses[0].IP, strconv.FormatInt(int64(p.Port), 10)), nil 57 | } 58 | } 59 | } 60 | } 61 | return "", errors.New("unknown service port") 62 | } 63 | -------------------------------------------------------------------------------- /pkg/client/client.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/pkg/errors" 5 | "github.com/rancher/wrangler/pkg/apply" 6 | appsctl "github.com/rancher/wrangler/pkg/generated/controllers/apps" 7 | appsctlv1 "github.com/rancher/wrangler/pkg/generated/controllers/apps/v1" 8 | corectl "github.com/rancher/wrangler/pkg/generated/controllers/core" 9 | corectlv1 "github.com/rancher/wrangler/pkg/generated/controllers/core/v1" 10 | "github.com/rancher/wrangler/pkg/kubeconfig" 11 | ) 12 | 13 | const ( 14 | DefaultNamespace = "k3c" 15 | ) 16 | 17 | var DefaultConfig = Config{ 18 | Namespace: DefaultNamespace, 19 | } 20 | 21 | type Config struct { 22 | Namespace string `usage:"namespace" default:"k3c" short:"n" env:"NAMESPACE"` 23 | Kubeconfig string `usage:"kubeconfig for authentication" short:"k" env:"KUBECONFIG"` 24 | Context string `usage:"kubeconfig context for authentication" short:"x" env:"KUBECONTEXT"` 25 | } 26 | 27 | func (c *Config) Interface() (*Interface, error) { 28 | if c == nil { 29 | return nil, errors.Errorf("client is not configured, please set client config") 30 | } 31 | return NewInterface(c.Kubeconfig, c.Context, c.Namespace) 32 | } 33 | 34 | type Interface struct { 35 | Core corectlv1.Interface 36 | Apps appsctlv1.Interface 37 | Apply apply.Apply 38 | Namespace string 39 | } 40 | 41 | func NewInterface(kubecfg, kubectx, kubens string) (*Interface, error) { 42 | cc := kubeconfig.GetNonInteractiveClientConfigWithContext(kubecfg, kubectx) 43 | ns, _, err := cc.Namespace() 44 | if err != nil { 45 | return nil, err 46 | } 47 | 48 | if kubens != "" { 49 | ns = kubens 50 | } 51 | 52 | rc, err := cc.ClientConfig() 53 | if err != nil { 54 | return nil, err 55 | } 56 | 57 | c := &Interface{ 58 | Namespace: ns, 59 | } 60 | 61 | core, err := corectl.NewFactoryFromConfig(rc) 62 | if err != nil { 63 | return nil, err 64 | } 65 | c.Core = core.Core().V1() 66 | 67 | apps, err := appsctl.NewFactoryFromConfig(rc) 68 | if err != nil { 69 | return nil, err 70 | } 71 | c.Apps = apps.Apps().V1() 72 | 73 | c.Apply, err = apply.NewForConfig(rc) 74 | if err != nil { 75 | return nil, err 76 | } 77 | 78 | if c.Namespace == "" { 79 | c.Namespace = "k3c" 80 | } 81 | 82 | c.Apply = c.Apply. 83 | WithDynamicLookup(). 84 | WithDefaultNamespace(c.Namespace). 85 | WithListerNamespace(c.Namespace). 86 | WithRestrictClusterScoped() 87 | 88 | return c, nil 89 | } 90 | -------------------------------------------------------------------------------- /pkg/progress/progress.go: -------------------------------------------------------------------------------- 1 | package progress 2 | 3 | import ( 4 | "io" 5 | "sort" 6 | "text/tabwriter" 7 | "time" 8 | 9 | "github.com/containerd/containerd/cmd/ctr/commands/content" 10 | "github.com/containerd/containerd/pkg/progress" 11 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 12 | ) 13 | 14 | func Display(sch <-chan []imagesv1.ImageStatus, out io.Writer) (err error) { 15 | start := time.Now() 16 | 17 | pw := progress.NewWriter(out) 18 | defer func() { 19 | pw.Flush() 20 | if err == nil { 21 | pw.Write([]byte("\n")) 22 | } else { 23 | pw.Write([]byte(err.Error())) 24 | } 25 | pw.Flush() 26 | }() 27 | 28 | for sc := range sch { 29 | pw.Flush() 30 | if len(sc) == 0 { 31 | continue 32 | } 33 | 34 | var status []content.StatusInfo 35 | for _, s := range sc { 36 | status = append(status, content.StatusInfo{ 37 | Ref: s.Ref, 38 | Status: s.Status, 39 | Offset: s.Offset, 40 | Total: s.Total, 41 | StartedAt: s.StartedAt, 42 | UpdatedAt: s.UpdatedAt, 43 | }) 44 | } 45 | 46 | sort.Slice(status, func(i, j int) bool { 47 | return status[i].Ref < status[j].Ref 48 | }) 49 | 50 | tw := tabwriter.NewWriter(pw, 1, 8, 1, ' ', 0) 51 | content.Display(tw, status, start) 52 | tw.Flush() 53 | } 54 | 55 | return nil 56 | } 57 | -------------------------------------------------------------------------------- /pkg/progress/tracker.go: -------------------------------------------------------------------------------- 1 | package progress 2 | 3 | import ( 4 | "context" 5 | "sync" 6 | "time" 7 | 8 | "github.com/containerd/containerd/remotes/docker" 9 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 10 | ) 11 | 12 | // most of this is copied from containerd ctr tool 13 | 14 | type Tracker interface { 15 | Add(ref string) 16 | Status() <-chan []imagesv1.ImageStatus 17 | } 18 | 19 | type tracker struct { 20 | *pushjobs 21 | status chan []imagesv1.ImageStatus 22 | } 23 | 24 | func (t *tracker) Status() <-chan []imagesv1.ImageStatus { 25 | return t.status 26 | } 27 | 28 | func NewTracker(ctx context.Context, statusTracker docker.StatusTracker) Tracker { 29 | ongoing := newPushJobs(statusTracker) 30 | 31 | var ( 32 | result = make(chan []imagesv1.ImageStatus) 33 | ) 34 | 35 | go func() { 36 | ticker := time.NewTicker(100 * time.Millisecond) 37 | 38 | defer ticker.Stop() 39 | defer close(result) 40 | 41 | for { 42 | select { 43 | case <-ticker.C: 44 | result <- ongoing.status() 45 | case <-ctx.Done(): 46 | return 47 | } 48 | } 49 | }() 50 | 51 | return &tracker{ 52 | pushjobs: ongoing, 53 | status: result, 54 | } 55 | } 56 | 57 | type pushjobs struct { 58 | jobs map[string]struct{} 59 | ordered []string 60 | tracker docker.StatusTracker 61 | mu sync.Mutex 62 | } 63 | 64 | func newPushJobs(tracker docker.StatusTracker) *pushjobs { 65 | return &pushjobs{ 66 | jobs: make(map[string]struct{}), 67 | tracker: tracker, 68 | } 69 | } 70 | 71 | func (j *pushjobs) Add(ref string) { 72 | j.mu.Lock() 73 | defer j.mu.Unlock() 74 | 75 | if _, ok := j.jobs[ref]; ok { 76 | return 77 | } 78 | j.ordered = append(j.ordered, ref) 79 | j.jobs[ref] = struct{}{} 80 | } 81 | 82 | func (j *pushjobs) status() []imagesv1.ImageStatus { 83 | j.mu.Lock() 84 | defer j.mu.Unlock() 85 | 86 | statuses := make([]imagesv1.ImageStatus, 0, len(j.jobs)) 87 | for _, name := range j.ordered { 88 | si := imagesv1.ImageStatus{ 89 | Ref: name, 90 | } 91 | 92 | status, err := j.tracker.GetStatus(name) 93 | if err != nil { 94 | si.Status = "waiting" 95 | } else { 96 | si.Offset = status.Offset 97 | si.Total = status.Total 98 | si.StartedAt = status.StartedAt 99 | si.UpdatedAt = status.UpdatedAt 100 | if status.Offset >= status.Total { 101 | if status.UploadUUID == "" { 102 | si.Status = "done" 103 | } else { 104 | si.Status = "committing" 105 | } 106 | } else { 107 | si.Status = "uploading" 108 | } 109 | } 110 | statuses = append(statuses, si) 111 | } 112 | 113 | return statuses 114 | } 115 | -------------------------------------------------------------------------------- /pkg/server/action/agent.go: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import "github.com/rancher/k3c/pkg/server" 4 | 5 | type Agent struct { 6 | server.Config 7 | } 8 | -------------------------------------------------------------------------------- /pkg/server/action/agent_linux.go: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "net" 7 | 8 | "github.com/containerd/containerd" 9 | "github.com/containerd/containerd/api/events" 10 | "github.com/containerd/containerd/content" 11 | "github.com/containerd/containerd/errdefs" 12 | "github.com/containerd/containerd/images" 13 | "github.com/containerd/containerd/namespaces" 14 | "github.com/containerd/typeurl" 15 | "github.com/gogo/protobuf/types" 16 | ocispec "github.com/opencontainers/image-spec/specs-go/v1" 17 | "github.com/pkg/errors" 18 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 19 | "github.com/rancher/k3c/pkg/client" 20 | "github.com/rancher/k3c/pkg/server" 21 | "github.com/sirupsen/logrus" 22 | "google.golang.org/grpc" 23 | ) 24 | 25 | func (s *Agent) Run(ctx context.Context) error { 26 | backend, err := s.Interface(ctx, &client.DefaultConfig) 27 | if err != nil { 28 | return err 29 | } 30 | defer backend.Close() 31 | 32 | go s.syncImageContent(namespaces.WithNamespace(ctx, s.BuildkitNamespace), backend.Containerd) 33 | go s.listenAndServe(ctx, backend) 34 | 35 | select { 36 | case <-ctx.Done(): 37 | return ctx.Err() 38 | } 39 | } 40 | 41 | func (s *Agent) listenAndServe(ctx context.Context, backend *server.Interface) error { 42 | lc := &net.ListenConfig{} 43 | listener, err := lc.Listen(ctx, "tcp", fmt.Sprintf("0.0.0.0:%d", s.AgentPort)) 44 | if err != nil { 45 | return err 46 | } 47 | defer listener.Close() 48 | 49 | server := grpc.NewServer() 50 | imagesv1.RegisterImagesServer(server, backend) 51 | defer server.Stop() 52 | return server.Serve(listener) 53 | } 54 | 55 | func (s *Agent) syncImageContent(ctx context.Context, ctr *containerd.Client) { 56 | events, errors := ctr.EventService().Subscribe(ctx, `topic~="/images/"`) 57 | for { 58 | select { 59 | case <-ctx.Done(): 60 | return 61 | case err, ok := <-errors: 62 | if !ok { 63 | return 64 | } 65 | logrus.Errorf("sync-image-content: %v", err) 66 | case evt, ok := <-events: 67 | if !ok { 68 | return 69 | } 70 | if evt.Namespace != s.BuildkitNamespace { 71 | continue 72 | } 73 | if err := handleImageEvent(ctx, ctr, evt.Event); err != nil { 74 | logrus.Errorf("sync-image-content: handling %#v returned %v", evt, err) 75 | } 76 | } 77 | } 78 | } 79 | 80 | func handleImageEvent(ctx context.Context, ctr *containerd.Client, any *types.Any) error { 81 | evt, err := typeurl.UnmarshalAny(any) 82 | if err != nil { 83 | return errors.Wrap(err, "failed to unmarshal any") 84 | } 85 | 86 | switch e := evt.(type) { 87 | case *events.ImageCreate: 88 | logrus.Debugf("image-create: %s", e.Name) 89 | return copyImageContent(ctx, ctr, e.Name, func(x context.Context, s images.Store, i images.Image) error { 90 | _, err := s.Create(x, i) 91 | if errdefs.IsAlreadyExists(err) { 92 | _, err = s.Update(x, i) 93 | } 94 | return err 95 | }) 96 | case *events.ImageUpdate: 97 | logrus.Debugf("image-update: %s", e.Name) 98 | return copyImageContent(ctx, ctr, e.Name, func(x context.Context, s images.Store, i images.Image) error { 99 | _, err := s.Create(x, i) 100 | if errdefs.IsAlreadyExists(err) { 101 | _, err = s.Update(x, i) 102 | } 103 | return err 104 | }) 105 | } 106 | 107 | return nil 108 | } 109 | 110 | func copyImageContent(ctx context.Context, ctr *containerd.Client, name string, fn func(context.Context, images.Store, images.Image) error) error { 111 | imageStore := ctr.ImageService() 112 | img, err := imageStore.Get(ctx, name) 113 | if err != nil { 114 | return err 115 | } 116 | contentStore := ctr.ContentStore() 117 | toCtx := namespaces.WithNamespace(ctx, "k8s.io") 118 | handler := images.Handlers(images.ChildrenHandler(contentStore), copyImageContentFunc(toCtx, contentStore, img)) 119 | if err = images.Walk(ctx, handler, img.Target); err != nil { 120 | return err 121 | } 122 | return fn(toCtx, imageStore, img) 123 | } 124 | 125 | func copyImageContentFunc(toCtx context.Context, contentStore content.Store, img images.Image) images.HandlerFunc { 126 | return func(fromCtx context.Context, desc ocispec.Descriptor) (children []ocispec.Descriptor, err error) { 127 | logrus.Debugf("copy-image-content: media-type=%v, digest=%v", desc.MediaType, desc.Digest) 128 | info, err := contentStore.Info(fromCtx, desc.Digest) 129 | if err != nil { 130 | return children, err 131 | } 132 | ra, err := contentStore.ReaderAt(fromCtx, desc) 133 | if err != nil { 134 | return children, err 135 | } 136 | defer ra.Close() 137 | wopts := []content.WriterOpt{content.WithRef(img.Name)} 138 | if _, err := contentStore.Info(toCtx, desc.Digest); errdefs.IsNotFound(err) { 139 | // if the image does not already exist in the target namespace we supply the descriptor here so as to 140 | // ensure that it is created with proper size information. if the image already exist the size for the digest 141 | // for the to-be updated image is sourced from what is passed to content.Copy 142 | wopts = append(wopts, content.WithDescriptor(desc)) 143 | } 144 | w, err := contentStore.Writer(toCtx, wopts...) 145 | if err != nil { 146 | return children, err 147 | } 148 | defer w.Close() 149 | err = content.Copy(toCtx, w, content.NewReader(ra), desc.Size, desc.Digest, content.WithLabels(info.Labels)) 150 | if err != nil && errdefs.IsAlreadyExists(err) { 151 | return children, nil 152 | } 153 | return children, err 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /pkg/server/action/agent_other.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package action 4 | 5 | import "context" 6 | 7 | func (s *Agent) Run(ctx context.Context) error { 8 | panic("not supported on this platform") 9 | } 10 | -------------------------------------------------------------------------------- /pkg/server/config.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "time" 7 | 8 | "github.com/containerd/containerd" 9 | buildkit "github.com/moby/buildkit/client" 10 | "github.com/rancher/k3c/pkg/client" 11 | "github.com/rancher/k3c/pkg/version" 12 | "google.golang.org/grpc" 13 | criv1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 14 | ) 15 | 16 | const ( 17 | defaultAgentPort = 1233 18 | defaultAgentImage = "docker.io/rancher/k3c" 19 | defaultBuildkitImage = "docker.io/moby/buildkit:v0.8.1" 20 | 21 | // defaultBuildkitPort = 1234 22 | // defaultBuildkitAddress = "unix:///run/buildkit/buildkitd.sock" 23 | // defaultBuildkitNamespace = "buildkit" 24 | // defaultContainerdAddress = "/run/k3s/containerd/containerd.sock" 25 | ) 26 | 27 | var ( 28 | DefaultAgentPort = defaultAgentPort 29 | DefaultAgentImage = defaultAgentImage 30 | DefaultBuildkitImage = defaultBuildkitImage 31 | 32 | // DefaultBuildkitPort = defaultBuildkitPort 33 | // DefaultBuildkitAddress = defaultBuildkitAddress 34 | // DefaultBuildkitNamespace = defaultBuildkitNamespace 35 | // DefaultContainerdAddress = defaultContainerdAddress 36 | // DefaultListenAddress = fmt.Sprintf("tcp://0.0.0.0:%d", defaultAgentPort) 37 | ) 38 | 39 | type Config struct { 40 | AgentImage string `usage:"Image to run the agent w/ missing tag inferred from version" default:"docker.io/rancher/k3c"` 41 | AgentPort int `usage:"Port that the agent will listen on" default:"1233"` 42 | BuildkitImage string `usage:"BuildKit image for running buildkitd" default:"docker.io/moby/buildkit:v0.8.1"` 43 | BuildkitNamespace string `usage:"BuildKit namespace in containerd (not 'k8s.io')" default:"buildkit"` 44 | BuildkitPort int `usage:"BuildKit service port" default:"1234"` 45 | BuildkitSocket string `usage:"BuildKit socket address" default:"unix:///run/buildkit/buildkitd.sock"` 46 | ContainerdSocket string `usage:"Containerd socket address" default:"/run/k3s/containerd/containerd.sock"` 47 | } 48 | 49 | func (c *Config) GetAgentImage() string { 50 | if c.AgentImage == "" { 51 | c.AgentImage = DefaultAgentImage 52 | } 53 | // TODO assumes default agent image is tag-less 54 | if c.AgentImage == DefaultAgentImage { 55 | return fmt.Sprintf("%s:%s", c.AgentImage, version.Version) 56 | } 57 | return c.AgentImage 58 | } 59 | 60 | func (c *Config) GetBuildkitImage() string { 61 | if c.BuildkitImage == "" { 62 | c.BuildkitImage = DefaultBuildkitImage 63 | } 64 | return c.BuildkitImage 65 | } 66 | 67 | func (c *Config) Interface(ctx context.Context, config *client.Config) (*Interface, error) { 68 | k8s, err := config.Interface() 69 | if err != nil { 70 | return nil, err 71 | } 72 | server := Interface{ 73 | Kubernetes: k8s, 74 | } 75 | 76 | server.Buildkit, err = buildkit.New(ctx, c.BuildkitSocket) 77 | if err != nil { 78 | return nil, err 79 | } 80 | conn, err := grpc.DialContext(ctx, fmt.Sprintf("unix://%s", c.ContainerdSocket), grpc.WithInsecure(), grpc.WithBlock(), grpc.FailOnNonTempDialError(true)) 81 | if err != nil { 82 | server.Close() 83 | return nil, err 84 | } 85 | server.Containerd, err = containerd.NewWithConn(conn, 86 | containerd.WithDefaultNamespace(c.BuildkitNamespace), 87 | containerd.WithTimeout(5*time.Second), 88 | ) 89 | if err != nil { 90 | server.Close() 91 | return nil, err 92 | } 93 | server.RuntimeService = criv1.NewRuntimeServiceClient(conn) 94 | server.ImageService = criv1.NewImageServiceClient(conn) 95 | 96 | return &server, nil 97 | } 98 | -------------------------------------------------------------------------------- /pkg/server/images-pull.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | "github.com/containerd/containerd/namespaces" 8 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 9 | "github.com/sirupsen/logrus" 10 | criv1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 11 | ) 12 | 13 | // Pull server-side impl 14 | func (i *Interface) Pull(ctx context.Context, request *imagesv1.ImagePullRequest) (*imagesv1.ImagePullResponse, error) { 15 | req := &criv1.PullImageRequest{ 16 | Image: request.Image, 17 | } 18 | res, err := i.ImageService.PullImage(ctx, req) 19 | if err != nil { 20 | return nil, err 21 | } 22 | return &imagesv1.ImagePullResponse{ 23 | Image: res.ImageRef, 24 | }, nil 25 | } 26 | 27 | // PullProgress server-side impl 28 | func (i *Interface) PullProgress(req *imagesv1.ImageProgressRequest, srv imagesv1.Images_PullProgressServer) error { 29 | ctx := namespaces.WithNamespace(srv.Context(), "k8s.io") 30 | 31 | for { 32 | select { 33 | case <-ctx.Done(): 34 | return ctx.Err() 35 | case <-time.After(100 * time.Millisecond): 36 | isr, err := i.ImageService.ImageStatus(ctx, &criv1.ImageStatusRequest{ 37 | Image: &criv1.ImageSpec{ 38 | Image: req.Image, 39 | }, 40 | }) 41 | if err != nil { 42 | logrus.Debugf("pull-progress-image-status-error: %v", err) 43 | return err 44 | } 45 | if isr.Image != nil { 46 | logrus.Debugf("pull-progress-image-status-done: %s", isr.Image) 47 | return nil 48 | } 49 | csl, err := i.Containerd.ContentStore().ListStatuses(ctx, "") // TODO is this filter too broad? 50 | if err != nil { 51 | logrus.Debugf("pull-progress-content-status-error: %v", err) 52 | return err 53 | } 54 | res := &imagesv1.ImageProgressResponse{} 55 | for _, s := range csl { 56 | status := "waiting" 57 | if s.Offset == s.Total { 58 | status = "unpacking" 59 | } else if s.Offset > 0 { 60 | status = "downloading" 61 | } 62 | res.Status = append(res.Status, imagesv1.ImageStatus{ 63 | Status: status, 64 | Ref: s.Ref, 65 | Offset: s.Offset, 66 | Total: s.Total, 67 | StartedAt: s.StartedAt, 68 | UpdatedAt: s.UpdatedAt, 69 | }) 70 | } 71 | if err = srv.Send(res); err != nil { 72 | logrus.Debugf("pull-progress-content-send-error: %v", err) 73 | return err 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /pkg/server/images-push.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "net/http" 7 | "time" 8 | 9 | "github.com/containerd/containerd" 10 | "github.com/containerd/containerd/cmd/ctr/commands" 11 | "github.com/containerd/containerd/images" 12 | "github.com/containerd/containerd/namespaces" 13 | "github.com/containerd/containerd/remotes" 14 | "github.com/containerd/containerd/remotes/docker" 15 | ocispec "github.com/opencontainers/image-spec/specs-go/v1" 16 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 17 | "github.com/rancher/k3c/pkg/auth" 18 | "github.com/rancher/k3c/pkg/progress" 19 | "github.com/rancher/k3c/pkg/version" 20 | "github.com/sirupsen/logrus" 21 | ) 22 | 23 | // Push server-side impl 24 | func (i *Interface) Push(ctx context.Context, request *imagesv1.ImagePushRequest) (*imagesv1.ImagePushResponse, error) { 25 | ctx = namespaces.WithNamespace(ctx, "k8s.io") 26 | img, err := i.Containerd.ImageService().Get(ctx, request.Image.Image) 27 | if err != nil { 28 | return nil, err 29 | } 30 | 31 | authorizer := docker.NewDockerAuthorizer( 32 | docker.WithAuthClient(http.DefaultClient), 33 | docker.WithAuthCreds(func(host string) (string, string, error) { 34 | return auth.Parse(request.Auth, host) 35 | }), 36 | docker.WithAuthHeader(http.Header{ 37 | "User-Agent": []string{fmt.Sprintf("k3c/%s", version.Version)}, 38 | }), 39 | ) 40 | resolver := docker.NewResolver(docker.ResolverOptions{ 41 | Tracker: commands.PushTracker, 42 | Hosts: docker.ConfigureDefaultRegistries( 43 | docker.WithAuthorizer(authorizer), 44 | ), 45 | }) 46 | tracker := progress.NewTracker(ctx, commands.PushTracker) 47 | i.pushes.Store(img.Name, tracker) 48 | handler := images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) { 49 | tracker.Add(remotes.MakeRefKey(ctx, desc)) 50 | return nil, nil 51 | }) 52 | err = i.Containerd.Push(ctx, img.Name, img.Target, 53 | containerd.WithResolver(resolver), 54 | containerd.WithImageHandler(handler), 55 | ) 56 | if err != nil { 57 | return nil, err 58 | } 59 | return &imagesv1.ImagePushResponse{ 60 | Image: img.Name, 61 | }, nil 62 | } 63 | 64 | // PushProgress server-side impl 65 | func (i *Interface) PushProgress(req *imagesv1.ImageProgressRequest, srv imagesv1.Images_PushProgressServer) error { 66 | ctx := namespaces.WithNamespace(srv.Context(), "k8s.io") 67 | defer i.pushes.Delete(req.Image) 68 | 69 | timeout := time.After(15 * time.Second) 70 | 71 | for { 72 | if tracker, tracking := i.pushes.Load(req.Image); tracking { 73 | for status := range tracker.(progress.Tracker).Status() { 74 | if err := srv.Send(&imagesv1.ImageProgressResponse{Status: status}); err != nil { 75 | logrus.Debugf("push-progress-error: %s -> %v", req.Image, err) 76 | return err 77 | } 78 | } 79 | logrus.Debugf("push-progress-done: %s", req.Image) 80 | return nil 81 | } 82 | select { 83 | case <-timeout: 84 | logrus.Debugf("push-progress-timeout: not tracking %s", req.Image) 85 | return nil 86 | case <-ctx.Done(): 87 | return ctx.Err() 88 | case <-time.After(100 * time.Millisecond): 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /pkg/server/images-tag.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/containerd/containerd/errdefs" 7 | "github.com/containerd/containerd/namespaces" 8 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 9 | "github.com/sirupsen/logrus" 10 | criv1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 11 | ) 12 | 13 | // Tag image server-side impl, adapted from containerd's `ctr tag` implementation 14 | func (i *Interface) Tag(ctx context.Context, req *imagesv1.ImageTagRequest) (*imagesv1.ImageTagResponse, error) { 15 | // containerd services require a namespace 16 | ctx, done, err := i.Containerd.WithLease(namespaces.WithNamespace(ctx, "k8s.io")) 17 | if err != nil { 18 | return nil, err 19 | } 20 | defer done(ctx) 21 | ref := req.Image.Image // TODO normalize this 22 | svc := i.Containerd.ImageService() 23 | img, err := svc.Get(ctx, ref) 24 | if err != nil { 25 | return nil, err 26 | } 27 | for _, tag := range req.Tags { 28 | img.Name = tag 29 | // Attempt to create the image first 30 | if _, err = svc.Create(ctx, img); err != nil { 31 | if errdefs.IsAlreadyExists(err) { 32 | if err = svc.Delete(ctx, tag); err != nil { 33 | return nil, err 34 | } 35 | if _, err = svc.Create(ctx, img); err != nil { 36 | return nil, err 37 | } 38 | } else { 39 | return nil, err 40 | } 41 | } 42 | logrus.Debugf("%#v", img) 43 | } 44 | res, err := i.ImageService.ImageStatus(ctx, &criv1.ImageStatusRequest{Image: req.Image}) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return &imagesv1.ImageTagResponse{ 49 | Image: res.Image, 50 | }, nil 51 | } 52 | -------------------------------------------------------------------------------- /pkg/server/images.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | 6 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 7 | criv1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 8 | ) 9 | 10 | // List images server-side impl 11 | func (i *Interface) List(ctx context.Context, req *imagesv1.ImageListRequest) (*imagesv1.ImageListResponse, error) { 12 | res, err := i.ImageService.ListImages(ctx, &criv1.ListImagesRequest{Filter: req.Filter}) 13 | if err != nil { 14 | return nil, err 15 | } 16 | return &imagesv1.ImageListResponse{ 17 | Images: res.Images, 18 | }, nil 19 | } 20 | 21 | // Status of an image server-side impl (unused) 22 | func (i *Interface) Status(ctx context.Context, req *imagesv1.ImageStatusRequest) (*imagesv1.ImageStatusResponse, error) { 23 | res, err := i.ImageService.ImageStatus(ctx, &criv1.ImageStatusRequest{Image: req.Image}) 24 | if err != nil { 25 | return nil, err 26 | } 27 | return &imagesv1.ImageStatusResponse{ 28 | Image: res.Image, 29 | }, nil 30 | } 31 | 32 | // Remove image server-side impl 33 | func (i *Interface) Remove(ctx context.Context, req *imagesv1.ImageRemoveRequest) (*imagesv1.ImageRemoveResponse, error) { 34 | _, err := i.ImageService.RemoveImage(ctx, &criv1.RemoveImageRequest{Image: req.Image}) 35 | if err != nil { 36 | return nil, err 37 | } 38 | return &imagesv1.ImageRemoveResponse{}, nil 39 | } 40 | -------------------------------------------------------------------------------- /pkg/server/server.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "sync" 5 | 6 | "github.com/containerd/containerd" 7 | buildkit "github.com/moby/buildkit/client" 8 | imagesv1 "github.com/rancher/k3c/pkg/apis/services/images/v1alpha1" 9 | "github.com/rancher/k3c/pkg/client" 10 | "github.com/sirupsen/logrus" 11 | criv1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 12 | ) 13 | 14 | var _ imagesv1.ImagesServer = &Interface{} 15 | 16 | type Interface struct { 17 | Kubernetes *client.Interface 18 | Buildkit *buildkit.Client 19 | Containerd *containerd.Client 20 | RuntimeService criv1.RuntimeServiceClient 21 | ImageService criv1.ImageServiceClient 22 | pushes sync.Map 23 | } 24 | 25 | // Close the Interface connections to various backends. 26 | func (i *Interface) Close() { 27 | if i.Buildkit != nil { 28 | if err := i.Buildkit.Close(); err != nil { 29 | logrus.Warnf("error closing connection to buildkit: %v", err) 30 | } 31 | } 32 | if i.Containerd != nil { 33 | // this will close the underlying grpc connection making the cri runtime/images clients inoperable as well 34 | if err := i.Containerd.Close(); err != nil { 35 | logrus.Warnf("error closing connection to containerd: %v", err) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /pkg/version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | var ( 8 | Version = "dev" 9 | GitCommit = "HEAD" 10 | ) 11 | 12 | func FriendlyVersion() string { 13 | return fmt.Sprintf("%s (%s)", Version, GitCommit) 14 | } 15 | --------------------------------------------------------------------------------