mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-16 07:10:54 +00:00
Compare commits
326 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d90825f4f0 | |||
| 5be757e35e | |||
| e51c1894bf | |||
| 24fcde56b6 | |||
| 7390e19e03 | |||
| 0aa0c0a995 | |||
| 1d10dd6ce7 | |||
| e28fa416ab | |||
| d6c7b1d770 | |||
| 92ea4a2505 | |||
| 3e5e0fc119 | |||
| 9fa4248e3b | |||
| d958a146f7 | |||
| 125a7c2c07 | |||
| d403150d77 | |||
| 4e6c52ec2a | |||
| 90ffa6883a | |||
| 4a85be68a0 | |||
| 19e4040b17 | |||
| 767323fde9 | |||
| 5be8231598 | |||
| e9f1947156 | |||
| 3d8c906c7f | |||
| d1bfd29dfd | |||
| 27ec594606 | |||
| f652a522fd | |||
| a794e87490 | |||
| 5b04d4fbe1 | |||
| 1566e193f6 | |||
| 601c8e9d52 | |||
| 8e5707dbcc | |||
| ad4d0c7b96 | |||
| a11e004943 | |||
| f605d86a4e | |||
| f1c0205e21 | |||
| f8bde63081 | |||
| 887ce71005 | |||
| 87233ceafe | |||
| 27c15680e8 | |||
| cb72e2d70f | |||
| 2cafbc8484 | |||
| 6dbb28b2b8 | |||
| d8a4a28259 | |||
| 7d124ac5c0 | |||
| abebdb94a5 | |||
| 9a217171c8 | |||
| c67cafcf94 | |||
| f7057a9517 | |||
| ae5379d84a | |||
| c05068c2e8 | |||
| 22bc2f9d0f | |||
| c07bf2b108 | |||
| e447fc0f1e | |||
| e062df68c5 | |||
| 664a5cd675 | |||
| 9ef217b351 | |||
| 67bd15487d | |||
| 7b45c4d380 | |||
| 6cbd80566f | |||
| 274bb2732a | |||
| 5935c7d5a0 | |||
| 4ab07fef23 | |||
| e7abc4d39a | |||
| 71b045366d | |||
| 7abac9537f | |||
| 9d64dc2fd9 | |||
| 6e1b49daa8 | |||
| 7bbfe88008 | |||
| 4c5db7d98c | |||
| cab280ebc0 | |||
| 2f78cf5129 | |||
| bc3755dcf7 | |||
| a5730feb9d | |||
| b8f084b1dc | |||
| 9fc50e347b | |||
| 034ab23ff1 | |||
| 865a0c92eb | |||
| b3a4eb8897 | |||
| 33536bd69f | |||
| 10bed44763 | |||
| 0111596d50 | |||
| 1df6ce531c | |||
| 1ad63d1786 | |||
| 895cf5e5c6 | |||
| 9b53deb97f | |||
| 6e9e9a6e31 | |||
| 90343b21d3 | |||
| 2369a2dadf | |||
| 237f43f8ba | |||
| 7fcac4ed49 | |||
| d52f325d99 | |||
| 921dfaddb9 | |||
| f642f3fde4 | |||
| f401cea76a | |||
| 76d3b27842 | |||
| 35ad56ff7f | |||
| 3bfc305df8 | |||
| 5ab866f0db | |||
| 12855db1a0 | |||
| e094d79b85 | |||
| 96394ecf38 | |||
| e9600f9d66 | |||
| 94ec8c4548 | |||
| bde3dcc5f5 | |||
| df10066c16 | |||
| 6b52a72359 | |||
| 608e0d8610 | |||
| 94c1b2b755 | |||
| c31ab7b43f | |||
| 0bbf61df95 | |||
| 1b58b88b02 | |||
| 61ef1fe798 | |||
| 863ec4dae9 | |||
| 5aa5b8d9cb | |||
| 37750cefda | |||
| 7be60cd8be | |||
| 606b701b00 | |||
| fe2f17d38a | |||
| 4aeba31a6a | |||
| 2086d424bd | |||
| 520eeea355 | |||
| dad2527182 | |||
| 9a3922fe17 | |||
| 9c2e95d614 | |||
| baba1165ff | |||
| a0610292a7 | |||
| de7f169043 | |||
| 97b7143f6d | |||
| 520b50e49b | |||
| 70cbc12ac7 | |||
| 9a01c64f68 | |||
| 673da76e55 | |||
| 146daa22a7 | |||
| 9150a75886 | |||
| 92bff40eb4 | |||
| 3fd90c74de | |||
| 5039f76fe8 | |||
| 15e14b2a93 | |||
| d41157bd54 | |||
| cfe853e791 | |||
| 4fa420699b | |||
| 2b9a7914fd | |||
| 3bf957c313 | |||
| 25dfd98672 | |||
| a1fd350573 | |||
| bbf5db745f | |||
| 884d695273 | |||
| 65a984ec2b | |||
| e06ecf5092 | |||
| 3bbd61d75b | |||
| 69f851124c | |||
| 5fef06100c | |||
| 40ba4ce958 | |||
| a8aeaff2a3 | |||
| d8fea9f142 | |||
| f33a9dccf8 | |||
| 5c4f97f88e | |||
| 4c7796ca56 | |||
| e6e102a95c | |||
| fee581c722 | |||
| f398ffb183 | |||
| 60e578bad9 | |||
| 55fc2f4d0c | |||
| dc74239275 | |||
| 75ad96e9ca | |||
| 265d1373a1 | |||
| 814ee037d3 | |||
| 4ab22a5fc5 | |||
| 6222250104 | |||
| f2b328395d | |||
| f3732b1683 | |||
| 82ddc7f9ce | |||
| 5031adcb7f | |||
| c5322ff2f6 | |||
| a1f1cf307b | |||
| 1b0cad0f1b | |||
| 29c2603d61 | |||
| ea9657dae0 | |||
| b61875fa9c | |||
| 1308c2f774 | |||
| 63bc8282a0 | |||
| cd0626e825 | |||
| dc4b4a86a4 | |||
| bb6df8ee63 | |||
| 199b5ab9b8 | |||
| 5719d6fcdd | |||
| 29e4ea6ec0 | |||
| 491c8ebdd1 | |||
| 3afb6e47bf | |||
| f767136371 | |||
| 86162f0ef5 | |||
| f03f8378b9 | |||
| 074b35755d | |||
| a92de0d9bd | |||
| f966258772 | |||
| 7938eebdcd | |||
| dccf1acb78 | |||
| 20278a7b5d | |||
| d4268fd4c6 | |||
| e7af54999f | |||
| 916d5a22c2 | |||
| abdd341369 | |||
| a802160318 | |||
| a5c7bde1a3 | |||
| 217a8a8e92 | |||
| e85459c529 | |||
| 2edaf38386 | |||
| cc7f75370f | |||
| 829d9924c3 | |||
| 164cefe2a2 | |||
| 9ac2e25739 | |||
| 1de4d69922 | |||
| dbc5ba9458 | |||
| 1459919984 | |||
| 11b9382e56 | |||
| c49c3cac30 | |||
| 165c79394b | |||
| 8fa7bc9206 | |||
| 842cbc0e44 | |||
| 014f4c49d1 | |||
| c9f52ab9f4 | |||
| c44eb676b0 | |||
| d29fbb8acf | |||
| 1566f9a229 | |||
| b65434650c | |||
| 4ba3e0b941 | |||
| 535d7149bd | |||
| e8df80555c | |||
| d978ae5a15 | |||
| 8de7940335 | |||
| b6a1adf90e | |||
| 910b969894 | |||
| 476f17b84c | |||
| 1fe6cbdb4c | |||
| fb9f92e99e | |||
| 056182923a | |||
| be0e5f1dad | |||
| 5add1af33b | |||
| bda3b8dad2 | |||
| 5679b4b1db | |||
| 7730890e7c | |||
| 7d2ddd44c0 | |||
| ba8c42d70b | |||
| 09ad0121c6 | |||
| 23e839c80b | |||
| bed9fffa94 | |||
| 4c3e0f8b3c | |||
| c3bd6a3eea | |||
| 93294dcb18 | |||
| 9492994b8c | |||
| 0394a30dd7 | |||
| 83c0c03257 | |||
| 4c5aa19a8f | |||
| 8adb6e37eb | |||
| 12211e127c | |||
| 4345e93446 | |||
| 29bdd9ff26 | |||
| f6225c4983 | |||
| b49bcafd67 | |||
| 3cbca50cad | |||
| 018a6bd2c7 | |||
| 8c2cd7117c | |||
| 13e67ee7ca | |||
| a40e6dd5d8 | |||
| 89fd04febb | |||
| ee9fb8dfec | |||
| 1949e77df8 | |||
| 44079e1ce2 | |||
| 76a9eeda7c | |||
| 2dd9a49f05 | |||
| aa7a862631 | |||
| 66d1f3878b | |||
| 4f12259bc0 | |||
| c926f2bf05 | |||
| 1ee35b841d | |||
| 1a802d7428 | |||
| 056c3d6dad | |||
| 64760ea779 | |||
| d1027dd016 | |||
| 37862fdb5c | |||
| bbc8eae484 | |||
| 8fd4a508f8 | |||
| 26ac72d142 | |||
| bbebb43808 | |||
| 35deb90803 | |||
| 9fdc90cf13 | |||
| 6fe53d9508 | |||
| 9141f1b343 | |||
| 80804b9b49 | |||
| 034a67ff7e | |||
| 8d6cc854aa | |||
| 0ed02327b0 | |||
| fac32a6def | |||
| 1d0a51886f | |||
| e65a50161d | |||
| 950bfadaba | |||
| fbac926044 | |||
| 7efd573010 | |||
| 2b589d1ded | |||
| 63762ba279 | |||
| fa01fd6ed5 | |||
| 57598ec9de | |||
| 5ccd8663f6 | |||
| d663c8e3cc | |||
| 22a9d9a369 | |||
| b6ebdd9c7b | |||
| 94ac71d4ce | |||
| 9666e1cf41 | |||
| 35bd883d40 | |||
| 8faca75d06 | |||
| b1deaba0bd | |||
| 32417bbb7e | |||
| b3596e7471 | |||
| 9bbd6b21b9 | |||
| 7d35c5c5bb | |||
| 7d1f66e537 | |||
| 2e9f8b8064 | |||
| 5703f81bac | |||
| 7f8edee078 | |||
| 991aa67efb | |||
| f6e8e05dad | |||
| 09c07b24dc | |||
| 3699db53b5 | |||
| 0b2469eef2 | |||
| 1d892e6b99 | |||
| f4e87ed80b |
@@ -30,10 +30,10 @@ jobs:
|
||||
GOPROXY: "https://proxy.golang.org"
|
||||
|
||||
steps:
|
||||
- name: "Install Packages"
|
||||
- name: "Install Test Packages"
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends graphviz gnupg2 gpgv2 git gcc make devscripts python3 python3-requests-unixsocket python3-termcolor python3-swiftclient python3-boto python3-azure-storage python3-etcd3 python3-plyvel flake8
|
||||
sudo apt-get install -y --no-install-recommends graphviz gnupg2 gpgv2 git gcc make devscripts python3 python3-requests-unixsocket python3-termcolor python3-swiftclient python3-boto python3-azure-storage python3-etcd3 python3-plyvel flake8 faketime
|
||||
|
||||
- name: "Checkout Repository"
|
||||
uses: actions/checkout@v4
|
||||
@@ -93,7 +93,7 @@ jobs:
|
||||
|
||||
- name: "Merge Code Coverage"
|
||||
run: |
|
||||
go install github.com/wadey/gocovmerge@latest
|
||||
go install github.com/wadey/gocovmerge@v0.0.0-20160331181800-b5bfa59ec0ad
|
||||
~/go/bin/gocovmerge unit.out ${{ runner.temp }}/*.out > coverage.txt
|
||||
|
||||
- name: "Upload Code Coverage"
|
||||
@@ -139,7 +139,7 @@ jobs:
|
||||
APT_LISTCHANGES_FRONTEND: none
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
steps:
|
||||
- name: "Install packages"
|
||||
- name: "Install Build Packages"
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends make ca-certificates git curl build-essential devscripts dh-golang jq bash-completion lintian \
|
||||
@@ -207,6 +207,23 @@ jobs:
|
||||
run: |
|
||||
.github/workflows/scripts/upload-artifacts.sh release ${{ matrix.suite }}
|
||||
|
||||
- name: "Get aptly version"
|
||||
env:
|
||||
FORCE_CI: ${{ steps.force_ci.outputs.FORCE_CI }}
|
||||
run: |
|
||||
aptlyver=$(make -s version)
|
||||
echo "Aptly Version: $aptlyver"
|
||||
echo "VERSION=$aptlyver" >> $GITHUB_OUTPUT
|
||||
id: releaseversion
|
||||
|
||||
- name: "Upload CI Artifacts"
|
||||
if: github.ref != 'refs/heads/master' && !startsWith(github.event.ref, 'refs/tags')
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: aptly_${{ steps.releaseversion.outputs.VERSION }}_${{ matrix.suite }}_${{ matrix.arch }}
|
||||
path: build/
|
||||
retention-days: 7
|
||||
|
||||
ci-binary-build:
|
||||
name: "Build"
|
||||
needs: test
|
||||
@@ -267,6 +284,15 @@ jobs:
|
||||
path: build/aptly_${{ steps.releaseversion.outputs.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
|
||||
compression-level: 0 # no compression
|
||||
|
||||
- name: "Upload CI Artifacts"
|
||||
uses: actions/upload-artifact@v4
|
||||
if: "!startsWith(github.event.ref, 'refs/tags')"
|
||||
with:
|
||||
name: aptly_${{ steps.releaseversion.outputs.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}
|
||||
path: build/aptly_${{ steps.releaseversion.outputs.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
|
||||
compression-level: 0 # no compression
|
||||
retention-days: 7
|
||||
|
||||
gh-release:
|
||||
name: "Github Release"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
# Require: The version of golangci-lint to use.
|
||||
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
|
||||
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
|
||||
version: v1.54.1
|
||||
version: v1.64.5
|
||||
|
||||
# Optional: working directory, useful for monorepos
|
||||
# working-directory: somedir
|
||||
|
||||
+10
-15
@@ -1,16 +1,11 @@
|
||||
run:
|
||||
tests: false
|
||||
|
||||
|
||||
version: "2"
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- goconst
|
||||
- gofmt
|
||||
- goimports
|
||||
- govet
|
||||
- ineffassign
|
||||
- misspell
|
||||
- revive
|
||||
- staticcheck
|
||||
- vetshadow
|
||||
settings:
|
||||
staticcheck:
|
||||
checks:
|
||||
- "all"
|
||||
- "-QF1004" # could use strings.ReplaceAll instead
|
||||
- "-QF1012" # Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...))
|
||||
- "-QF1003" # could use tagged switch
|
||||
- "-ST1000" # at least one file in a package should have a package comment
|
||||
- "-QF1001" # could apply De Morgan's law
|
||||
|
||||
@@ -68,3 +68,4 @@ List of contributors, in chronological order:
|
||||
* Blake Kostner (https://github.com/btkostner)
|
||||
* Leigh London (https://github.com/leighlondon)
|
||||
* Gordian Schoenherr (https://github.com/schoenherrg)
|
||||
* Silke Hofstra (https://github.com/silkeh)
|
||||
|
||||
@@ -2,13 +2,18 @@ GOPATH=$(shell go env GOPATH)
|
||||
VERSION=$(shell make -s version)
|
||||
PYTHON?=python3
|
||||
BINPATH?=$(GOPATH)/bin
|
||||
GOLANGCI_LINT_VERSION=v1.54.1 # version supporting go 1.19
|
||||
GOLANGCI_LINT_VERSION=v2.0.2 # version supporting go 1.24
|
||||
COVERAGE_DIR?=$(shell mktemp -d)
|
||||
GOOS=$(shell go env GOHOSTOS)
|
||||
GOARCH=$(shell go env GOHOSTARCH)
|
||||
|
||||
# Uncomment to update system test gold files
|
||||
# CAPTURE := "--capture"
|
||||
# Unit Tests and some sysmte tests rely on expired certificates, turn back the time
|
||||
export TEST_FAKETIME := 2025-01-02 03:04:05
|
||||
|
||||
# export CAPUTRE=1 for regenrating test gold files
|
||||
ifeq ($(CAPTURE),1)
|
||||
CAPTURE_ARG := --capture
|
||||
endif
|
||||
|
||||
help: ## Print this help
|
||||
@grep -E '^[a-zA-Z][a-zA-Z0-9_-]*:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
@@ -50,7 +55,7 @@ swagger-install:
|
||||
echo "// @version $(VERSION)" >> docs/swagger.conf
|
||||
|
||||
azurite-start:
|
||||
azurite -l /tmp/aptly-azurite & \
|
||||
azurite -l /tmp/aptly-azurite > ~/.azurite.log 2>&1 & \
|
||||
echo $$! > ~/.azurite.pid
|
||||
|
||||
azurite-stop:
|
||||
@@ -69,9 +74,9 @@ flake8: ## run flake8 on system test python files
|
||||
|
||||
lint: prepare
|
||||
# Install golangci-lint
|
||||
@test -f $(BINPATH)/golangci-lint || go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
|
||||
@test -f $(BINPATH)/golangci-lint || go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
|
||||
# Running lint
|
||||
@PATH=$(BINPATH)/:$(PATH) golangci-lint run
|
||||
@NO_COLOR=true PATH=$(BINPATH)/:$(PATH) golangci-lint run --max-issues-per-linter=0 --max-same-issues=0
|
||||
|
||||
|
||||
build: prepare swagger ## Build aptly
|
||||
@@ -84,11 +89,11 @@ install:
|
||||
# go install -v
|
||||
@out=`mktemp`; if ! go install -v > $$out 2>&1; then cat $$out; rm -f $$out; echo "\nBuild failed\n"; exit 1; else rm -f $$out; fi
|
||||
|
||||
test: prepare swagger etcd-install ## Run unit tests
|
||||
test: prepare swagger etcd-install ## Run unit tests (add TEST=regex to specify which tests to run)
|
||||
@echo "\e[33m\e[1mStarting etcd ...\e[0m"
|
||||
@mkdir -p /tmp/aptly-etcd-data; system/t13_etcd/start-etcd.sh > /tmp/aptly-etcd-data/etcd.log 2>&1 &
|
||||
@echo "\e[33m\e[1mRunning go test ...\e[0m"
|
||||
go test -v ./... -gocheck.v=true -coverprofile=unit.out; echo $$? > .unit-test.ret
|
||||
faketime "$(TEST_FAKETIME)" go test -v ./... -gocheck.v=true -check.f "$(TEST)" -coverprofile=unit.out; echo $$? > .unit-test.ret
|
||||
@echo "\e[33m\e[1mStopping etcd ...\e[0m"
|
||||
@pid=`cat /tmp/etcd.pid`; kill $$pid
|
||||
@rm -f /tmp/aptly-etcd-data/etcd.log
|
||||
@@ -102,7 +107,7 @@ system-test: prepare swagger etcd-install ## Run system tests
|
||||
if [ ! -e ~/aptly-fixture-pool ]; then git clone https://github.com/aptly-dev/aptly-fixture-pool.git ~/aptly-fixture-pool/; fi
|
||||
test -f ~/etcd.db || (curl -o ~/etcd.db.xz http://repo.aptly.info/system-tests/etcd.db.xz && xz -d ~/etcd.db.xz)
|
||||
# Run system tests
|
||||
PATH=$(BINPATH)/:$(PATH) && FORCE_COLOR=1 $(PYTHON) system/run.py --long --coverage-dir $(COVERAGE_DIR) $(CAPTURE) $(TEST)
|
||||
PATH=$(BINPATH)/:$(PATH) FORCE_COLOR=1 $(PYTHON) system/run.py --long --coverage-dir $(COVERAGE_DIR) $(CAPTURE_ARG) $(TEST)
|
||||
|
||||
bench:
|
||||
@echo "\e[33m\e[1mRunning benchmark ...\e[0m"
|
||||
@@ -162,6 +167,9 @@ binaries: prepare swagger ## Build binary releases (FreeBSD, macOS, Linux gener
|
||||
docker-image: ## Build aptly-dev docker image
|
||||
@docker build -f system/Dockerfile . -t aptly-dev
|
||||
|
||||
docker-image-no-cache: ## Build aptly-dev docker image (no cache)
|
||||
@docker build --no-cache -f system/Dockerfile . -t aptly-dev
|
||||
|
||||
docker-build: ## Build aptly in docker container
|
||||
@docker run -it --rm -v ${PWD}:/work/src aptly-dev /work/src/system/docker-wrapper build
|
||||
|
||||
@@ -171,13 +179,13 @@ docker-shell: ## Run aptly and other commands in docker container
|
||||
docker-deb: ## Build debian packages in docker container
|
||||
@docker run -it --rm -v ${PWD}:/work/src aptly-dev /work/src/system/docker-wrapper dpkg DEBARCH=amd64
|
||||
|
||||
docker-unit-test: ## Run unit tests in docker container
|
||||
docker-unit-test: ## Run unit tests in docker container (add TEST=regex to specify which tests to run)
|
||||
@docker run -it --rm -v ${PWD}:/work/src aptly-dev /work/src/system/docker-wrapper \
|
||||
azurite-start \
|
||||
AZURE_STORAGE_ENDPOINT=http://127.0.0.1:10000/devstoreaccount1 \
|
||||
AZURE_STORAGE_ACCOUNT=devstoreaccount1 \
|
||||
AZURE_STORAGE_ACCESS_KEY="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" \
|
||||
test \
|
||||
test TEST=$(TEST) \
|
||||
azurite-stop
|
||||
|
||||
docker-system-test: ## Run system tests in docker container (add TEST=t04_mirror or TEST=UpdateMirror26Test to run only specific tests)
|
||||
@@ -186,6 +194,8 @@ docker-system-test: ## Run system tests in docker container (add TEST=t04_mirro
|
||||
AZURE_STORAGE_ENDPOINT=http://127.0.0.1:10000/devstoreaccount1 \
|
||||
AZURE_STORAGE_ACCOUNT=devstoreaccount1 \
|
||||
AZURE_STORAGE_ACCESS_KEY="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" \
|
||||
AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) \
|
||||
AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY) \
|
||||
system-test TEST=$(TEST) \
|
||||
azurite-stop
|
||||
|
||||
|
||||
+2
-1
@@ -12,5 +12,6 @@ git push origin v$version master
|
||||
```
|
||||
- run swagger locally (`make docker-serve`)
|
||||
- copy generated docs/swagger.json to https://github.com/aptly-dev/www.aptly.info/tree/master/static/swagger/aptly_1.x.y.json
|
||||
- releae www.aptly.info
|
||||
- add new version to select tag in content/doc/api/swagger.md line 48
|
||||
- push commit to master
|
||||
- create release announcement on https://github.com/aptly-dev/aptly/discussions
|
||||
|
||||
+21
-17
@@ -41,7 +41,10 @@ type aptlyVersion struct {
|
||||
// @Success 200 {object} aptlyVersion
|
||||
// @Router /api/version [get]
|
||||
func apiVersion(c *gin.Context) {
|
||||
c.JSON(200, gin.H{"Version": aptly.Version})
|
||||
version := aptlyVersion{
|
||||
Version: aptly.Version,
|
||||
}
|
||||
c.JSON(200, version)
|
||||
}
|
||||
|
||||
type aptlyStatus struct {
|
||||
@@ -67,7 +70,8 @@ func apiReady(isReady *atomic.Value) func(*gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, gin.H{"Status": "Aptly is ready"})
|
||||
status := aptlyStatus{Status: "Aptly is ready"}
|
||||
c.JSON(200, status)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +169,7 @@ func runTaskInBackground(name string, resources []string, proc task.Process) (ta
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer releaseDatabaseConnection()
|
||||
defer func() { _ = releaseDatabaseConnection() }()
|
||||
return proc(out, detail)
|
||||
})
|
||||
}
|
||||
@@ -174,18 +178,18 @@ func truthy(value interface{}) bool {
|
||||
if value == nil {
|
||||
return false
|
||||
}
|
||||
switch value.(type) {
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
switch strings.ToLower(value.(string)) {
|
||||
switch strings.ToLower(v) {
|
||||
case "n", "no", "f", "false", "0", "off":
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
case int:
|
||||
return !(value.(int) == 0)
|
||||
return v != 0
|
||||
case bool:
|
||||
return value.(bool)
|
||||
return v
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -210,11 +214,11 @@ func maybeRunTaskInBackground(c *gin.Context, name string, resources []string, p
|
||||
}
|
||||
|
||||
// wait for task to finish
|
||||
context.TaskList().WaitForTaskByID(task.ID)
|
||||
_, _ = context.TaskList().WaitForTaskByID(task.ID)
|
||||
|
||||
retValue, _ := context.TaskList().GetTaskReturnValueByID(task.ID)
|
||||
err, _ := context.TaskList().GetTaskErrorByID(task.ID)
|
||||
context.TaskList().DeleteTaskByID(task.ID)
|
||||
_, _ = context.TaskList().DeleteTaskByID(task.ID)
|
||||
if err != nil {
|
||||
AbortWithJSONError(c, retValue.Code, err)
|
||||
return
|
||||
@@ -282,11 +286,11 @@ func showPackages(c *gin.Context, reflist *deb.PackageRefList, collectionFactory
|
||||
// filter packages by version
|
||||
if c.Request.URL.Query().Get("maximumVersion") == "1" {
|
||||
list.PrepareIndex()
|
||||
list.ForEach(func(p *deb.Package) error {
|
||||
_ = list.ForEach(func(p *deb.Package) error {
|
||||
versionQ, err := query.Parse(fmt.Sprintf("Name (%s), $Version (<= %s)", p.Name, p.Version))
|
||||
if err != nil {
|
||||
fmt.Println("filter packages by version, query string parse err: ", err)
|
||||
c.AbortWithError(500, fmt.Errorf("unable to parse %s maximum version query string: %s", p.Name, err))
|
||||
_ = c.AbortWithError(500, fmt.Errorf("unable to parse %s maximum version query string: %s", p.Name, err))
|
||||
} else {
|
||||
tmpList, err := list.Filter(deb.FilterOptions{
|
||||
Queries: []deb.PackageQuery{versionQ},
|
||||
@@ -294,15 +298,15 @@ func showPackages(c *gin.Context, reflist *deb.PackageRefList, collectionFactory
|
||||
|
||||
if err == nil {
|
||||
if tmpList.Len() > 0 {
|
||||
tmpList.ForEach(func(tp *deb.Package) error {
|
||||
_ = tmpList.ForEach(func(tp *deb.Package) error {
|
||||
list.Remove(tp)
|
||||
return nil
|
||||
})
|
||||
list.Add(p)
|
||||
_ = list.Add(p)
|
||||
}
|
||||
} else {
|
||||
fmt.Println("filter packages by version, filter err: ", err)
|
||||
c.AbortWithError(500, fmt.Errorf("unable to get %s maximum version: %s", p.Name, err))
|
||||
_ = c.AbortWithError(500, fmt.Errorf("unable to get %s maximum version: %s", p.Name, err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +315,7 @@ func showPackages(c *gin.Context, reflist *deb.PackageRefList, collectionFactory
|
||||
}
|
||||
|
||||
if c.Request.URL.Query().Get("format") == "details" {
|
||||
list.ForEach(func(p *deb.Package) error {
|
||||
_ = list.ForEach(func(p *deb.Package) error {
|
||||
result = append(result, p)
|
||||
return nil
|
||||
})
|
||||
@@ -322,7 +326,7 @@ func showPackages(c *gin.Context, reflist *deb.PackageRefList, collectionFactory
|
||||
}
|
||||
}
|
||||
|
||||
func AbortWithJSONError(c *gin.Context, code int, err error) *gin.Error {
|
||||
func AbortWithJSONError(c *gin.Context, code int, err error) {
|
||||
c.Writer.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
return c.AbortWithError(code, err)
|
||||
_ = c.AbortWithError(code, err)
|
||||
}
|
||||
|
||||
+17
-17
@@ -24,14 +24,14 @@ func Test(t *testing.T) {
|
||||
TestingT(t)
|
||||
}
|
||||
|
||||
type ApiSuite struct {
|
||||
type APISuite struct {
|
||||
context *ctx.AptlyContext
|
||||
flags *flag.FlagSet
|
||||
configFile *os.File
|
||||
router http.Handler
|
||||
}
|
||||
|
||||
var _ = Suite(&ApiSuite{})
|
||||
var _ = Suite(&APISuite{})
|
||||
|
||||
func createTestConfig() *os.File {
|
||||
file, err := os.CreateTemp("", "aptly")
|
||||
@@ -45,11 +45,11 @@ func createTestConfig() *os.File {
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
file.Write(jsonString)
|
||||
_, _ = file.Write(jsonString)
|
||||
return file
|
||||
}
|
||||
|
||||
func (s *ApiSuite) setupContext() error {
|
||||
func (s *APISuite) setupContext() error {
|
||||
aptly.Version = "testVersion"
|
||||
file := createTestConfig()
|
||||
if nil == file {
|
||||
@@ -75,23 +75,23 @@ func (s *ApiSuite) setupContext() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ApiSuite) SetUpSuite(c *C) {
|
||||
func (s *APISuite) SetUpSuite(c *C) {
|
||||
err := s.setupContext()
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
func (s *ApiSuite) TearDownSuite(c *C) {
|
||||
os.Remove(s.configFile.Name())
|
||||
func (s *APISuite) TearDownSuite(c *C) {
|
||||
_ = os.Remove(s.configFile.Name())
|
||||
s.context.Shutdown()
|
||||
}
|
||||
|
||||
func (s *ApiSuite) SetUpTest(c *C) {
|
||||
func (s *APISuite) SetUpTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *ApiSuite) TearDownTest(c *C) {
|
||||
func (s *APISuite) TearDownTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *ApiSuite) HTTPRequest(method string, url string, body io.Reader) (*httptest.ResponseRecorder, error) {
|
||||
func (s *APISuite) HTTPRequest(method string, url string, body io.Reader) (*httptest.ResponseRecorder, error) {
|
||||
w := httptest.NewRecorder()
|
||||
req, err := http.NewRequest(method, url, body)
|
||||
if err != nil {
|
||||
@@ -102,32 +102,32 @@ func (s *ApiSuite) HTTPRequest(method string, url string, body io.Reader) (*http
|
||||
return w, nil
|
||||
}
|
||||
|
||||
func (s *ApiSuite) TestGinRunsInReleaseMode(c *C) {
|
||||
func (s *APISuite) TestGinRunsInReleaseMode(c *C) {
|
||||
c.Check(gin.Mode(), Equals, gin.ReleaseMode)
|
||||
}
|
||||
|
||||
func (s *ApiSuite) TestGetVersion(c *C) {
|
||||
func (s *APISuite) TestGetVersion(c *C) {
|
||||
response, err := s.HTTPRequest("GET", "/api/version", nil)
|
||||
c.Assert(err, IsNil)
|
||||
c.Check(response.Code, Equals, 200)
|
||||
c.Check(response.Body.String(), Matches, "{\"Version\":\""+aptly.Version+"\"}")
|
||||
}
|
||||
|
||||
func (s *ApiSuite) TestGetReadiness(c *C) {
|
||||
func (s *APISuite) TestGetReadiness(c *C) {
|
||||
response, err := s.HTTPRequest("GET", "/api/ready", nil)
|
||||
c.Assert(err, IsNil)
|
||||
c.Check(response.Code, Equals, 200)
|
||||
c.Check(response.Body.String(), Matches, "{\"Status\":\"Aptly is ready\"}")
|
||||
}
|
||||
|
||||
func (s *ApiSuite) TestGetHealthiness(c *C) {
|
||||
func (s *APISuite) TestGetHealthiness(c *C) {
|
||||
response, err := s.HTTPRequest("GET", "/api/healthy", nil)
|
||||
c.Assert(err, IsNil)
|
||||
c.Check(response.Code, Equals, 200)
|
||||
c.Check(response.Body.String(), Matches, "{\"Status\":\"Aptly is healthy\"}")
|
||||
}
|
||||
|
||||
func (s *ApiSuite) TestGetMetrics(c *C) {
|
||||
func (s *APISuite) TestGetMetrics(c *C) {
|
||||
response, err := s.HTTPRequest("GET", "/api/metrics", nil)
|
||||
c.Assert(err, IsNil)
|
||||
c.Check(response.Code, Equals, 200)
|
||||
@@ -141,7 +141,7 @@ func (s *ApiSuite) TestGetMetrics(c *C) {
|
||||
c.Check(b, Matches, ".*aptly_build_info.*version=\"testVersion\".*")
|
||||
}
|
||||
|
||||
func (s *ApiSuite) TestRepoCreate(c *C) {
|
||||
func (s *APISuite) TestRepoCreate(c *C) {
|
||||
body, err := json.Marshal(gin.H{
|
||||
"Name": "dummy",
|
||||
})
|
||||
@@ -150,7 +150,7 @@ func (s *ApiSuite) TestRepoCreate(c *C) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
func (s *ApiSuite) TestTruthy(c *C) {
|
||||
func (s *APISuite) TestTruthy(c *C) {
|
||||
c.Check(truthy("no"), Equals, false)
|
||||
c.Check(truthy("n"), Equals, false)
|
||||
c.Check(truthy("off"), Equals, false)
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
// @Success 200 {object} string "Output"
|
||||
// @Failure 404 {object} Error "Not Found"
|
||||
// @Router /api/db/cleanup [post]
|
||||
func apiDbCleanup(c *gin.Context) {
|
||||
func apiDBCleanup(c *gin.Context) {
|
||||
resources := []string{string(task.AllResourcesKey)}
|
||||
maybeRunTaskInBackground(c, "Clean up db", resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) {
|
||||
var err error
|
||||
@@ -109,8 +109,8 @@ func apiDbCleanup(c *gin.Context) {
|
||||
|
||||
if toDelete.Len() > 0 {
|
||||
batch := db.CreateBatch()
|
||||
toDelete.ForEach(func(ref []byte) error {
|
||||
collectionFactory.PackageCollection().DeleteByKey(ref, batch)
|
||||
_ = toDelete.ForEach(func(ref []byte) error {
|
||||
_ = collectionFactory.PackageCollection().DeleteByKey(ref, batch)
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
+2
-2
@@ -122,7 +122,7 @@ func apiFilesUpload(c *gin.Context) {
|
||||
AbortWithJSONError(c, 500, err)
|
||||
return
|
||||
}
|
||||
defer src.Close()
|
||||
defer func() { _ = src.Close() }()
|
||||
|
||||
destPath := filepath.Join(path, filepath.Base(file.Filename))
|
||||
dst, err := os.Create(destPath)
|
||||
@@ -130,7 +130,7 @@ func apiFilesUpload(c *gin.Context) {
|
||||
AbortWithJSONError(c, 500, err)
|
||||
return
|
||||
}
|
||||
defer dst.Close()
|
||||
defer func() { _ = dst.Close() }()
|
||||
|
||||
_, err = io.Copy(dst, src)
|
||||
if err != nil {
|
||||
|
||||
+17
-9
@@ -13,26 +13,34 @@ import (
|
||||
)
|
||||
|
||||
type gpgAddKeyParams struct {
|
||||
// Keyserver, when downloading GpgKeyIDs
|
||||
Keyserver string `json:"Keyserver" example:"hkp://keyserver.ubuntu.com:80"`
|
||||
// GpgKeyIDs to download from Keyserver, comma separated list
|
||||
GpgKeyID string `json:"GpgKeyID" example:"EF0F382A1A7B6500,8B48AD6246925553"`
|
||||
// Armored gpg public ket, instead of downloading from keyserver
|
||||
GpgKeyArmor string `json:"GpgKeyArmor" example:""`
|
||||
// Keyring for adding the keys (default: trustedkeys.gpg)
|
||||
Keyring string `json:"Keyring" example:"trustedkeys.gpg"`
|
||||
|
||||
// Add ASCII armored gpg public key, do not download from keyserver
|
||||
GpgKeyArmor string `json:"GpgKeyArmor" example:""`
|
||||
|
||||
// Keyserver to download keys provided in `GpgKeyID`
|
||||
Keyserver string `json:"Keyserver" example:"hkp://keyserver.ubuntu.com:80"`
|
||||
// Keys do download from `Keyserver`, separated by space
|
||||
GpgKeyID string `json:"GpgKeyID" example:"EF0F382A1A7B6500 8B48AD6246925553"`
|
||||
}
|
||||
|
||||
// @Summary Add GPG Keys
|
||||
// @Description **Adds GPG keys to aptly keyring**
|
||||
// @Description
|
||||
// @Description Add GPG public keys for veryfing remote repositories for mirroring.
|
||||
// @Description
|
||||
// @Description Keys can be added in two ways:
|
||||
// @Description * By providing the ASCII armord key in `GpgKeyArmor` (leave Keyserver and GpgKeyID empty)
|
||||
// @Description * By providing a `Keyserver` and one or more key IDs in `GpgKeyID`, separated by space (leave GpgKeyArmor empty)
|
||||
// @Description
|
||||
// @Tags Mirrors
|
||||
// @Consume json
|
||||
// @Param request body gpgAddKeyParams true "Parameters"
|
||||
// @Produce json
|
||||
// @Success 200 {object} string "OK"
|
||||
// @Failure 400 {object} Error "Bad Request"
|
||||
// @Failure 404 {object} Error "Not Found"
|
||||
// @Router /api/gpg [post]
|
||||
// @Router /api/gpg/key [post]
|
||||
func apiGPGAddKey(c *gin.Context) {
|
||||
b := gpgAddKeyParams{}
|
||||
if c.Bind(&b) != nil {
|
||||
@@ -60,7 +68,7 @@ func apiGPGAddKey(c *gin.Context) {
|
||||
AbortWithJSONError(c, 400, err)
|
||||
return
|
||||
}
|
||||
defer os.RemoveAll(tempdir)
|
||||
defer func() { _ = os.RemoveAll(tempdir) }()
|
||||
|
||||
keypath := filepath.Join(tempdir, "key")
|
||||
keyfile, e := os.Create(keypath)
|
||||
|
||||
+12
-12
@@ -67,17 +67,17 @@ func (s *MiddlewareSuite) TestJSONMiddleware4xx(c *C) {
|
||||
outC := make(chan string)
|
||||
go func() {
|
||||
var buf bytes.Buffer
|
||||
io.Copy(&buf, s.logReader)
|
||||
_, _ = io.Copy(&buf, s.logReader)
|
||||
fmt.Println(buf.String())
|
||||
outC <- buf.String()
|
||||
}()
|
||||
|
||||
s.HTTPRequest(http.MethodGet, "/", nil)
|
||||
s.logWriter.Close()
|
||||
_ = s.logWriter.Close()
|
||||
capturedOutput := <-outC
|
||||
|
||||
var jsonMap map[string]interface{}
|
||||
json.Unmarshal([]byte(capturedOutput), &jsonMap)
|
||||
_ = json.Unmarshal([]byte(capturedOutput), &jsonMap)
|
||||
|
||||
if val, ok := jsonMap["level"]; ok {
|
||||
c.Check(val, Equals, "warn")
|
||||
@@ -130,17 +130,17 @@ func (s *MiddlewareSuite) TestJSONMiddleware2xx(c *C) {
|
||||
outC := make(chan string)
|
||||
go func() {
|
||||
var buf bytes.Buffer
|
||||
io.Copy(&buf, s.logReader)
|
||||
_, _ = io.Copy(&buf, s.logReader)
|
||||
fmt.Println(buf.String())
|
||||
outC <- buf.String()
|
||||
}()
|
||||
|
||||
s.HTTPRequest(http.MethodGet, "/api/healthy", nil)
|
||||
s.logWriter.Close()
|
||||
_ = s.logWriter.Close()
|
||||
capturedOutput := <-outC
|
||||
|
||||
var jsonMap map[string]interface{}
|
||||
json.Unmarshal([]byte(capturedOutput), &jsonMap)
|
||||
_ = json.Unmarshal([]byte(capturedOutput), &jsonMap)
|
||||
|
||||
if val, ok := jsonMap["level"]; ok {
|
||||
c.Check(val, Equals, "info")
|
||||
@@ -153,17 +153,17 @@ func (s *MiddlewareSuite) TestJSONMiddleware5xx(c *C) {
|
||||
outC := make(chan string)
|
||||
go func() {
|
||||
var buf bytes.Buffer
|
||||
io.Copy(&buf, s.logReader)
|
||||
_, _ = io.Copy(&buf, s.logReader)
|
||||
fmt.Println(buf.String())
|
||||
outC <- buf.String()
|
||||
}()
|
||||
|
||||
s.HTTPRequest(http.MethodGet, "/api/ready", nil)
|
||||
s.logWriter.Close()
|
||||
_ = s.logWriter.Close()
|
||||
capturedOutput := <-outC
|
||||
|
||||
var jsonMap map[string]interface{}
|
||||
json.Unmarshal([]byte(capturedOutput), &jsonMap)
|
||||
_ = json.Unmarshal([]byte(capturedOutput), &jsonMap)
|
||||
|
||||
if val, ok := jsonMap["level"]; ok {
|
||||
c.Check(val, Equals, "error")
|
||||
@@ -176,17 +176,17 @@ func (s *MiddlewareSuite) TestJSONMiddlewareRaw(c *C) {
|
||||
outC := make(chan string)
|
||||
go func() {
|
||||
var buf bytes.Buffer
|
||||
io.Copy(&buf, s.logReader)
|
||||
_, _ = io.Copy(&buf, s.logReader)
|
||||
fmt.Println(buf.String())
|
||||
outC <- buf.String()
|
||||
}()
|
||||
|
||||
s.HTTPRequest(http.MethodGet, "/api/healthy?test=raw", nil)
|
||||
s.logWriter.Close()
|
||||
_ = s.logWriter.Close()
|
||||
capturedOutput := <-outC
|
||||
|
||||
var jsonMap map[string]interface{}
|
||||
json.Unmarshal([]byte(capturedOutput), &jsonMap)
|
||||
_ = json.Unmarshal([]byte(capturedOutput), &jsonMap)
|
||||
|
||||
fmt.Println(capturedOutput)
|
||||
|
||||
|
||||
+5
-5
@@ -43,7 +43,7 @@ func apiMirrorsList(c *gin.Context) {
|
||||
collection := collectionFactory.RemoteRepoCollection()
|
||||
|
||||
result := []*deb.RemoteRepo{}
|
||||
collection.ForEach(func(repo *deb.RemoteRepo) error {
|
||||
_ = collection.ForEach(func(repo *deb.RemoteRepo) error {
|
||||
result = append(result, repo)
|
||||
return nil
|
||||
})
|
||||
@@ -319,7 +319,7 @@ func apiMirrorsPackages(c *gin.Context) {
|
||||
}
|
||||
|
||||
if c.Request.URL.Query().Get("format") == "details" {
|
||||
list.ForEach(func(p *deb.Package) error {
|
||||
_ = list.ForEach(func(p *deb.Package) error {
|
||||
result = append(result, p)
|
||||
return nil
|
||||
})
|
||||
@@ -491,7 +491,7 @@ func apiMirrorsUpdate(c *gin.Context) {
|
||||
e := context.ReOpenDatabase()
|
||||
if e == nil {
|
||||
remote.MarkAsIdle()
|
||||
collection.Update(remote)
|
||||
_ = collection.Update(remote)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -579,7 +579,7 @@ func apiMirrorsUpdate(c *gin.Context) {
|
||||
file, e = os.CreateTemp("", task.File.Filename)
|
||||
if e == nil {
|
||||
task.TempDownPath = file.Name()
|
||||
file.Close()
|
||||
_ = file.Close()
|
||||
}
|
||||
}
|
||||
if e != nil {
|
||||
@@ -653,7 +653,7 @@ func apiMirrorsUpdate(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.Info().Msgf("%s: Finalizing download...", b.Name)
|
||||
remote.FinalizeDownload(collectionFactory, out)
|
||||
_ = remote.FinalizeDownload(collectionFactory, out)
|
||||
err = collectionFactory.RemoteRepoCollection().Update(remote)
|
||||
if err != nil {
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err)
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type MirrorSuite struct {
|
||||
ApiSuite
|
||||
APISuite
|
||||
}
|
||||
|
||||
var _ = Suite(&MirrorSuite{})
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
type PackagesSuite struct {
|
||||
ApiSuite
|
||||
APISuite
|
||||
}
|
||||
|
||||
var _ = Suite(&PackagesSuite{})
|
||||
|
||||
+9
-9
@@ -343,7 +343,7 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
|
||||
|
||||
duplicate := collection.CheckDuplicate(published)
|
||||
if duplicate != nil {
|
||||
collectionFactory.PublishedRepoCollection().LoadComplete(duplicate, collectionFactory)
|
||||
_ = collectionFactory.PublishedRepoCollection().LoadComplete(duplicate, collectionFactory)
|
||||
return &task.ProcessReturnValue{Code: http.StatusBadRequest, Value: nil}, fmt.Errorf("prefix/distribution already used by another published repo: %s", duplicate)
|
||||
}
|
||||
|
||||
@@ -471,7 +471,7 @@ func apiPublishUpdateSwitch(c *gin.Context) {
|
||||
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
|
||||
err = collection.LoadComplete(published, collectionFactory)
|
||||
if err != nil {
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("Unable to update: %s", err)
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err)
|
||||
}
|
||||
|
||||
revision := published.ObtainRevision()
|
||||
@@ -487,12 +487,12 @@ func apiPublishUpdateSwitch(c *gin.Context) {
|
||||
|
||||
result, err := published.Update(collectionFactory, out)
|
||||
if err != nil {
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("Unable to update: %s", err)
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err)
|
||||
}
|
||||
|
||||
err = published.Publish(context.PackagePool(), context, collectionFactory, signer, out, b.ForceOverwrite, context.SkelPath())
|
||||
if err != nil {
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("Unable to update: %s", err)
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err)
|
||||
}
|
||||
|
||||
err = collection.Update(published)
|
||||
@@ -625,7 +625,7 @@ func apiPublishAddSource(c *gin.Context) {
|
||||
|
||||
resources := []string{string(published.Key())}
|
||||
taskName := fmt.Sprintf("Update published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution)
|
||||
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
|
||||
maybeRunTaskInBackground(c, taskName, resources, func(_ aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
|
||||
err = collection.Update(published)
|
||||
if err != nil {
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to save to DB: %s", err)
|
||||
@@ -739,7 +739,7 @@ func apiPublishSetSources(c *gin.Context) {
|
||||
|
||||
resources := []string{string(published.Key())}
|
||||
taskName := fmt.Sprintf("Update published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution)
|
||||
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
|
||||
maybeRunTaskInBackground(c, taskName, resources, func(_ aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
|
||||
err = collection.Update(published)
|
||||
if err != nil {
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to save to DB: %s", err)
|
||||
@@ -789,7 +789,7 @@ func apiPublishDropChanges(c *gin.Context) {
|
||||
|
||||
resources := []string{string(published.Key())}
|
||||
taskName := fmt.Sprintf("Update published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution)
|
||||
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
|
||||
maybeRunTaskInBackground(c, taskName, resources, func(_ aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
|
||||
err = collection.Update(published)
|
||||
if err != nil {
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to save to DB: %s", err)
|
||||
@@ -869,7 +869,7 @@ func apiPublishUpdateSource(c *gin.Context) {
|
||||
|
||||
resources := []string{string(published.Key())}
|
||||
taskName := fmt.Sprintf("Update published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution)
|
||||
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
|
||||
maybeRunTaskInBackground(c, taskName, resources, func(_ aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
|
||||
err = collection.Update(published)
|
||||
if err != nil {
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to save to DB: %s", err)
|
||||
@@ -932,7 +932,7 @@ func apiPublishRemoveSource(c *gin.Context) {
|
||||
|
||||
resources := []string{string(published.Key())}
|
||||
taskName := fmt.Sprintf("Update published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution)
|
||||
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
|
||||
maybeRunTaskInBackground(c, taskName, resources, func(_ aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
|
||||
err = collection.Update(published)
|
||||
if err != nil {
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to save to DB: %s", err)
|
||||
|
||||
+38
-32
@@ -29,14 +29,14 @@ func reposListInAPIMode(localRepos map[string]utils.FileSystemPublishRoot) gin.H
|
||||
return func(c *gin.Context) {
|
||||
c.Writer.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
c.Writer.Flush()
|
||||
c.Writer.WriteString("<pre>\n")
|
||||
_, _ = c.Writer.WriteString("<pre>\n")
|
||||
if len(localRepos) == 0 {
|
||||
c.Writer.WriteString("<a href=\"-/\">default</a>\n")
|
||||
_, _ = c.Writer.WriteString("<a href=\"-/\">default</a>\n")
|
||||
}
|
||||
for publishPrefix := range localRepos {
|
||||
c.Writer.WriteString(fmt.Sprintf("<a href=\"%[1]s/\">%[1]s</a>\n", publishPrefix))
|
||||
_, _ = c.Writer.WriteString(fmt.Sprintf("<a href=\"%[1]s/\">%[1]s</a>\n", publishPrefix))
|
||||
}
|
||||
c.Writer.WriteString("</pre>")
|
||||
_, _ = c.Writer.WriteString("</pre>")
|
||||
c.Writer.Flush()
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func apiReposList(c *gin.Context) {
|
||||
|
||||
collectionFactory := context.NewCollectionFactory()
|
||||
collection := collectionFactory.LocalRepoCollection()
|
||||
collection.ForEach(func(r *deb.LocalRepo) error {
|
||||
_ = collection.ForEach(func(r *deb.LocalRepo) error {
|
||||
result = append(result, r)
|
||||
return nil
|
||||
})
|
||||
@@ -107,9 +107,9 @@ type repoCreateParams struct {
|
||||
// @Description {"Name":"aptly-repo","Comment":"","DefaultDistribution":"","DefaultComponent":""}
|
||||
// @Description ```
|
||||
// @Tags Repos
|
||||
// @Produce json
|
||||
// @Consume json
|
||||
// @Param request body repoCreateParams true "Parameters"
|
||||
// @Produce json
|
||||
// @Success 201 {object} deb.LocalRepo
|
||||
// @Failure 404 {object} Error "Source snapshot not found"
|
||||
// @Failure 409 {object} Error "Local repo already exists"
|
||||
@@ -178,8 +178,10 @@ type reposEditParams struct {
|
||||
// @Summary Update Repository
|
||||
// @Description **Update local repository meta information**
|
||||
// @Tags Repos
|
||||
// @Produce json
|
||||
// @Param name path string true "Repository name"
|
||||
// @Consume json
|
||||
// @Param request body reposEditParams true "Parameters"
|
||||
// @Produce json
|
||||
// @Success 200 {object} deb.LocalRepo "msg"
|
||||
// @Failure 404 {object} Error "Not Found"
|
||||
// @Failure 500 {object} Error "Internal Server Error"
|
||||
@@ -231,8 +233,8 @@ func apiReposEdit(c *gin.Context) {
|
||||
// @Summary Get Repository Info
|
||||
// @Description Returns basic information about local repository.
|
||||
// @Tags Repos
|
||||
// @Produce json
|
||||
// @Param name path string true "Repository name"
|
||||
// @Produce json
|
||||
// @Success 200 {object} deb.LocalRepo
|
||||
// @Failure 404 {object} Error "Repository not found"
|
||||
// @Router /api/repos/{name} [get]
|
||||
@@ -254,9 +256,10 @@ func apiReposShow(c *gin.Context) {
|
||||
// @Description Cannot drop repos that are published.
|
||||
// @Description Needs force=1 to drop repos used as source by other repos.
|
||||
// @Tags Repos
|
||||
// @Produce json
|
||||
// @Param name path string true "Repository name"
|
||||
// @Param _async query bool false "Run in background and return task object"
|
||||
// @Param force query int false "force: 1 to enable"
|
||||
// @Produce json
|
||||
// @Success 200 {object} task.ProcessReturnValue "Repo object"
|
||||
// @Failure 404 {object} Error "Not Found"
|
||||
// @Failure 404 {object} Error "Repo Conflict"
|
||||
@@ -306,12 +309,12 @@ func apiReposDrop(c *gin.Context) {
|
||||
// @Description ["Pi386 aptly 0.8 966561016b44ed80"]
|
||||
// @Description ```
|
||||
// @Tags Repos
|
||||
// @Produce json
|
||||
// @Param name path string true "Snapshot to search"
|
||||
// @Param name path string true "Repository name"
|
||||
// @Param q query string true "Package query (e.g Name%20(~%20matlab))"
|
||||
// @Param withDeps query string true "Set to 1 to include dependencies when evaluating package query"
|
||||
// @Param format query string true "Set to 'details' to return extra info about each package"
|
||||
// @Param maximumVersion query string true "Set to 1 to only return the highest version for each package name"
|
||||
// @Produce json
|
||||
// @Success 200 {object} string "msg"
|
||||
// @Failure 404 {object} Error "Not Found"
|
||||
// @Failure 404 {object} Error "Internal Server Error"
|
||||
@@ -406,9 +409,10 @@ func apiReposPackagesAddDelete(c *gin.Context, taskNamePrefix string, cb func(li
|
||||
// @Description
|
||||
// @Description API verifies that packages actually exist in aptly database and checks constraint that conflicting packages can’t be part of the same local repository.
|
||||
// @Tags Repos
|
||||
// @Produce json
|
||||
// @Param name path string true "Repository name"
|
||||
// @Param request body reposPackagesAddDeleteParams true "Parameters"
|
||||
// @Param _async query bool false "Run in background and return task object"
|
||||
// @Produce json
|
||||
// @Success 200 {object} string "msg"
|
||||
// @Failure 400 {object} Error "Bad Request"
|
||||
// @Failure 404 {object} Error "Not Found"
|
||||
@@ -426,9 +430,11 @@ func apiReposPackagesAdd(c *gin.Context) {
|
||||
// @Description
|
||||
// @Description Any package(s) can be removed from a local repository. Package references from a local repository can be retrieved with GET /api/repos/:name/packages.
|
||||
// @Tags Repos
|
||||
// @Produce json
|
||||
// @Param request body reposPackagesAddDeleteParams true "Parameters"
|
||||
// @Param name path string true "Repository name"
|
||||
// @Param _async query bool false "Run in background and return task object"
|
||||
// @Consume json
|
||||
// @Param request body reposPackagesAddDeleteParams true "Parameters"
|
||||
// @Produce json
|
||||
// @Success 200 {object} string "msg"
|
||||
// @Failure 400 {object} Error "Bad Request"
|
||||
// @Failure 404 {object} Error "Not Found"
|
||||
@@ -570,7 +576,7 @@ func apiReposPackageFromDir(c *gin.Context) {
|
||||
}
|
||||
|
||||
// atempt to remove dir, if it fails, that's fine: probably it's not empty
|
||||
os.Remove(filepath.Join(context.UploadPath(), dirParam))
|
||||
_ = os.Remove(filepath.Join(context.UploadPath(), dirParam))
|
||||
}
|
||||
|
||||
if failedFiles == nil {
|
||||
@@ -608,8 +614,8 @@ type reposCopyPackageParams struct {
|
||||
// @Description Copies a package from a source to destination repository
|
||||
// @Tags Repos
|
||||
// @Produce json
|
||||
// @Param name path string true "Source repo"
|
||||
// @Param src path string true "Destination repo"
|
||||
// @Param name path string true "Destination repo"
|
||||
// @Param src path string true "Source repo"
|
||||
// @Param file path string true "File/packages to copy"
|
||||
// @Param _async query bool false "Run in background and return task object"
|
||||
// @Success 200 {object} task.ProcessReturnValue "msg"
|
||||
@@ -762,12 +768,15 @@ func apiReposCopyPackage(c *gin.Context) {
|
||||
// @Summary Include File from Directory
|
||||
// @Description Allows automatic processing of .changes file controlling package upload (uploaded using File Upload API) to the local repository. i.e. Exposes repo include command in api.
|
||||
// @Tags Repos
|
||||
// @Produce json
|
||||
// @Param name path string true "Repository name"
|
||||
// @Param dir path string true "Directory of packages"
|
||||
// @Param file path string true "File/packages to include"
|
||||
// @Param forceReplace query int false "when value is set to 1, when adding package that conflicts with existing package, remove existing package"
|
||||
// @Param noRemoveFiles query int false "when value is set to 1, don’t remove files that have been imported successfully into repository"
|
||||
// @Param acceptUnsigned query int false "when value is set to 1, accept unsigned .changes files"
|
||||
// @Param ignoreSignature query int false "when value is set to 1 disable verification of .changes file signature"
|
||||
// @Param _async query bool false "Run in background and return task object"
|
||||
// @Produce json
|
||||
// @Success 200 {object} string "msg"
|
||||
// @Failure 404 {object} Error "Not Found"
|
||||
// @Router /api/repos/{name}/include/{dir}/{file} [post]
|
||||
@@ -776,26 +785,22 @@ func apiReposIncludePackageFromFile(c *gin.Context) {
|
||||
apiReposIncludePackageFromDir(c)
|
||||
}
|
||||
|
||||
type reposIncludePackageFromDirReport struct {
|
||||
Warnings []string
|
||||
Added []string
|
||||
Deleted []string
|
||||
}
|
||||
|
||||
type reposIncludePackageFromDirResponse struct {
|
||||
Report reposIncludePackageFromDirReport
|
||||
Report *aptly.RecordingResultReporter
|
||||
FailedFiles []string
|
||||
}
|
||||
|
||||
// @Summary Include Directory
|
||||
// @Description Allows automatic processing of .changes file controlling package upload (uploaded using File Upload API) to the local repository. i.e. Exposes repo include command in api.
|
||||
// @Tags Repos
|
||||
// @Produce json
|
||||
// @Param name path string true "Repository name"
|
||||
// @Param dir path string true "Directory of packages"
|
||||
// @Param forceReplace query int false "when value is set to 1, when adding package that conflicts with existing package, remove existing package"
|
||||
// @Param noRemoveFiles query int false "when value is set to 1, don’t remove files that have been imported successfully into repository"
|
||||
// @Param acceptUnsigned query int false "when value is set to 1, accept unsigned .changes files"
|
||||
// @Param ignoreSignature query int false "when value is set to 1 disable verification of .changes file signature"
|
||||
// @Param _async query bool false "Run in background and return task object"
|
||||
// @Produce json
|
||||
// @Success 200 {object} reposIncludePackageFromDirResponse "Response"
|
||||
// @Failure 404 {object} Error "Not Found"
|
||||
// @Router /api/repos/{name}/include/{dir} [post]
|
||||
@@ -836,7 +841,7 @@ func apiReposIncludePackageFromDir(c *gin.Context) {
|
||||
}
|
||||
|
||||
var resources []string
|
||||
if len(repoTemplate.Tree.Root.Nodes) > 1 {
|
||||
if len(repoTemplate.Root.Nodes) > 1 {
|
||||
resources = append(resources, task.AllLocalReposResourcesKey)
|
||||
} else {
|
||||
// repo template string is simple text so only use resource key of specific repository
|
||||
@@ -876,7 +881,7 @@ func apiReposIncludePackageFromDir(c *gin.Context) {
|
||||
|
||||
if !noRemoveFiles {
|
||||
// atempt to remove dir, if it fails, that's fine: probably it's not empty
|
||||
os.Remove(filepath.Join(context.UploadPath(), dirParam))
|
||||
_ = os.Remove(filepath.Join(context.UploadPath(), dirParam))
|
||||
}
|
||||
|
||||
if failedFiles == nil {
|
||||
@@ -896,9 +901,10 @@ func apiReposIncludePackageFromDir(c *gin.Context) {
|
||||
out.Printf("Failed files: %s\n", strings.Join(failedFiles, ", "))
|
||||
}
|
||||
|
||||
return &task.ProcessReturnValue{Code: http.StatusOK, Value: gin.H{
|
||||
"Report": reporter,
|
||||
"FailedFiles": failedFiles,
|
||||
}}, nil
|
||||
ret := reposIncludePackageFromDirResponse{
|
||||
Report: reporter,
|
||||
FailedFiles: failedFiles,
|
||||
}
|
||||
return &task.ProcessReturnValue{Code: http.StatusOK, Value: ret}, nil
|
||||
})
|
||||
}
|
||||
|
||||
+1
-6
@@ -2,7 +2,6 @@ package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/aptly-dev/aptly/aptly"
|
||||
@@ -56,13 +55,9 @@ func Router(c *ctx.AptlyContext) http.Handler {
|
||||
router.UseRawPath = true
|
||||
|
||||
if c.Config().LogFormat == "json" {
|
||||
c.StructuredLogging(true)
|
||||
utils.SetupJSONLogger(c.Config().LogLevel, os.Stdout)
|
||||
gin.DefaultWriter = utils.LogWriter{Logger: log.Logger}
|
||||
router.Use(JSONLogger())
|
||||
} else {
|
||||
c.StructuredLogging(false)
|
||||
utils.SetupDefaultLogger(c.Config().LogLevel)
|
||||
router.Use(gin.Logger())
|
||||
}
|
||||
|
||||
@@ -220,7 +215,7 @@ func Router(c *ctx.AptlyContext) http.Handler {
|
||||
api.GET("/graph.:ext", apiGraph)
|
||||
}
|
||||
{
|
||||
api.POST("/db/cleanup", apiDbCleanup)
|
||||
api.POST("/db/cleanup", apiDBCleanup)
|
||||
}
|
||||
{
|
||||
api.GET("/tasks", apiTasksList)
|
||||
|
||||
+4
-4
@@ -33,7 +33,7 @@ func apiSnapshotsList(c *gin.Context) {
|
||||
}
|
||||
|
||||
result := []*deb.Snapshot{}
|
||||
collection.ForEachSorted(SortMethodString, func(snapshot *deb.Snapshot) error {
|
||||
_ = collection.ForEachSorted(SortMethodString, func(snapshot *deb.Snapshot) error {
|
||||
result = append(result, snapshot)
|
||||
return nil
|
||||
})
|
||||
@@ -555,7 +555,7 @@ func apiSnapshotsMerge(c *gin.Context) {
|
||||
}
|
||||
|
||||
if len(body.Sources) < 1 {
|
||||
AbortWithJSONError(c, http.StatusBadRequest, fmt.Errorf("At least one source snapshot is required"))
|
||||
AbortWithJSONError(c, http.StatusBadRequest, fmt.Errorf("minimum one source snapshot is required"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -765,7 +765,7 @@ func apiSnapshotsPull(c *gin.Context) {
|
||||
addedPackages := []string{}
|
||||
alreadySeen := map[string]bool{}
|
||||
|
||||
destinationPackageList.ForEachIndexed(func(pkg *deb.Package) error {
|
||||
_ = destinationPackageList.ForEachIndexed(func(pkg *deb.Package) error {
|
||||
key := pkg.Architecture + "_" + pkg.Name
|
||||
_, seen := alreadySeen[key]
|
||||
|
||||
@@ -781,7 +781,7 @@ func apiSnapshotsPull(c *gin.Context) {
|
||||
|
||||
// If !allMatches, add only first matching name-arch package
|
||||
if !seen || allMatches {
|
||||
toPackageList.Add(pkg)
|
||||
_ = toPackageList.Add(pkg)
|
||||
addedPackages = append(addedPackages, pkg.String())
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package aptly
|
||||
|
||||
// Default aptly.conf (filled in at link time)
|
||||
// AptlyConf holds the default aptly.conf (filled in at link time)
|
||||
var AptlyConf []byte
|
||||
|
||||
@@ -29,7 +29,7 @@ func NewPackagePool(accountName, accountKey, container, prefix, endpoint string)
|
||||
return &PackagePool{az: azctx}, nil
|
||||
}
|
||||
|
||||
// String
|
||||
// String returns the storage as string
|
||||
func (pool *PackagePool) String() string {
|
||||
return pool.az.String()
|
||||
}
|
||||
@@ -104,7 +104,7 @@ func (pool *PackagePool) Open(path string) (aptly.ReadSeekerCloser, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error creating tempfile for %s", path)
|
||||
}
|
||||
defer os.Remove(temp.Name())
|
||||
defer func () { _ = os.Remove(temp.Name()) }()
|
||||
|
||||
_, err = pool.az.client.DownloadFile(context.TODO(), pool.az.container, path, temp, nil)
|
||||
if err != nil {
|
||||
@@ -156,7 +156,7 @@ func (pool *PackagePool) Import(srcPath, basename string, checksums *utils.Check
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer source.Close()
|
||||
defer func() { _ = source.Close() }()
|
||||
|
||||
err = pool.az.putFile(path, source, checksums.MD5)
|
||||
if err != nil {
|
||||
|
||||
@@ -2,7 +2,7 @@ package azure
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@@ -69,8 +69,8 @@ func (s *PackagePoolSuite) TestFilepathList(c *C) {
|
||||
c.Check(err, IsNil)
|
||||
c.Check(list, DeepEquals, []string{})
|
||||
|
||||
s.pool.Import(s.debFile, "a.deb", &utils.ChecksumInfo{}, false, s.cs)
|
||||
s.pool.Import(s.debFile, "b.deb", &utils.ChecksumInfo{}, false, s.cs)
|
||||
_, _ = s.pool.Import(s.debFile, "a.deb", &utils.ChecksumInfo{}, false, s.cs)
|
||||
_, _ = s.pool.Import(s.debFile, "b.deb", &utils.ChecksumInfo{}, false, s.cs)
|
||||
|
||||
list, err = s.pool.FilepathList(nil)
|
||||
c.Check(err, IsNil)
|
||||
@@ -81,8 +81,8 @@ func (s *PackagePoolSuite) TestFilepathList(c *C) {
|
||||
}
|
||||
|
||||
func (s *PackagePoolSuite) TestRemove(c *C) {
|
||||
s.pool.Import(s.debFile, "a.deb", &utils.ChecksumInfo{}, false, s.cs)
|
||||
s.pool.Import(s.debFile, "b.deb", &utils.ChecksumInfo{}, false, s.cs)
|
||||
_, _ = s.pool.Import(s.debFile, "a.deb", &utils.ChecksumInfo{}, false, s.cs)
|
||||
_, _ = s.pool.Import(s.debFile, "b.deb", &utils.ChecksumInfo{}, false, s.cs)
|
||||
|
||||
size, err := s.pool.Remove("c7/6b/4bd12fd92e4dfe1b55b18a67a669_a.deb")
|
||||
c.Check(err, IsNil)
|
||||
@@ -247,7 +247,7 @@ func (s *PackagePoolSuite) TestOpen(c *C) {
|
||||
|
||||
f, err := s.pool.Open(path)
|
||||
c.Assert(err, IsNil)
|
||||
contents, err := ioutil.ReadAll(f)
|
||||
contents, err := io.ReadAll(f)
|
||||
c.Assert(err, IsNil)
|
||||
c.Check(len(contents), Equals, 2738)
|
||||
c.Check(f.Close(), IsNil)
|
||||
|
||||
+7
-5
@@ -18,7 +18,7 @@ import (
|
||||
|
||||
// PublishedStorage abstract file system with published files (actually hosted on Azure)
|
||||
type PublishedStorage struct {
|
||||
prefix string
|
||||
// FIXME: unused ???? prefix string
|
||||
az *azContext
|
||||
pathCache map[string]map[string]string
|
||||
}
|
||||
@@ -38,7 +38,7 @@ func NewPublishedStorage(accountName, accountKey, container, prefix, endpoint st
|
||||
return &PublishedStorage{az: azctx}, nil
|
||||
}
|
||||
|
||||
// String
|
||||
// String returns the storage as string
|
||||
func (storage *PublishedStorage) String() string {
|
||||
return storage.az.String()
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func (storage *PublishedStorage) PutFile(path string, sourceFilename string) err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer source.Close()
|
||||
defer func() { _ = source.Close() }()
|
||||
|
||||
err = storage.az.putFile(path, source, sourceMD5)
|
||||
if err != nil {
|
||||
@@ -158,7 +158,7 @@ func (storage *PublishedStorage) LinkFromPool(publishedPrefix, publishedRelPath,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer source.Close()
|
||||
defer func() { _ = source.Close() }()
|
||||
|
||||
err = storage.az.putFile(relFilePath, source, sourceMD5)
|
||||
if err == nil {
|
||||
@@ -193,7 +193,9 @@ func (storage *PublishedStorage) internalCopyOrMoveBlob(src, dst string, metadat
|
||||
if err != nil {
|
||||
return fmt.Errorf("error acquiring lease on source blob %s", src)
|
||||
}
|
||||
defer blobLeaseClient.BreakLease(context.Background(), &lease.BlobBreakOptions{BreakPeriod: to.Ptr(int32(60))})
|
||||
defer func() {
|
||||
_, _ = blobLeaseClient.BreakLease(context.Background(), &lease.BlobBreakOptions{BreakPeriod: to.Ptr(int32(60))})
|
||||
}()
|
||||
|
||||
dstBlobClient := containerClient.NewBlobClient(dst)
|
||||
copyResp, err := dstBlobClient.StartCopyFromURL(context.Background(), srcBlobClient.URL(), &blob.StartCopyFromURLOptions{
|
||||
|
||||
+10
-10
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"crypto/rand"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"bytes"
|
||||
@@ -36,7 +36,7 @@ func randString(n int) string {
|
||||
}
|
||||
const alphanum = "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||
var bytes = make([]byte, n)
|
||||
rand.Read(bytes)
|
||||
_, _ = rand.Read(bytes)
|
||||
for i, b := range bytes {
|
||||
bytes[i] = alphanum[b%byte(len(alphanum))]
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func (s *PublishedStorageSuite) TearDownTest(c *C) {
|
||||
func (s *PublishedStorageSuite) GetFile(c *C, path string) []byte {
|
||||
resp, err := s.storage.az.client.DownloadStream(context.Background(), s.storage.az.container, path, nil)
|
||||
c.Assert(err, IsNil)
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
c.Assert(err, IsNil)
|
||||
return data
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func (s *PublishedStorageSuite) TestPutFile(c *C) {
|
||||
filename := "a/b.txt"
|
||||
|
||||
dir := c.MkDir()
|
||||
err := ioutil.WriteFile(filepath.Join(dir, "a"), content, 0644)
|
||||
err := os.WriteFile(filepath.Join(dir, "a"), content, 0644)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
err = s.storage.PutFile(filename, filepath.Join(dir, "a"))
|
||||
@@ -140,7 +140,7 @@ func (s *PublishedStorageSuite) TestPutFilePlus(c *C) {
|
||||
filename := "a/b+c.txt"
|
||||
|
||||
dir := c.MkDir()
|
||||
err := ioutil.WriteFile(filepath.Join(dir, "a"), content, 0644)
|
||||
err := os.WriteFile(filepath.Join(dir, "a"), content, 0644)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
err = s.storage.PutFile(filename, filepath.Join(dir, "a"))
|
||||
@@ -258,7 +258,7 @@ func (s *PublishedStorageSuite) TestRemoveDirsPlus(c *C) {
|
||||
|
||||
func (s *PublishedStorageSuite) TestRenameFile(c *C) {
|
||||
dir := c.MkDir()
|
||||
err := ioutil.WriteFile(filepath.Join(dir, "a"), []byte("Welcome to Azure!"), 0644)
|
||||
err := os.WriteFile(filepath.Join(dir, "a"), []byte("Welcome to Azure!"), 0644)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
err = s.storage.PutFile("source.txt", filepath.Join(dir, "a"))
|
||||
@@ -280,18 +280,18 @@ func (s *PublishedStorageSuite) TestLinkFromPool(c *C) {
|
||||
cs := files.NewMockChecksumStorage()
|
||||
|
||||
tmpFile1 := filepath.Join(c.MkDir(), "mars-invaders_1.03.deb")
|
||||
err := ioutil.WriteFile(tmpFile1, []byte("Contents"), 0644)
|
||||
err := os.WriteFile(tmpFile1, []byte("Contents"), 0644)
|
||||
c.Assert(err, IsNil)
|
||||
cksum1 := utils.ChecksumInfo{MD5: "c1df1da7a1ce305a3b60af9d5733ac1d"}
|
||||
|
||||
tmpFile2 := filepath.Join(c.MkDir(), "mars-invaders_1.03.deb")
|
||||
err = ioutil.WriteFile(tmpFile2, []byte("Spam"), 0644)
|
||||
err = os.WriteFile(tmpFile2, []byte("Spam"), 0644)
|
||||
c.Assert(err, IsNil)
|
||||
cksum2 := utils.ChecksumInfo{MD5: "e9dfd31cc505d51fc26975250750deab"}
|
||||
|
||||
tmpFile3 := filepath.Join(c.MkDir(), "netboot/boot.img.gz")
|
||||
os.MkdirAll(filepath.Dir(tmpFile3), 0777)
|
||||
err = ioutil.WriteFile(tmpFile3, []byte("Contents"), 0644)
|
||||
_ = os.MkdirAll(filepath.Dir(tmpFile3), 0777)
|
||||
err = os.WriteFile(tmpFile3, []byte("Contents"), 0644)
|
||||
c.Assert(err, IsNil)
|
||||
cksum3 := utils.ChecksumInfo{MD5: "c1df1da7a1ce305a3b60af9d5733ac1d"}
|
||||
|
||||
|
||||
+4
-4
@@ -46,7 +46,7 @@ func aptlyAPIServe(cmd *commander.Command, args []string) error {
|
||||
}
|
||||
if err == nil && len(listeners) == 1 {
|
||||
listener := listeners[0]
|
||||
defer listener.Close()
|
||||
defer func() { _ = listener.Close() }()
|
||||
fmt.Printf("\nTaking over web server at: %s (press Ctrl+C to quit)...\n", listener.Addr().String())
|
||||
err = http.Serve(listener, api.Router(context))
|
||||
if err != nil {
|
||||
@@ -67,7 +67,7 @@ func aptlyAPIServe(cmd *commander.Command, args []string) error {
|
||||
if _, ok := <-sigchan; ok {
|
||||
fmt.Printf("\nShutdown signal received, waiting for background tasks...\n")
|
||||
context.TaskList().Wait()
|
||||
server.Shutdown(stdcontext.Background())
|
||||
_ = server.Shutdown(stdcontext.Background())
|
||||
}
|
||||
})()
|
||||
defer close(sigchan)
|
||||
@@ -75,14 +75,14 @@ func aptlyAPIServe(cmd *commander.Command, args []string) error {
|
||||
listenURL, err := url.Parse(listen)
|
||||
if err == nil && listenURL.Scheme == "unix" {
|
||||
file := listenURL.Path
|
||||
os.Remove(file)
|
||||
_ = os.Remove(file)
|
||||
|
||||
var listener net.Listener
|
||||
listener, err = net.Listen("unix", file)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to listen on: %s\n%s", file, err)
|
||||
}
|
||||
defer listener.Close()
|
||||
defer func() { _ = listener.Close() }()
|
||||
|
||||
err = server.Serve(listener)
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ package environment to new version.`,
|
||||
Flag: *flag.NewFlagSet("aptly", flag.ExitOnError),
|
||||
Subcommands: []*commander.Command{
|
||||
makeCmdConfig(),
|
||||
makeCmdDb(),
|
||||
makeCmdDB(),
|
||||
makeCmdGraph(),
|
||||
makeCmdMirror(),
|
||||
makeCmdRepo(),
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/smira/commander"
|
||||
"gopkg.in/yaml.v3"
|
||||
yaml "gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func aptlyConfigShow(_ *commander.Command, _ []string) error {
|
||||
|
||||
@@ -4,13 +4,13 @@ import (
|
||||
"github.com/smira/commander"
|
||||
)
|
||||
|
||||
func makeCmdDb() *commander.Command {
|
||||
func makeCmdDB() *commander.Command {
|
||||
return &commander.Command{
|
||||
UsageLine: "db",
|
||||
Short: "manage aptly's internal database and package pool",
|
||||
Subcommands: []*commander.Command{
|
||||
makeCmdDbCleanup(),
|
||||
makeCmdDbRecover(),
|
||||
makeCmdDBCleanup(),
|
||||
makeCmdDBRecover(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// aptly db cleanup
|
||||
func aptlyDbCleanup(cmd *commander.Command, args []string) error {
|
||||
func aptlyDBCleanup(cmd *commander.Command, args []string) error {
|
||||
var err error
|
||||
|
||||
if len(args) != 0 {
|
||||
@@ -48,7 +48,7 @@ func aptlyDbCleanup(cmd *commander.Command, args []string) error {
|
||||
|
||||
if verbose {
|
||||
description := fmt.Sprintf("mirror %s", repo.Name)
|
||||
repo.RefList().ForEach(func(key []byte) error {
|
||||
_ = repo.RefList().ForEach(func(key []byte) error {
|
||||
packageRefSources[string(key)] = append(packageRefSources[string(key)], description)
|
||||
return nil
|
||||
})
|
||||
@@ -81,7 +81,7 @@ func aptlyDbCleanup(cmd *commander.Command, args []string) error {
|
||||
|
||||
if verbose {
|
||||
description := fmt.Sprintf("local repo %s", repo.Name)
|
||||
repo.RefList().ForEach(func(key []byte) error {
|
||||
_ = repo.RefList().ForEach(func(key []byte) error {
|
||||
packageRefSources[string(key)] = append(packageRefSources[string(key)], description)
|
||||
return nil
|
||||
})
|
||||
@@ -113,7 +113,7 @@ func aptlyDbCleanup(cmd *commander.Command, args []string) error {
|
||||
|
||||
if verbose {
|
||||
description := fmt.Sprintf("snapshot %s", snapshot.Name)
|
||||
snapshot.RefList().ForEach(func(key []byte) error {
|
||||
_ = snapshot.RefList().ForEach(func(key []byte) error {
|
||||
packageRefSources[string(key)] = append(packageRefSources[string(key)], description)
|
||||
return nil
|
||||
})
|
||||
@@ -146,7 +146,7 @@ func aptlyDbCleanup(cmd *commander.Command, args []string) error {
|
||||
if verbose {
|
||||
description := fmt.Sprintf("published repository %s:%s/%s component %s",
|
||||
published.Storage, published.Prefix, published.Distribution, component)
|
||||
published.RefList(component).ForEach(func(key []byte) error {
|
||||
_ = published.RefList(component).ForEach(func(key []byte) error {
|
||||
packageRefSources[string(key)] = append(packageRefSources[string(key)], description)
|
||||
return nil
|
||||
})
|
||||
@@ -291,9 +291,9 @@ func aptlyDbCleanup(cmd *commander.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func makeCmdDbCleanup() *commander.Command {
|
||||
func makeCmdDBCleanup() *commander.Command {
|
||||
cmd := &commander.Command{
|
||||
Run: aptlyDbCleanup,
|
||||
Run: aptlyDBCleanup,
|
||||
UsageLine: "cleanup",
|
||||
Short: "cleanup DB and package pool",
|
||||
Long: `
|
||||
|
||||
+45
-4
@@ -1,13 +1,16 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/aptly-dev/aptly/deb"
|
||||
"github.com/smira/commander"
|
||||
|
||||
"github.com/aptly-dev/aptly/database/goleveldb"
|
||||
)
|
||||
|
||||
// aptly db recover
|
||||
func aptlyDbRecover(cmd *commander.Command, args []string) error {
|
||||
func aptlyDBRecover(cmd *commander.Command, args []string) error {
|
||||
var err error
|
||||
|
||||
if len(args) != 0 {
|
||||
@@ -16,14 +19,19 @@ func aptlyDbRecover(cmd *commander.Command, args []string) error {
|
||||
}
|
||||
|
||||
context.Progress().Printf("Recovering database...\n")
|
||||
err = goleveldb.RecoverDB(context.DBPath())
|
||||
if err = goleveldb.RecoverDB(context.DBPath()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
context.Progress().Printf("Checking database integrity...\n")
|
||||
err = checkIntegrity()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func makeCmdDbRecover() *commander.Command {
|
||||
func makeCmdDBRecover() *commander.Command {
|
||||
cmd := &commander.Command{
|
||||
Run: aptlyDbRecover,
|
||||
Run: aptlyDBRecover,
|
||||
UsageLine: "recover",
|
||||
Short: "recover DB after crash",
|
||||
Long: `
|
||||
@@ -38,3 +46,36 @@ Example:
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func checkIntegrity() error {
|
||||
return context.NewCollectionFactory().LocalRepoCollection().ForEach(checkRepo)
|
||||
}
|
||||
|
||||
func checkRepo(repo *deb.LocalRepo) error {
|
||||
collectionFactory := context.NewCollectionFactory()
|
||||
repos := collectionFactory.LocalRepoCollection()
|
||||
|
||||
err := repos.LoadComplete(repo)
|
||||
if err != nil {
|
||||
return fmt.Errorf("load complete repo %q: %s", repo.Name, err)
|
||||
}
|
||||
|
||||
dangling, err := deb.FindDanglingReferences(repo.RefList(), collectionFactory.PackageCollection())
|
||||
if err != nil {
|
||||
return fmt.Errorf("find dangling references: %w", err)
|
||||
}
|
||||
|
||||
if len(dangling.Refs) > 0 {
|
||||
for _, ref := range dangling.Refs {
|
||||
context.Progress().Printf("Removing dangling database reference %q\n", ref)
|
||||
}
|
||||
|
||||
repo.UpdateRefList(repo.RefList().Subtract(dangling))
|
||||
|
||||
if err = repos.Update(repo); err != nil {
|
||||
return fmt.Errorf("update repo: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
+2
-2
@@ -38,8 +38,8 @@ func aptlyGraph(cmd *commander.Command, args []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tempfile.Close()
|
||||
os.Remove(tempfile.Name())
|
||||
_ = tempfile.Close()
|
||||
_ = os.Remove(tempfile.Name())
|
||||
|
||||
format := context.Flags().Lookup("format").Value.String()
|
||||
output := context.Flags().Lookup("output").Value.String()
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ func getVerifier(flags *flag.FlagSet) (pgp.Verifier, error) {
|
||||
verifier.AddKeyring(keyRing)
|
||||
}
|
||||
|
||||
err := verifier.InitKeyring(ignoreSignatures == false) // be verbose only if verifying signatures is requested
|
||||
err := verifier.InitKeyring(!ignoreSignatures) // be verbose only if verifying signatures is requested
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ func aptlyMirrorListTxt(cmd *commander.Command, _ []string) error {
|
||||
|
||||
repos := make([]string, collectionFactory.RemoteRepoCollection().Len())
|
||||
i := 0
|
||||
collectionFactory.RemoteRepoCollection().ForEach(func(repo *deb.RemoteRepo) error {
|
||||
_ = collectionFactory.RemoteRepoCollection().ForEach(func(repo *deb.RemoteRepo) error {
|
||||
if raw {
|
||||
repos[i] = repo.Name
|
||||
} else {
|
||||
@@ -42,7 +42,7 @@ func aptlyMirrorListTxt(cmd *commander.Command, _ []string) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
context.CloseDatabase()
|
||||
_ = context.CloseDatabase()
|
||||
|
||||
sort.Strings(repos)
|
||||
|
||||
@@ -70,13 +70,13 @@ func aptlyMirrorListJSON(_ *commander.Command, _ []string) error {
|
||||
|
||||
repos := make([]*deb.RemoteRepo, context.NewCollectionFactory().RemoteRepoCollection().Len())
|
||||
i := 0
|
||||
context.NewCollectionFactory().RemoteRepoCollection().ForEach(func(repo *deb.RemoteRepo) error {
|
||||
_ = context.NewCollectionFactory().RemoteRepoCollection().ForEach(func(repo *deb.RemoteRepo) error {
|
||||
repos[i] = repo
|
||||
i++
|
||||
return nil
|
||||
})
|
||||
|
||||
context.CloseDatabase()
|
||||
_ = context.CloseDatabase()
|
||||
|
||||
sort.Slice(repos, func(i, j int) bool {
|
||||
return repos[i].Name < repos[j].Name
|
||||
|
||||
+2
-2
@@ -86,7 +86,7 @@ func aptlyMirrorShowTxt(_ *commander.Command, args []string) error {
|
||||
if repo.LastDownloadDate.IsZero() {
|
||||
fmt.Printf("Unable to show package list, mirror hasn't been downloaded yet.\n")
|
||||
} else {
|
||||
ListPackagesRefList(repo.RefList(), collectionFactory)
|
||||
_ = ListPackagesRefList(repo.RefList(), collectionFactory)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ func aptlyMirrorShowJSON(_ *commander.Command, args []string) error {
|
||||
}
|
||||
|
||||
list.PrepareIndex()
|
||||
list.ForEachIndexed(func(p *deb.Package) error {
|
||||
_ = list.ForEachIndexed(func(p *deb.Package) error {
|
||||
repo.Packages = append(repo.Packages, p.GetFullName())
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -101,7 +101,7 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
||||
err = context.ReOpenDatabase()
|
||||
if err == nil {
|
||||
repo.MarkAsIdle()
|
||||
collectionFactory.RemoteRepoCollection().Update(repo)
|
||||
_ = collectionFactory.RemoteRepoCollection().Update(repo)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -173,7 +173,7 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
||||
file, e = os.CreateTemp("", task.File.Filename)
|
||||
if e == nil {
|
||||
task.TempDownPath = file.Name()
|
||||
file.Close()
|
||||
_ = file.Close()
|
||||
}
|
||||
}
|
||||
if e != nil {
|
||||
@@ -261,7 +261,7 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
||||
return fmt.Errorf("unable to update: download errors:\n %s", strings.Join(errors, "\n "))
|
||||
}
|
||||
|
||||
repo.FinalizeDownload(collectionFactory, context.Progress())
|
||||
_ = repo.FinalizeDownload(collectionFactory, context.Progress())
|
||||
err = collectionFactory.RemoteRepoCollection().Update(repo)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to update: %s", err)
|
||||
|
||||
@@ -40,7 +40,7 @@ func aptlyPackageSearch(cmd *commander.Command, args []string) error {
|
||||
}
|
||||
|
||||
format := context.Flags().Lookup("format").Value.String()
|
||||
PrintPackageList(result, format, "")
|
||||
_ = PrintPackageList(result, format, "")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
+3
-3
@@ -84,8 +84,8 @@ func aptlyPackageShow(cmd *commander.Command, args []string) error {
|
||||
result := q.Query(collectionFactory.PackageCollection())
|
||||
|
||||
err = result.ForEach(func(p *deb.Package) error {
|
||||
p.Stanza().WriteTo(w, p.IsSource, false, false)
|
||||
w.Flush()
|
||||
_ = p.Stanza().WriteTo(w, p.IsSource, false, false)
|
||||
_ = w.Flush()
|
||||
fmt.Printf("\n")
|
||||
|
||||
if withFiles {
|
||||
@@ -109,7 +109,7 @@ func aptlyPackageShow(cmd *commander.Command, args []string) error {
|
||||
|
||||
if withReferences {
|
||||
fmt.Printf("References to package:\n")
|
||||
printReferencesTo(p, collectionFactory)
|
||||
_ = printReferencesTo(p, collectionFactory)
|
||||
fmt.Printf("\n")
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ func aptlyPublishListTxt(cmd *commander.Command, _ []string) error {
|
||||
return fmt.Errorf("unable to load list of repos: %s", err)
|
||||
}
|
||||
|
||||
context.CloseDatabase()
|
||||
_ = context.CloseDatabase()
|
||||
|
||||
sort.Strings(published)
|
||||
|
||||
@@ -99,7 +99,7 @@ func aptlyPublishListJSON(_ *commander.Command, _ []string) error {
|
||||
return fmt.Errorf("unable to load list of repos: %s", err)
|
||||
}
|
||||
|
||||
context.CloseDatabase()
|
||||
_ = context.CloseDatabase()
|
||||
|
||||
sort.Slice(repos, func(i, j int) bool {
|
||||
return repos[i].GetPath() < repos[j].GetPath()
|
||||
|
||||
@@ -156,7 +156,7 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
|
||||
|
||||
duplicate := collectionFactory.PublishedRepoCollection().CheckDuplicate(published)
|
||||
if duplicate != nil {
|
||||
collectionFactory.PublishedRepoCollection().LoadComplete(duplicate, collectionFactory)
|
||||
_ = collectionFactory.PublishedRepoCollection().LoadComplete(duplicate, collectionFactory)
|
||||
return fmt.Errorf("prefix/distribution already used by another published repo: %s", duplicate)
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ func aptlyRepoListTxt(cmd *commander.Command, _ []string) error {
|
||||
collectionFactory := context.NewCollectionFactory()
|
||||
repos := make([]string, collectionFactory.LocalRepoCollection().Len())
|
||||
i := 0
|
||||
collectionFactory.LocalRepoCollection().ForEach(func(repo *deb.LocalRepo) error {
|
||||
_ = collectionFactory.LocalRepoCollection().ForEach(func(repo *deb.LocalRepo) error {
|
||||
if raw {
|
||||
repos[i] = repo.Name
|
||||
} else {
|
||||
@@ -47,7 +47,7 @@ func aptlyRepoListTxt(cmd *commander.Command, _ []string) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
context.CloseDatabase()
|
||||
_ = context.CloseDatabase()
|
||||
|
||||
sort.Strings(repos)
|
||||
|
||||
@@ -76,7 +76,7 @@ func aptlyRepoListJSON(_ *commander.Command, _ []string) error {
|
||||
|
||||
repos := make([]*deb.LocalRepo, context.NewCollectionFactory().LocalRepoCollection().Len())
|
||||
i := 0
|
||||
context.NewCollectionFactory().LocalRepoCollection().ForEach(func(repo *deb.LocalRepo) error {
|
||||
_ = context.NewCollectionFactory().LocalRepoCollection().ForEach(func(repo *deb.LocalRepo) error {
|
||||
e := context.NewCollectionFactory().LocalRepoCollection().LoadComplete(repo)
|
||||
if e != nil {
|
||||
return e
|
||||
@@ -87,7 +87,7 @@ func aptlyRepoListJSON(_ *commander.Command, _ []string) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
context.CloseDatabase()
|
||||
_ = context.CloseDatabase()
|
||||
|
||||
sort.Slice(repos, func(i, j int) bool {
|
||||
return repos[i].Name < repos[j].Name
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ func aptlyRepoRemove(cmd *commander.Command, args []string) error {
|
||||
return fmt.Errorf("unable to remove: %s", err)
|
||||
}
|
||||
|
||||
toRemove.ForEach(func(p *deb.Package) error {
|
||||
_ = toRemove.ForEach(func(p *deb.Package) error {
|
||||
list.Remove(p)
|
||||
context.Progress().ColoredPrintf("@r[-]@| %s removed", p)
|
||||
return nil
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ func aptlyRepoShowTxt(_ *commander.Command, args []string) error {
|
||||
|
||||
withPackages := context.Flags().Lookup("with-packages").Value.Get().(bool)
|
||||
if withPackages {
|
||||
ListPackagesRefList(repo.RefList(), collectionFactory)
|
||||
_ = ListPackagesRefList(repo.RefList(), collectionFactory)
|
||||
}
|
||||
|
||||
return err
|
||||
|
||||
@@ -33,7 +33,7 @@ func aptlySnapshotListTxt(cmd *commander.Command, _ []string) error {
|
||||
collection := collectionFactory.SnapshotCollection()
|
||||
|
||||
if raw {
|
||||
collection.ForEachSorted(sortMethodString, func(snapshot *deb.Snapshot) error {
|
||||
_ = collection.ForEachSorted(sortMethodString, func(snapshot *deb.Snapshot) error {
|
||||
fmt.Printf("%s\n", snapshot.Name)
|
||||
return nil
|
||||
})
|
||||
@@ -68,7 +68,7 @@ func aptlySnapshotListJSON(cmd *commander.Command, _ []string) error {
|
||||
|
||||
jsonSnapshots := make([]*deb.Snapshot, collection.Len())
|
||||
i := 0
|
||||
collection.ForEachSorted(sortMethodString, func(snapshot *deb.Snapshot) error {
|
||||
_ = collection.ForEachSorted(sortMethodString, func(snapshot *deb.Snapshot) error {
|
||||
jsonSnapshots[i] = snapshot
|
||||
i++
|
||||
return nil
|
||||
|
||||
@@ -116,7 +116,7 @@ func aptlySnapshotPull(cmd *commander.Command, args []string) error {
|
||||
|
||||
alreadySeen := map[string]bool{}
|
||||
|
||||
result.ForEachIndexed(func(pkg *deb.Package) error {
|
||||
_ = result.ForEachIndexed(func(pkg *deb.Package) error {
|
||||
key := pkg.Architecture + "_" + pkg.Name
|
||||
_, seen := alreadySeen[key]
|
||||
|
||||
@@ -132,7 +132,7 @@ func aptlySnapshotPull(cmd *commander.Command, args []string) error {
|
||||
|
||||
// If !allMatches, add only first matching name-arch package
|
||||
if !seen || allMatches {
|
||||
packageList.Add(pkg)
|
||||
_ = packageList.Add(pkg)
|
||||
context.Progress().ColoredPrintf("@g[+]@| %s added", pkg)
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ func aptlySnapshotMirrorRepoSearch(cmd *commander.Command, args []string) error
|
||||
}
|
||||
|
||||
format := context.Flags().Lookup("format").Value.String()
|
||||
PrintPackageList(result, format, "")
|
||||
_ = PrintPackageList(result, format, "")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func aptlySnapshotShowTxt(_ *commander.Command, args []string) error {
|
||||
|
||||
withPackages := context.Flags().Lookup("with-packages").Value.Get().(bool)
|
||||
if withPackages {
|
||||
ListPackagesRefList(snapshot.RefList(), collectionFactory)
|
||||
_ = ListPackagesRefList(snapshot.RefList(), collectionFactory)
|
||||
}
|
||||
|
||||
return err
|
||||
@@ -139,7 +139,7 @@ func aptlySnapshotShowJSON(_ *commander.Command, args []string) error {
|
||||
}
|
||||
|
||||
list.PrepareIndex()
|
||||
list.ForEachIndexed(func(p *deb.Package) error {
|
||||
_ = list.ForEachIndexed(func(p *deb.Package) error {
|
||||
snapshot.Packages = append(snapshot.Packages, p.GetFullName())
|
||||
return nil
|
||||
})
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/mattn/go-shellwords"
|
||||
shellwords "github.com/mattn/go-shellwords"
|
||||
"github.com/smira/commander"
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ func aptlyTaskRun(cmd *commander.Command, args []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
defer func() { _ = file.Close() }()
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
|
||||
|
||||
+45
-9
@@ -22,34 +22,36 @@
|
||||
|
||||
__aptly_mirror_list()
|
||||
{
|
||||
aptly mirror list -raw
|
||||
aptly ${aptly_global_opts[@]} mirror list -raw
|
||||
}
|
||||
|
||||
__aptly_repo_list()
|
||||
{
|
||||
aptly repo list -raw
|
||||
aptly ${aptly_global_opts[@]} repo list -raw
|
||||
}
|
||||
|
||||
__aptly_snapshot_list()
|
||||
{
|
||||
aptly snapshot list -raw
|
||||
aptly ${aptly_global_opts[@]} snapshot list -raw
|
||||
}
|
||||
|
||||
__aptly_published_distributions()
|
||||
{
|
||||
aptly publish list -raw | cut -d ' ' -f 2 | sort | uniq
|
||||
aptly ${aptly_global_opts[@]} publish list -raw | cut -d ' ' -f 2 | sort | uniq
|
||||
}
|
||||
|
||||
__aptly_published_prefixes()
|
||||
{
|
||||
aptly publish list -raw | cut -d ' ' -f 1 | sort | uniq
|
||||
aptly ${aptly_global_opts[@]} publish list -raw | cut -d ' ' -f 1 | sort | uniq
|
||||
}
|
||||
|
||||
__aptly_prefixes_for_distribution()
|
||||
{
|
||||
aptly publish list -raw | awk -v dist="$1" '{ if (dist == $2) print $1 }' | sort | uniq
|
||||
aptly ${aptly_global_opts[@]} publish list -raw | awk -v dist="$1" '{ if (dist == $2) print $1 }' | sort | uniq
|
||||
}
|
||||
|
||||
|
||||
|
||||
_aptly()
|
||||
{
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
@@ -57,7 +59,12 @@ _aptly()
|
||||
prevprev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
|
||||
commands="api config db graph mirror package publish repo serve snapshot task version"
|
||||
options="-architectures= -config= -db-open-attempts= -dep-follow-all-variants -dep-follow-recommends -dep-follow-source -dep-follow-suggests -dep-verbose-resolve -gpg-provider="
|
||||
|
||||
options="-architectures -config -db-open-attempts -dep-follow-all-variants -dep-follow-recommends -dep-follow-source -dep-follow-suggests -dep-verbose-resolve -gpg-provider"
|
||||
options_without_arg="-dep-follow-all-variants -dep-follow-recommends -dep-follow-source -dep-follow-suggests -dep-verbose-resolve"
|
||||
options_with_arg="-architectures -db-open-attempts -gpg-provider"
|
||||
options_with_path_arg="-config"
|
||||
|
||||
db_subcommands="cleanup recover"
|
||||
mirror_subcommands="create drop edit show list rename search update"
|
||||
publish_subcommands="drop list repo snapshot switch update source"
|
||||
@@ -69,12 +76,41 @@ _aptly()
|
||||
config_subcommands="show"
|
||||
api_subcommands="serve"
|
||||
|
||||
local cmd subcmd numargs numoptions i
|
||||
local cmd subcmd numargs numoptions i aptly_global_opts
|
||||
|
||||
numargs=0
|
||||
numoptions=0
|
||||
|
||||
for opt in "${options_with_path_arg[@]}"; do
|
||||
[[ "$prev" == "$opt" ]] || continue
|
||||
compopt -o filenames 2>/dev/null
|
||||
_filedir
|
||||
return 0
|
||||
done
|
||||
|
||||
for (( i=1; i < $COMP_CWORD; i++ )); do
|
||||
word=${COMP_WORDS[i]}
|
||||
if [[ "$word" == -*=* ]]; then
|
||||
for o in "${options[@]}"; do
|
||||
[[ ${word%%=*} == "$o" ]] && aptly_global_opts+=("$word")
|
||||
done
|
||||
else
|
||||
for o in "${options_with_arg[@]}" ""${options_with_path_arg[@]}"" ; do
|
||||
if [[ "$word" == "$o" ]]; then
|
||||
if (( i + 1 < COMP_CWORD )); then
|
||||
aptly_global_opts+=("$word" "${COMP_WORDS[i+1]}")
|
||||
else
|
||||
aptly_global_opts+=("$word")
|
||||
fi
|
||||
(( i++ ))
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
fi
|
||||
for o in ${options_without_arg[@]}; do
|
||||
[[ "$word" == "$o" ]] && aptly_global_opts+=("$word")
|
||||
done
|
||||
|
||||
if [[ -n "$cmd" ]]; then
|
||||
if [[ ! -n "$subcmd" ]]; then
|
||||
subcmd=${COMP_WORDS[i]}
|
||||
@@ -339,7 +375,7 @@ _aptly()
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "-accept-unsigned -force-replace -ignore-signatures -keyring= -no-remove-files -repo= -uploaders-file=" -- ${cur}))
|
||||
else
|
||||
comptopt -o filenames 2>/dev/null
|
||||
compopt -o filenames 2>/dev/null
|
||||
COMPREPLY=($(compgen -f -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
|
||||
+3
-2
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/aptly-dev/aptly/aptly"
|
||||
"github.com/aptly-dev/aptly/utils"
|
||||
"github.com/cheggaaa/pb"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/wsxiaoys/terminal/color"
|
||||
@@ -78,7 +79,7 @@ func (p *Progress) InitBar(count int64, isBytes bool, _ aptly.BarType) {
|
||||
if p.bar != nil {
|
||||
panic("bar already initialized")
|
||||
}
|
||||
if RunningOnTerminal() {
|
||||
if utils.RunningOnTerminal() {
|
||||
p.bar = pb.New(0)
|
||||
p.bar.Total = count
|
||||
p.bar.NotPrint = true
|
||||
@@ -141,7 +142,7 @@ func (p *Progress) PrintfStdErr(msg string, a ...interface{}) {
|
||||
|
||||
// ColoredPrintf does printf in colored way + newline
|
||||
func (p *Progress) ColoredPrintf(msg string, a ...interface{}) {
|
||||
if RunningOnTerminal() {
|
||||
if utils.RunningOnTerminal() {
|
||||
p.queue <- printTask{code: codePrint, message: color.Sprintf(msg, a...) + "\n"}
|
||||
} else {
|
||||
// stip color marks
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package console
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
// RunningOnTerminal checks whether stdout is terminal
|
||||
func RunningOnTerminal() bool {
|
||||
return term.IsTerminal(syscall.Stdout)
|
||||
}
|
||||
+21
-13
@@ -115,7 +115,7 @@ func (context *AptlyContext) config() *utils.ConfigStructure {
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Config file not found, creating default config at %s\n\n", homeLocation)
|
||||
|
||||
utils.SaveConfigRaw(homeLocation, aptly.AptlyConf)
|
||||
_ = utils.SaveConfigRaw(homeLocation, aptly.AptlyConf)
|
||||
err = utils.LoadConfig(homeLocation, &utils.Config)
|
||||
if err != nil {
|
||||
Fatal(fmt.Errorf("error loading config file %s: %s", homeLocation, err))
|
||||
@@ -123,6 +123,14 @@ func (context *AptlyContext) config() *utils.ConfigStructure {
|
||||
}
|
||||
}
|
||||
|
||||
if utils.Config.LogFormat == "json" {
|
||||
context.StructuredLogging(true)
|
||||
utils.SetupJSONLogger(utils.Config.LogLevel, os.Stdout)
|
||||
} else {
|
||||
context.StructuredLogging(false)
|
||||
utils.SetupDefaultLogger(utils.Config.LogLevel)
|
||||
}
|
||||
|
||||
context.configLoaded = true
|
||||
|
||||
}
|
||||
@@ -233,7 +241,7 @@ func (context *AptlyContext) newDownloader(progress aptly.Progress) aptly.Downlo
|
||||
// If flag is defined prefer it to global setting
|
||||
maxTries = maxTriesFlag.Value.Get().(int)
|
||||
}
|
||||
var downloader string = context.config().Downloader
|
||||
var downloader = context.config().Downloader
|
||||
downloaderFlag := context.flags.Lookup("downloader")
|
||||
if downloaderFlag != nil {
|
||||
downloader = downloaderFlag.Value.String()
|
||||
@@ -295,8 +303,8 @@ func (context *AptlyContext) _database() (database.Storage, error) {
|
||||
switch context.config().DatabaseBackend.Type {
|
||||
case "leveldb":
|
||||
dbPath := filepath.Join(context.config().GetRootDir(), "db")
|
||||
if len(context.config().DatabaseBackend.DbPath) != 0 {
|
||||
dbPath = context.config().DatabaseBackend.DbPath
|
||||
if len(context.config().DatabaseBackend.DBPath) != 0 {
|
||||
dbPath = context.config().DatabaseBackend.DBPath
|
||||
}
|
||||
context.database, err = goleveldb.NewDB(dbPath)
|
||||
case "etcd":
|
||||
@@ -444,7 +452,7 @@ func (context *AptlyContext) GetPublishedStorage(name string) aptly.PublishedSto
|
||||
} else if strings.HasPrefix(name, "azure:") {
|
||||
params, ok := context.config().AzurePublishRoots[name[6:]]
|
||||
if !ok {
|
||||
Fatal(fmt.Errorf("Published Azure storage %v not configured", name[6:]))
|
||||
Fatal(fmt.Errorf("published Azure storage %v not configured", name[6:]))
|
||||
}
|
||||
|
||||
var err error
|
||||
@@ -589,17 +597,17 @@ func (context *AptlyContext) Shutdown() {
|
||||
|
||||
if aptly.EnableDebug {
|
||||
if context.fileMemProfile != nil {
|
||||
pprof.WriteHeapProfile(context.fileMemProfile)
|
||||
context.fileMemProfile.Close()
|
||||
_ = pprof.WriteHeapProfile(context.fileMemProfile)
|
||||
_ = context.fileMemProfile.Close()
|
||||
context.fileMemProfile = nil
|
||||
}
|
||||
if context.fileCPUProfile != nil {
|
||||
pprof.StopCPUProfile()
|
||||
context.fileCPUProfile.Close()
|
||||
_ = context.fileCPUProfile.Close()
|
||||
context.fileCPUProfile = nil
|
||||
}
|
||||
if context.fileMemProfile != nil {
|
||||
context.fileMemProfile.Close()
|
||||
_ = context.fileMemProfile.Close()
|
||||
context.fileMemProfile = nil
|
||||
}
|
||||
}
|
||||
@@ -607,7 +615,7 @@ func (context *AptlyContext) Shutdown() {
|
||||
context.taskList.Stop()
|
||||
}
|
||||
if context.database != nil {
|
||||
context.database.Close()
|
||||
_ = context.database.Close()
|
||||
context.database = nil
|
||||
}
|
||||
if context.downloader != nil {
|
||||
@@ -652,7 +660,7 @@ func NewContext(flags *flag.FlagSet) (*AptlyContext, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pprof.StartCPUProfile(context.fileCPUProfile)
|
||||
_ = pprof.StartCPUProfile(context.fileCPUProfile)
|
||||
}
|
||||
|
||||
memprofile := flags.Lookup("memprofile").Value.String()
|
||||
@@ -672,7 +680,7 @@ func NewContext(flags *flag.FlagSet) (*AptlyContext, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
context.fileMemStats.WriteString("# Time\tHeapSys\tHeapAlloc\tHeapIdle\tHeapReleased\n")
|
||||
_, _ = context.fileMemStats.WriteString("# Time\tHeapSys\tHeapAlloc\tHeapIdle\tHeapReleased\n")
|
||||
|
||||
go func() {
|
||||
var stats runtime.MemStats
|
||||
@@ -682,7 +690,7 @@ func NewContext(flags *flag.FlagSet) (*AptlyContext, error) {
|
||||
for {
|
||||
runtime.ReadMemStats(&stats)
|
||||
if context.fileMemStats != nil {
|
||||
context.fileMemStats.WriteString(fmt.Sprintf("%d\t%d\t%d\t%d\t%d\n",
|
||||
_, _ = context.fileMemStats.WriteString(fmt.Sprintf("%d\t%d\t%d\t%d\t%d\n",
|
||||
(time.Now().UnixNano()-start)/1000000, stats.HeapSys, stats.HeapAlloc, stats.HeapIdle, stats.HeapReleased))
|
||||
time.Sleep(interval)
|
||||
} else {
|
||||
|
||||
@@ -14,7 +14,6 @@ func Test(t *testing.T) {
|
||||
}
|
||||
|
||||
type EtcDDBSuite struct {
|
||||
url string
|
||||
db database.Storage
|
||||
}
|
||||
|
||||
@@ -67,17 +66,17 @@ func (s *EtcDDBSuite) TestDelete(c *C) {
|
||||
func (s *EtcDDBSuite) TestByPrefix(c *C) {
|
||||
//c.Check(s.db.FetchByPrefix([]byte{0x80}), DeepEquals, [][]byte{})
|
||||
|
||||
s.db.Put([]byte{0x80, 0x01}, []byte{0x01})
|
||||
s.db.Put([]byte{0x80, 0x03}, []byte{0x03})
|
||||
s.db.Put([]byte{0x80, 0x02}, []byte{0x02})
|
||||
_ = s.db.Put([]byte{0x80, 0x01}, []byte{0x01})
|
||||
_ = s.db.Put([]byte{0x80, 0x03}, []byte{0x03})
|
||||
_ = s.db.Put([]byte{0x80, 0x02}, []byte{0x02})
|
||||
c.Check(s.db.FetchByPrefix([]byte{0x80}), DeepEquals, [][]byte{{0x01}, {0x02}, {0x03}})
|
||||
c.Check(s.db.KeysByPrefix([]byte{0x80}), DeepEquals, [][]byte{{0x80, 0x01}, {0x80, 0x02}, {0x80, 0x03}})
|
||||
|
||||
s.db.Put([]byte{0x90, 0x01}, []byte{0x04})
|
||||
_ = s.db.Put([]byte{0x90, 0x01}, []byte{0x04})
|
||||
c.Check(s.db.FetchByPrefix([]byte{0x80}), DeepEquals, [][]byte{{0x01}, {0x02}, {0x03}})
|
||||
c.Check(s.db.KeysByPrefix([]byte{0x80}), DeepEquals, [][]byte{{0x80, 0x01}, {0x80, 0x02}, {0x80, 0x03}})
|
||||
|
||||
s.db.Put([]byte{0x00, 0x01}, []byte{0x05})
|
||||
_ = s.db.Put([]byte{0x00, 0x01}, []byte{0x05})
|
||||
c.Check(s.db.FetchByPrefix([]byte{0x80}), DeepEquals, [][]byte{{0x01}, {0x02}, {0x03}})
|
||||
c.Check(s.db.KeysByPrefix([]byte{0x80}), DeepEquals, [][]byte{{0x80, 0x01}, {0x80, 0x02}, {0x80, 0x03}})
|
||||
|
||||
@@ -109,7 +108,7 @@ func (s *EtcDDBSuite) TestHasPrefix(c *C) {
|
||||
//c.Check(s.db.HasPrefix([]byte(nil)), Equals, false)
|
||||
//c.Check(s.db.HasPrefix([]byte{0x80}), Equals, false)
|
||||
|
||||
s.db.Put([]byte{0x80, 0x01}, []byte{0x01})
|
||||
_ = s.db.Put([]byte{0x80, 0x01}, []byte{0x01})
|
||||
|
||||
c.Check(s.db.HasPrefix([]byte(nil)), Equals, true)
|
||||
c.Check(s.db.HasPrefix([]byte{0x80}), Equals, true)
|
||||
@@ -124,13 +123,15 @@ func (s *EtcDDBSuite) TestTransactionCommit(c *C) {
|
||||
value2 = []byte("value2")
|
||||
)
|
||||
transaction, err := s.db.OpenTransaction()
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
err = s.db.Put(key, value)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
c.Assert(err, IsNil)
|
||||
transaction.Put(key2, value2)
|
||||
_ = transaction.Put(key2, value2)
|
||||
v, err := s.db.Get(key)
|
||||
c.Assert(err, IsNil)
|
||||
c.Check(v, DeepEquals, value)
|
||||
err = transaction.Delete(key)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
@@ -145,7 +145,7 @@ func (s *EtcDStorage) Close() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Reopen tries to open (re-open) the database
|
||||
// Open returns the database
|
||||
func (s *EtcDStorage) Open() error {
|
||||
if s.db != nil {
|
||||
return nil
|
||||
|
||||
@@ -67,8 +67,7 @@ func (t *transaction) Commit() (err error) {
|
||||
// Discard is safe to call after Commit(), it would be no-op
|
||||
func (t *transaction) Discard() {
|
||||
t.ops = []clientv3.Op{}
|
||||
t.tmpdb.Drop()
|
||||
return
|
||||
_ = t.tmpdb.Drop()
|
||||
}
|
||||
|
||||
// transaction should implement database.Transaction
|
||||
|
||||
@@ -51,8 +51,8 @@ func RecoverDB(path string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
db.Close()
|
||||
stor.Close()
|
||||
_ = db.Close()
|
||||
_ = stor.Close()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -119,17 +119,17 @@ func (s *LevelDBSuite) TestDelete(c *C) {
|
||||
func (s *LevelDBSuite) TestByPrefix(c *C) {
|
||||
c.Check(s.db.FetchByPrefix([]byte{0x80}), DeepEquals, [][]byte{})
|
||||
|
||||
s.db.Put([]byte{0x80, 0x01}, []byte{0x01})
|
||||
s.db.Put([]byte{0x80, 0x03}, []byte{0x03})
|
||||
s.db.Put([]byte{0x80, 0x02}, []byte{0x02})
|
||||
_ = s.db.Put([]byte{0x80, 0x01}, []byte{0x01})
|
||||
_ = s.db.Put([]byte{0x80, 0x03}, []byte{0x03})
|
||||
_ = s.db.Put([]byte{0x80, 0x02}, []byte{0x02})
|
||||
c.Check(s.db.FetchByPrefix([]byte{0x80}), DeepEquals, [][]byte{{0x01}, {0x02}, {0x03}})
|
||||
c.Check(s.db.KeysByPrefix([]byte{0x80}), DeepEquals, [][]byte{{0x80, 0x01}, {0x80, 0x02}, {0x80, 0x03}})
|
||||
|
||||
s.db.Put([]byte{0x90, 0x01}, []byte{0x04})
|
||||
_ = s.db.Put([]byte{0x90, 0x01}, []byte{0x04})
|
||||
c.Check(s.db.FetchByPrefix([]byte{0x80}), DeepEquals, [][]byte{{0x01}, {0x02}, {0x03}})
|
||||
c.Check(s.db.KeysByPrefix([]byte{0x80}), DeepEquals, [][]byte{{0x80, 0x01}, {0x80, 0x02}, {0x80, 0x03}})
|
||||
|
||||
s.db.Put([]byte{0x00, 0x01}, []byte{0x05})
|
||||
_ = s.db.Put([]byte{0x00, 0x01}, []byte{0x05})
|
||||
c.Check(s.db.FetchByPrefix([]byte{0x80}), DeepEquals, [][]byte{{0x01}, {0x02}, {0x03}})
|
||||
c.Check(s.db.KeysByPrefix([]byte{0x80}), DeepEquals, [][]byte{{0x80, 0x01}, {0x80, 0x02}, {0x80, 0x03}})
|
||||
|
||||
@@ -161,7 +161,7 @@ func (s *LevelDBSuite) TestHasPrefix(c *C) {
|
||||
c.Check(s.db.HasPrefix([]byte(nil)), Equals, false)
|
||||
c.Check(s.db.HasPrefix([]byte{0x80}), Equals, false)
|
||||
|
||||
s.db.Put([]byte{0x80, 0x01}, []byte{0x01})
|
||||
_ = s.db.Put([]byte{0x80, 0x01}, []byte{0x01})
|
||||
|
||||
c.Check(s.db.HasPrefix([]byte(nil)), Equals, true)
|
||||
c.Check(s.db.HasPrefix([]byte{0x80}), Equals, true)
|
||||
@@ -180,8 +180,8 @@ func (s *LevelDBSuite) TestBatch(c *C) {
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
batch := s.db.CreateBatch()
|
||||
batch.Put(key2, value2)
|
||||
batch.Delete(key)
|
||||
_ = batch.Put(key2, value2)
|
||||
_ = batch.Delete(key)
|
||||
|
||||
v, err := s.db.Get(key)
|
||||
c.Check(err, IsNil)
|
||||
@@ -202,9 +202,9 @@ func (s *LevelDBSuite) TestBatch(c *C) {
|
||||
}
|
||||
|
||||
func (s *LevelDBSuite) TestCompactDB(c *C) {
|
||||
s.db.Put([]byte{0x80, 0x01}, []byte{0x01})
|
||||
s.db.Put([]byte{0x80, 0x03}, []byte{0x03})
|
||||
s.db.Put([]byte{0x80, 0x02}, []byte{0x02})
|
||||
_ = s.db.Put([]byte{0x80, 0x01}, []byte{0x01})
|
||||
_ = s.db.Put([]byte{0x80, 0x03}, []byte{0x03})
|
||||
_ = s.db.Put([]byte{0x80, 0x02}, []byte{0x02})
|
||||
|
||||
c.Check(s.db.CompactDB(), IsNil)
|
||||
}
|
||||
|
||||
+8
-8
@@ -60,14 +60,14 @@ func (c *Changes) VerifyAndParse(acceptUnsigned, ignoreSignature bool, verifier
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer input.Close()
|
||||
defer func() { _ = input.Close() }()
|
||||
|
||||
isClearSigned, err := verifier.IsClearSigned(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
input.Seek(0, 0)
|
||||
_, _ = input.Seek(0, 0)
|
||||
|
||||
if !isClearSigned && !acceptUnsigned {
|
||||
return fmt.Errorf(".changes file is not signed and unsigned processing hasn't been enabled")
|
||||
@@ -79,7 +79,7 @@ func (c *Changes) VerifyAndParse(acceptUnsigned, ignoreSignature bool, verifier
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
input.Seek(0, 0)
|
||||
_, _ = input.Seek(0, 0)
|
||||
|
||||
c.SignatureKeys = keyInfo.GoodKeys
|
||||
}
|
||||
@@ -91,7 +91,7 @@ func (c *Changes) VerifyAndParse(acceptUnsigned, ignoreSignature bool, verifier
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer text.Close()
|
||||
defer func() { _ = text.Close() }()
|
||||
} else {
|
||||
text = input
|
||||
}
|
||||
@@ -307,7 +307,7 @@ func ImportChangesFiles(changesFiles []string, reporter aptly.ResultReporter, ac
|
||||
if err != nil {
|
||||
failedFiles = append(failedFiles, path)
|
||||
reporter.Warning("unable to process file %s: %s", changes.ChangesName, err)
|
||||
changes.Cleanup()
|
||||
_ = changes.Cleanup()
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ func ImportChangesFiles(changesFiles []string, reporter aptly.ResultReporter, ac
|
||||
if err != nil {
|
||||
failedFiles = append(failedFiles, path)
|
||||
reporter.Warning("unable to process file %s: %s", changes.ChangesName, err)
|
||||
changes.Cleanup()
|
||||
_ = changes.Cleanup()
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ func ImportChangesFiles(changesFiles []string, reporter aptly.ResultReporter, ac
|
||||
if err != nil {
|
||||
failedFiles = append(failedFiles, path)
|
||||
reporter.Warning("unable to process file %s: %s", changes.ChangesName, err)
|
||||
changes.Cleanup()
|
||||
_ = changes.Cleanup()
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ func ImportChangesFiles(changesFiles []string, reporter aptly.ResultReporter, ac
|
||||
failedFiles = append(failedFiles, path)
|
||||
reporter.Warning("changes file skipped due to uploaders config: %s, keys %#v: %s",
|
||||
changes.ChangesName, changes.SignatureKeys, err)
|
||||
changes.Cleanup()
|
||||
_ = changes.Cleanup()
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -51,7 +51,7 @@ func (s *ChangesSuite) SetUpTest(c *C) {
|
||||
|
||||
func (s *ChangesSuite) TearDownTest(c *C) {
|
||||
s.progress.Shutdown()
|
||||
s.db.Close()
|
||||
_ = s.db.Close()
|
||||
}
|
||||
|
||||
func (s *ChangesSuite) TestParseAndVerify(c *C) {
|
||||
@@ -108,13 +108,13 @@ func (s *ChangesSuite) TestImportChangesFiles(c *C) {
|
||||
|
||||
for _, path := range origFailedFiles {
|
||||
filename := filepath.Join(s.Dir, filepath.Base(path))
|
||||
utils.CopyFile(path, filename)
|
||||
_ = utils.CopyFile(path, filename)
|
||||
expectedFailedFiles = append(expectedFailedFiles, filename)
|
||||
}
|
||||
|
||||
for _, path := range origProcessedFiles {
|
||||
filename := filepath.Join(s.Dir, filepath.Base(path))
|
||||
utils.CopyFile(path, filename)
|
||||
_ = utils.CopyFile(path, filename)
|
||||
expectedProcessedFiles = append(expectedProcessedFiles, filename)
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ func (s *ChecksumCollectionSuite) SetUpTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *ChecksumCollectionSuite) TearDownTest(c *C) {
|
||||
s.db.Close()
|
||||
_ = s.db.Close()
|
||||
}
|
||||
|
||||
func (s *ChecksumCollectionSuite) TestFlow(c *C) {
|
||||
|
||||
+10
-10
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/aptly-dev/aptly/pgp"
|
||||
"github.com/kjk/lzma"
|
||||
"github.com/klauspost/compress/zstd"
|
||||
"github.com/smira/go-xz"
|
||||
xz "github.com/smira/go-xz"
|
||||
)
|
||||
|
||||
// Source kinds
|
||||
@@ -35,7 +35,7 @@ func GetControlFileFromDeb(packageFile string) (Stanza, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
defer func() { _ = file.Close() }()
|
||||
|
||||
library := ar.NewReader(file)
|
||||
for {
|
||||
@@ -66,14 +66,14 @@ func GetControlFileFromDeb(packageFile string) (Stanza, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to ungzip %s from %s", header.Name, packageFile)
|
||||
}
|
||||
defer ungzip.Close()
|
||||
defer func() { _ = ungzip.Close() }()
|
||||
tarInput = ungzip
|
||||
case "control.tar.xz":
|
||||
unxz, err := xz.NewReader(bufReader)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to unxz %s from %s", header.Name, packageFile)
|
||||
}
|
||||
defer unxz.Close()
|
||||
defer func() { _ = unxz.Close() }()
|
||||
tarInput = unxz
|
||||
case "control.tar.zst":
|
||||
unzstd, err := zstd.NewReader(bufReader)
|
||||
@@ -116,10 +116,10 @@ func GetControlFileFromDsc(dscFile string, verifier pgp.Verifier) (Stanza, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
defer func() { _ = file.Close() }()
|
||||
|
||||
isClearSigned, err := verifier.IsClearSigned(file)
|
||||
file.Seek(0, 0)
|
||||
_, _ = file.Seek(0, 0)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -132,7 +132,7 @@ func GetControlFileFromDsc(dscFile string, verifier pgp.Verifier) (Stanza, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer text.Close()
|
||||
defer func() { _ = text.Close() }()
|
||||
} else {
|
||||
text = file
|
||||
}
|
||||
@@ -181,7 +181,7 @@ func GetContentsFromDeb(file io.Reader, packageFile string) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to ungzip data.tar.gz from %s", packageFile)
|
||||
}
|
||||
defer ungzip.Close()
|
||||
defer func() { _ = ungzip.Close() }()
|
||||
tarInput = ungzip
|
||||
}
|
||||
case "data.tar.bz2":
|
||||
@@ -191,11 +191,11 @@ func GetContentsFromDeb(file io.Reader, packageFile string) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to unxz data.tar.xz from %s", packageFile)
|
||||
}
|
||||
defer unxz.Close()
|
||||
defer func() { _ = unxz.Close() }()
|
||||
tarInput = unxz
|
||||
case "data.tar.lzma":
|
||||
unlzma := lzma.NewReader(bufReader)
|
||||
defer unlzma.Close()
|
||||
defer func() { _ = unlzma.Close() }()
|
||||
tarInput = unlzma
|
||||
case "data.tar.zst":
|
||||
unzstd, err := zstd.NewReader(bufReader)
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package deb
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/aptly-dev/aptly/database"
|
||||
)
|
||||
|
||||
// FindDanglingReferences finds references that exist in the given PackageRefList, but not in the given PackageCollection.
|
||||
// It returns all such references, so they can be removed from the database.
|
||||
func FindDanglingReferences(reflist *PackageRefList, packages *PackageCollection) (dangling *PackageRefList, err error) {
|
||||
dangling = &PackageRefList{}
|
||||
|
||||
err = reflist.ForEach(func(key []byte) error {
|
||||
ok, err := isDangling(packages, key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if ok {
|
||||
dangling.Refs = append(dangling.Refs, key)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dangling, nil
|
||||
}
|
||||
|
||||
func isDangling(packages *PackageCollection, key []byte) (bool, error) {
|
||||
_, err := packages.ByKey(key)
|
||||
if errors.Is(err, database.ErrNotFound) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("get reference %q: %w", key, err)
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package deb_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/aptly-dev/aptly/database/goleveldb"
|
||||
"github.com/aptly-dev/aptly/deb"
|
||||
)
|
||||
|
||||
func TestFindDanglingReferences(t *testing.T) {
|
||||
reflist := deb.NewPackageRefList()
|
||||
reflist.Refs = [][]byte{[]byte("P existing 1.2.3"), []byte("P dangling 1.2.3")}
|
||||
|
||||
db, _ := goleveldb.NewOpenDB(t.TempDir())
|
||||
packages := deb.NewPackageCollection(db)
|
||||
|
||||
if err := packages.Update(&deb.Package{Name: "existing", Version: "1.2.3"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
dangling, err := deb.FindDanglingReferences(reflist, packages)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
exp := &deb.PackageRefList{
|
||||
Refs: [][]byte{[]byte("P dangling 1.2.3")},
|
||||
}
|
||||
|
||||
compareRefs(t, exp, dangling)
|
||||
}
|
||||
|
||||
func compareRefs(t *testing.T, exp, got *deb.PackageRefList) {
|
||||
t.Helper()
|
||||
|
||||
if len(exp.Refs) != len(got.Refs) {
|
||||
t.Fatalf("refs length mismatch: exp %d, got %d", len(exp.Refs), len(got.Refs))
|
||||
}
|
||||
|
||||
for i := range exp.Refs {
|
||||
if !bytes.Equal(exp.Refs[i], got.Refs[i]) {
|
||||
t.Fatalf("refs do not match: exp %q, got %q", exp.Refs[i], got.Refs[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -163,7 +163,7 @@ func (s *ControlFileSuite) TestCanonicalCase(c *C) {
|
||||
func (s *ControlFileSuite) TestLongFields(c *C) {
|
||||
f, err := os.Open("long.stanza")
|
||||
c.Assert(err, IsNil)
|
||||
defer f.Close()
|
||||
defer func() { _ = f.Close() }()
|
||||
|
||||
r := NewControlFileReader(f, false, false)
|
||||
stanza, e := r.ReadStanza()
|
||||
|
||||
+11
-11
@@ -12,15 +12,15 @@ func BuildGraph(collectionFactory *CollectionFactory, layout string) (gographviz
|
||||
var err error
|
||||
|
||||
graph := gographviz.NewEscape()
|
||||
graph.SetDir(true)
|
||||
graph.SetName("aptly")
|
||||
_ = graph.SetDir(true)
|
||||
_ = graph.SetName("aptly")
|
||||
|
||||
var labelStart string
|
||||
var labelEnd string
|
||||
|
||||
switch layout {
|
||||
case "vertical":
|
||||
graph.AddAttr("aptly", "rankdir", "LR")
|
||||
_ = graph.AddAttr("aptly", "rankdir", "LR")
|
||||
labelStart = ""
|
||||
labelEnd = ""
|
||||
case "horizontal":
|
||||
@@ -38,7 +38,7 @@ func BuildGraph(collectionFactory *CollectionFactory, layout string) (gographviz
|
||||
return e
|
||||
}
|
||||
|
||||
graph.AddNode("aptly", repo.UUID, map[string]string{
|
||||
_ = graph.AddNode("aptly", repo.UUID, map[string]string{
|
||||
"shape": "Mrecord",
|
||||
"style": "filled",
|
||||
"fillcolor": "darkgoldenrod1",
|
||||
@@ -60,7 +60,7 @@ func BuildGraph(collectionFactory *CollectionFactory, layout string) (gographviz
|
||||
return e
|
||||
}
|
||||
|
||||
graph.AddNode("aptly", repo.UUID, map[string]string{
|
||||
_ = graph.AddNode("aptly", repo.UUID, map[string]string{
|
||||
"shape": "Mrecord",
|
||||
"style": "filled",
|
||||
"fillcolor": "mediumseagreen",
|
||||
@@ -75,7 +75,7 @@ func BuildGraph(collectionFactory *CollectionFactory, layout string) (gographviz
|
||||
return nil, err
|
||||
}
|
||||
|
||||
collectionFactory.SnapshotCollection().ForEach(func(snapshot *Snapshot) error {
|
||||
_ = collectionFactory.SnapshotCollection().ForEach(func(snapshot *Snapshot) error {
|
||||
existingNodes[snapshot.UUID] = true
|
||||
return nil
|
||||
})
|
||||
@@ -91,7 +91,7 @@ func BuildGraph(collectionFactory *CollectionFactory, layout string) (gographviz
|
||||
description = "Snapshot from repo"
|
||||
}
|
||||
|
||||
graph.AddNode("aptly", snapshot.UUID, map[string]string{
|
||||
_ = graph.AddNode("aptly", snapshot.UUID, map[string]string{
|
||||
"shape": "Mrecord",
|
||||
"style": "filled",
|
||||
"fillcolor": "cadetblue1",
|
||||
@@ -103,7 +103,7 @@ func BuildGraph(collectionFactory *CollectionFactory, layout string) (gographviz
|
||||
for _, uuid := range snapshot.SourceIDs {
|
||||
_, exists := existingNodes[uuid]
|
||||
if exists {
|
||||
graph.AddEdge(uuid, snapshot.UUID, true, nil)
|
||||
_ = graph.AddEdge(uuid, snapshot.UUID, true, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,8 +114,8 @@ func BuildGraph(collectionFactory *CollectionFactory, layout string) (gographviz
|
||||
return nil, err
|
||||
}
|
||||
|
||||
collectionFactory.PublishedRepoCollection().ForEach(func(repo *PublishedRepo) error {
|
||||
graph.AddNode("aptly", repo.UUID, map[string]string{
|
||||
_ = collectionFactory.PublishedRepoCollection().ForEach(func(repo *PublishedRepo) error {
|
||||
_ = graph.AddNode("aptly", repo.UUID, map[string]string{
|
||||
"shape": "Mrecord",
|
||||
"style": "filled",
|
||||
"fillcolor": "darkolivegreen1",
|
||||
@@ -127,7 +127,7 @@ func BuildGraph(collectionFactory *CollectionFactory, layout string) (gographviz
|
||||
for _, uuid := range repo.Sources {
|
||||
_, exists := existingNodes[uuid]
|
||||
if exists {
|
||||
graph.AddEdge(uuid, repo.UUID, true, nil)
|
||||
_ = graph.AddEdge(uuid, repo.UUID, true, nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -59,24 +59,24 @@ func (file *indexFile) Finalize(signer pgp.Signer) error {
|
||||
if file.discardable {
|
||||
return nil
|
||||
}
|
||||
file.BufWriter()
|
||||
_, _ = file.BufWriter()
|
||||
}
|
||||
|
||||
err := file.w.Flush()
|
||||
if err != nil {
|
||||
file.tempFile.Close()
|
||||
_ = file.tempFile.Close()
|
||||
return fmt.Errorf("unable to write to index file: %s", err)
|
||||
}
|
||||
|
||||
if file.compressable {
|
||||
err = utils.CompressFile(file.tempFile, file.onlyGzip || file.parent.skipBz2)
|
||||
if err != nil {
|
||||
file.tempFile.Close()
|
||||
_ = file.tempFile.Close()
|
||||
return fmt.Errorf("unable to compress index file: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
file.tempFile.Close()
|
||||
_ = file.tempFile.Close()
|
||||
|
||||
exts := []string{""}
|
||||
cksumExts := exts
|
||||
@@ -220,11 +220,11 @@ func packageIndexByHash(file *indexFile, ext string, hash string, sum string) er
|
||||
// If we managed to resolve the link target: delete it. This is the
|
||||
// oldest physical index file we no longer need. Once we drop our
|
||||
// old symlink we'll essentially forget about it existing at all.
|
||||
file.parent.publishedStorage.Remove(linkTarget)
|
||||
_ = file.parent.publishedStorage.Remove(linkTarget)
|
||||
}
|
||||
file.parent.publishedStorage.Remove(oldIndexPath)
|
||||
_ = file.parent.publishedStorage.Remove(oldIndexPath)
|
||||
}
|
||||
file.parent.publishedStorage.RenameFile(indexPath, oldIndexPath)
|
||||
_ = file.parent.publishedStorage.RenameFile(indexPath, oldIndexPath)
|
||||
}
|
||||
|
||||
// create symlink
|
||||
|
||||
+2
-2
@@ -438,7 +438,7 @@ func (l *PackageList) Scan(q PackageQuery) (result *PackageList) {
|
||||
result = NewPackageListWithDuplicates(l.duplicatesAllowed, 0)
|
||||
for _, pkg := range l.packages {
|
||||
if q.Matches(pkg) {
|
||||
result.Add(pkg)
|
||||
_ = result.Add(pkg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ func (l *PackageList) SearchByKey(arch, name, version string) (result *PackageLi
|
||||
|
||||
pkg := l.packages["P"+arch+" "+name+" "+version]
|
||||
if pkg != nil {
|
||||
result.Add(pkg)
|
||||
_ = result.Add(pkg)
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
+10
-10
@@ -96,7 +96,7 @@ func (s *PackageListSuite) SetUpTest(c *C) {
|
||||
{Name: "dpkg", Version: "1.7", Architecture: "source", SourceArchitecture: "any", IsSource: true, deps: &PackageDependencies{}},
|
||||
}
|
||||
for _, p := range s.packages {
|
||||
s.il.Add(p)
|
||||
_ = s.il.Add(p)
|
||||
}
|
||||
s.il.PrepareIndex()
|
||||
|
||||
@@ -110,7 +110,7 @@ func (s *PackageListSuite) SetUpTest(c *C) {
|
||||
{Name: "app", Version: "3.0", Architecture: "amd64", deps: &PackageDependencies{PreDepends: []string{"dpkg >= 1.6)"}, Depends: []string{"lib (>> 0.9)", "data (>= 1.0)"}}},
|
||||
}
|
||||
for _, p := range s.packages2 {
|
||||
s.il2.Add(p)
|
||||
_ = s.il2.Add(p)
|
||||
}
|
||||
s.il2.PrepareIndex()
|
||||
|
||||
@@ -202,8 +202,8 @@ func (s *PackageListSuite) TestRemoveWhenIndexed(c *C) {
|
||||
}
|
||||
|
||||
func (s *PackageListSuite) TestForeach(c *C) {
|
||||
s.list.Add(s.p1)
|
||||
s.list.Add(s.p3)
|
||||
_ = s.list.Add(s.p1)
|
||||
_ = s.list.Add(s.p3)
|
||||
|
||||
Len := 0
|
||||
err := s.list.ForEach(func(*Package) error {
|
||||
@@ -232,21 +232,21 @@ func (s *PackageListSuite) TestIndex(c *C) {
|
||||
}
|
||||
|
||||
func (s *PackageListSuite) TestAppend(c *C) {
|
||||
s.list.Add(s.p1)
|
||||
s.list.Add(s.p3)
|
||||
_ = s.list.Add(s.p1)
|
||||
_ = s.list.Add(s.p3)
|
||||
|
||||
err := s.list.Append(s.il)
|
||||
c.Check(err, IsNil)
|
||||
c.Check(s.list.Len(), Equals, 16)
|
||||
|
||||
list := NewPackageList()
|
||||
list.Add(s.p4)
|
||||
_ = list.Add(s.p4)
|
||||
|
||||
err = s.list.Append(list)
|
||||
c.Check(err, ErrorMatches, "package already exists and is different: .*")
|
||||
|
||||
s.list.PrepareIndex()
|
||||
c.Check(func() { s.list.Append(s.il) }, Panics, "Append not supported when indexed")
|
||||
c.Check(func() { _ = s.list.Append(s.il) }, Panics, "Append not supported when indexed")
|
||||
}
|
||||
|
||||
func (s *PackageListSuite) TestSearch(c *C) {
|
||||
@@ -312,7 +312,7 @@ func (s *PackageListSuite) TestSearch(c *C) {
|
||||
|
||||
func (s *PackageListSuite) TestFilter(c *C) {
|
||||
c.Check(func() {
|
||||
s.list.Filter(FilterOptions{
|
||||
_, _ = s.list.Filter(FilterOptions{
|
||||
Queries: []PackageQuery{&PkgQuery{"abcd", "0.3", "i386"}},
|
||||
})
|
||||
}, Panics, "list not indexed, can't filter")
|
||||
@@ -479,7 +479,7 @@ func (s *PackageListSuite) TestVerifyDependencies(c *C) {
|
||||
{Pkg: "mail-agent", Relation: VersionDontCare, Version: "", Architecture: "arm"}})
|
||||
|
||||
for _, p := range s.sourcePackages {
|
||||
s.il.Add(p)
|
||||
_ = s.il.Add(p)
|
||||
}
|
||||
|
||||
missing, err = s.il.VerifyDependencies(DepFollowSource, []string{"i386", "amd64"}, s.il, nil)
|
||||
|
||||
+6
-6
@@ -69,7 +69,7 @@ func (repo *LocalRepo) Encode() []byte {
|
||||
var buf bytes.Buffer
|
||||
|
||||
encoder := codec.NewEncoder(&buf, &codec.MsgpackHandle{})
|
||||
encoder.Encode(repo)
|
||||
_ = encoder.Encode(repo)
|
||||
|
||||
return buf.Bytes()
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func (collection *LocalRepoCollection) search(filter func(*LocalRepo) bool, uniq
|
||||
return result
|
||||
}
|
||||
|
||||
collection.db.ProcessByPrefix([]byte("L"), func(_, blob []byte) error {
|
||||
_ = collection.db.ProcessByPrefix([]byte("L"), func(_, blob []byte) error {
|
||||
r := &LocalRepo{}
|
||||
if err := r.Decode(blob); err != nil {
|
||||
log.Printf("Error decoding local repo: %s\n", err)
|
||||
@@ -159,9 +159,9 @@ func (collection *LocalRepoCollection) Add(repo *LocalRepo) error {
|
||||
// Update stores updated information about repo in DB
|
||||
func (collection *LocalRepoCollection) Update(repo *LocalRepo) error {
|
||||
batch := collection.db.CreateBatch()
|
||||
batch.Put(repo.Key(), repo.Encode())
|
||||
_ = batch.Put(repo.Key(), repo.Encode())
|
||||
if repo.packageRefs != nil {
|
||||
batch.Put(repo.RefKey(), repo.packageRefs.Encode())
|
||||
_ = batch.Put(repo.RefKey(), repo.packageRefs.Encode())
|
||||
}
|
||||
return batch.Write()
|
||||
}
|
||||
@@ -247,7 +247,7 @@ func (collection *LocalRepoCollection) Drop(repo *LocalRepo) error {
|
||||
delete(collection.cache, repo.UUID)
|
||||
|
||||
batch := collection.db.CreateBatch()
|
||||
batch.Delete(repo.Key())
|
||||
batch.Delete(repo.RefKey())
|
||||
_ = batch.Delete(repo.Key())
|
||||
_ = batch.Delete(repo.RefKey())
|
||||
return batch.Write()
|
||||
}
|
||||
|
||||
+10
-10
@@ -21,8 +21,8 @@ var _ = Suite(&LocalRepoSuite{})
|
||||
func (s *LocalRepoSuite) SetUpTest(c *C) {
|
||||
s.db, _ = goleveldb.NewOpenDB(c.MkDir())
|
||||
s.list = NewPackageList()
|
||||
s.list.Add(&Package{Name: "lib", Version: "1.7", Architecture: "i386"})
|
||||
s.list.Add(&Package{Name: "app", Version: "1.9", Architecture: "amd64"})
|
||||
_ = s.list.Add(&Package{Name: "lib", Version: "1.7", Architecture: "i386"})
|
||||
_ = s.list.Add(&Package{Name: "app", Version: "1.9", Architecture: "amd64"})
|
||||
|
||||
s.reflist = NewPackageRefListFromPackageList(s.list)
|
||||
|
||||
@@ -31,7 +31,7 @@ func (s *LocalRepoSuite) SetUpTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *LocalRepoSuite) TearDownTest(c *C) {
|
||||
s.db.Close()
|
||||
_ = s.db.Close()
|
||||
}
|
||||
|
||||
func (s *LocalRepoSuite) TestString(c *C) {
|
||||
@@ -88,14 +88,14 @@ func (s *LocalRepoCollectionSuite) SetUpTest(c *C) {
|
||||
s.collection = NewLocalRepoCollection(s.db)
|
||||
|
||||
s.list = NewPackageList()
|
||||
s.list.Add(&Package{Name: "lib", Version: "1.7", Architecture: "i386"})
|
||||
s.list.Add(&Package{Name: "app", Version: "1.9", Architecture: "amd64"})
|
||||
_ = s.list.Add(&Package{Name: "lib", Version: "1.7", Architecture: "i386"})
|
||||
_ = s.list.Add(&Package{Name: "app", Version: "1.9", Architecture: "amd64"})
|
||||
|
||||
s.reflist = NewPackageRefListFromPackageList(s.list)
|
||||
}
|
||||
|
||||
func (s *LocalRepoCollectionSuite) TearDownTest(c *C) {
|
||||
s.db.Close()
|
||||
_ = s.db.Close()
|
||||
}
|
||||
|
||||
func (s *LocalRepoCollectionSuite) TestAddByName(c *C) {
|
||||
@@ -156,7 +156,7 @@ func (s *LocalRepoCollectionSuite) TestUpdateLoadComplete(c *C) {
|
||||
|
||||
func (s *LocalRepoCollectionSuite) TestForEachAndLen(c *C) {
|
||||
repo := NewLocalRepo("local1", "Comment 1")
|
||||
s.collection.Add(repo)
|
||||
_ = s.collection.Add(repo)
|
||||
|
||||
count := 0
|
||||
err := s.collection.ForEach(func(*LocalRepo) error {
|
||||
@@ -178,10 +178,10 @@ func (s *LocalRepoCollectionSuite) TestForEachAndLen(c *C) {
|
||||
|
||||
func (s *LocalRepoCollectionSuite) TestDrop(c *C) {
|
||||
repo1 := NewLocalRepo("local1", "Comment 1")
|
||||
s.collection.Add(repo1)
|
||||
_ = s.collection.Add(repo1)
|
||||
|
||||
repo2 := NewLocalRepo("local2", "Comment 2")
|
||||
s.collection.Add(repo2)
|
||||
_ = s.collection.Add(repo2)
|
||||
|
||||
r1, _ := s.collection.ByUUID(repo1.UUID)
|
||||
c.Check(r1, Equals, repo1)
|
||||
@@ -208,6 +208,6 @@ func (s *LocalRepoCollectionSuite) TestDropNonExisting(c *C) {
|
||||
_, err := s.collection.ByUUID(repo.UUID)
|
||||
c.Check(err, ErrorMatches, "local repo .* not found")
|
||||
|
||||
err = s.collection.Drop(repo)
|
||||
_ = s.collection.Drop(repo)
|
||||
c.Check(s.collection.Drop(repo), ErrorMatches, "local repo not found")
|
||||
}
|
||||
|
||||
+1
-1
@@ -565,7 +565,7 @@ func (p *Package) CalculateContents(packagePool aptly.PackagePool, progress aptl
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
defer reader.Close()
|
||||
defer func() { _ = reader.Close() }()
|
||||
|
||||
contents, err := GetContentsFromDeb(reader, file.Filename)
|
||||
if err != nil {
|
||||
|
||||
@@ -309,7 +309,7 @@ func (collection *PackageCollection) Scan(q PackageQuery) (result *PackageList)
|
||||
}
|
||||
|
||||
if q.Matches(pkg) {
|
||||
result.Add(pkg)
|
||||
_ = result.Add(pkg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ func (collection *PackageCollection) SearchByKey(arch, name, version string) (re
|
||||
}
|
||||
|
||||
if pkg.Architecture == arch && pkg.Name == name && pkg.Version == version {
|
||||
result.Add(pkg)
|
||||
_ = result.Add(pkg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func (s *PackageCollectionSuite) SetUpTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *PackageCollectionSuite) TearDownTest(c *C) {
|
||||
s.db.Close()
|
||||
_ = s.db.Close()
|
||||
}
|
||||
|
||||
func (s *PackageCollectionSuite) TestUpdate(c *C) {
|
||||
@@ -67,7 +67,7 @@ func (s *PackageCollectionSuite) TestByKey(c *C) {
|
||||
|
||||
func (s *PackageCollectionSuite) TestByKeyOld0_3(c *C) {
|
||||
key := []byte("Pi386 vmware-view-open-client 4.5.0-297975+dfsg-4+b1")
|
||||
s.db.Put(key, old0_3Package)
|
||||
_ = s.db.Put(key, old0_3Package)
|
||||
|
||||
p, err := s.collection.ByKey(key)
|
||||
c.Check(err, IsNil)
|
||||
|
||||
@@ -64,7 +64,7 @@ func (files PackageFiles) Hash() uint64 {
|
||||
|
||||
for _, f := range files {
|
||||
h.Write([]byte(f.Filename))
|
||||
binary.Write(h, binary.BigEndian, f.Checksums.Size)
|
||||
_ = binary.Write(h, binary.BigEndian, f.Checksums.Size)
|
||||
h.Write([]byte(f.Checksums.MD5))
|
||||
h.Write([]byte(f.Checksums.SHA1))
|
||||
h.Write([]byte(f.Checksums.SHA256))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package deb
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/aptly-dev/aptly/aptly"
|
||||
@@ -39,7 +39,7 @@ func (s *PackageFilesSuite) TestVerify(c *C) {
|
||||
c.Check(result, Equals, false)
|
||||
|
||||
tmpFilepath := filepath.Join(c.MkDir(), "file")
|
||||
c.Assert(ioutil.WriteFile(tmpFilepath, []byte("abcde"), 0777), IsNil)
|
||||
c.Assert(os.WriteFile(tmpFilepath, []byte("abcde"), 0777), IsNil)
|
||||
|
||||
s.files[0].PoolPath, _ = packagePool.Import(tmpFilepath, s.files[0].Filename, &s.files[0].Checksums, false, s.cs)
|
||||
|
||||
|
||||
+4
-4
@@ -2,7 +2,7 @@ package deb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
||||
@@ -395,7 +395,7 @@ func (s *PackageSuite) TestLinkFromPool(c *C) {
|
||||
p := NewPackageFromControlFile(s.stanza)
|
||||
|
||||
tmpFilepath := filepath.Join(c.MkDir(), "file")
|
||||
c.Assert(ioutil.WriteFile(tmpFilepath, nil, 0777), IsNil)
|
||||
c.Assert(os.WriteFile(tmpFilepath, nil, 0777), IsNil)
|
||||
|
||||
p.Files()[0].PoolPath, _ = packagePool.Import(tmpFilepath, p.Files()[0].Filename, &p.Files()[0].Checksums, false, cs)
|
||||
|
||||
@@ -434,7 +434,7 @@ func (s *PackageSuite) TestDownloadList(c *C) {
|
||||
})
|
||||
|
||||
tmpFilepath := filepath.Join(c.MkDir(), "file")
|
||||
c.Assert(ioutil.WriteFile(tmpFilepath, []byte("abcde"), 0777), IsNil)
|
||||
c.Assert(os.WriteFile(tmpFilepath, []byte("abcde"), 0777), IsNil)
|
||||
p.Files()[0].PoolPath, _ = packagePool.Import(tmpFilepath, p.Files()[0].Filename, &p.Files()[0].Checksums, false, cs)
|
||||
|
||||
list, err = p.DownloadList(packagePool, cs)
|
||||
@@ -449,7 +449,7 @@ func (s *PackageSuite) TestVerifyFiles(c *C) {
|
||||
cs := files.NewMockChecksumStorage()
|
||||
|
||||
tmpFilepath := filepath.Join(c.MkDir(), "file")
|
||||
c.Assert(ioutil.WriteFile(tmpFilepath, []byte("abcde"), 0777), IsNil)
|
||||
c.Assert(os.WriteFile(tmpFilepath, []byte("abcde"), 0777), IsNil)
|
||||
|
||||
p.Files()[0].PoolPath, _ = packagePool.Import(tmpFilepath, p.Files()[0].Filename, &p.Files()[0].Checksums, false, cs)
|
||||
|
||||
|
||||
+11
-11
@@ -631,7 +631,7 @@ func (p *PublishedRepo) Components() []string {
|
||||
return result
|
||||
}
|
||||
|
||||
// Components returns sorted list of published repo source names
|
||||
// SourceNames returns sorted list of published repo source names
|
||||
func (p *PublishedRepo) SourceNames() []string {
|
||||
var sources = []string{}
|
||||
|
||||
@@ -702,7 +702,7 @@ func (p *PublishedRepo) Encode() []byte {
|
||||
var buf bytes.Buffer
|
||||
|
||||
encoder := codec.NewEncoder(&buf, &codec.MsgpackHandle{})
|
||||
encoder.Encode(p)
|
||||
_ = encoder.Encode(p)
|
||||
|
||||
return buf.Bytes()
|
||||
}
|
||||
@@ -884,7 +884,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.RemoveAll(tempDir)
|
||||
defer func() { _ = os.RemoveAll(tempDir) }()
|
||||
|
||||
indexes := newIndexFiles(publishedStorage, basePath, tempDir, suffix, p.AcquireByHash, p.SkipBz2)
|
||||
|
||||
@@ -970,7 +970,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
||||
contentIndexesMap[key] = contentIndex
|
||||
}
|
||||
|
||||
contentIndex.Push(qualifiedName, contents, batch)
|
||||
_ = contentIndex.Push(qualifiedName, contents, batch)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1275,11 +1275,11 @@ func (collection *PublishedRepoCollection) CheckDuplicate(repo *PublishedRepo) *
|
||||
// Update stores updated information about repo in DB
|
||||
func (collection *PublishedRepoCollection) Update(repo *PublishedRepo) error {
|
||||
batch := collection.db.CreateBatch()
|
||||
batch.Put(repo.Key(), repo.Encode())
|
||||
_ = batch.Put(repo.Key(), repo.Encode())
|
||||
|
||||
if repo.SourceKind == SourceLocalRepo {
|
||||
for component, item := range repo.sourceItems {
|
||||
batch.Put(repo.RefKey(component), item.packageRefs.Encode())
|
||||
_ = batch.Put(repo.RefKey(component), item.packageRefs.Encode())
|
||||
}
|
||||
}
|
||||
return batch.Write()
|
||||
@@ -1324,7 +1324,7 @@ func (collection *PublishedRepoCollection) LoadShallow(repo *PublishedRepo, coll
|
||||
|
||||
// LoadComplete loads complete information on the sources of the repo *and* their packages
|
||||
func (collection *PublishedRepoCollection) LoadComplete(repo *PublishedRepo, collectionFactory *CollectionFactory) (err error) {
|
||||
collection.LoadShallow(repo, collectionFactory)
|
||||
_ = collection.LoadShallow(repo, collectionFactory)
|
||||
|
||||
if repo.SourceKind == SourceSnapshot {
|
||||
for _, item := range repo.sourceItems {
|
||||
@@ -1502,7 +1502,7 @@ func (collection *PublishedRepoCollection) listReferencedFilesByComponent(prefix
|
||||
return nil, err
|
||||
}
|
||||
|
||||
packageList.ForEach(func(p *Package) error {
|
||||
_ = packageList.ForEach(func(p *Package) error {
|
||||
poolDir, err := p.PoolDirectory()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1575,7 +1575,7 @@ func (collection *PublishedRepoCollection) CleanupPrefixComponentFiles(published
|
||||
return err
|
||||
}
|
||||
|
||||
packageList.ForEach(func(p *Package) error {
|
||||
_ = packageList.ForEach(func(p *Package) error {
|
||||
poolDir, err := p.PoolDirectory()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1709,10 +1709,10 @@ func (collection *PublishedRepoCollection) Remove(publishedStorageProvider aptly
|
||||
}
|
||||
|
||||
batch := collection.db.CreateBatch()
|
||||
batch.Delete(repo.Key())
|
||||
_ = batch.Delete(repo.Key())
|
||||
|
||||
for _, component := range repo.Components() {
|
||||
batch.Delete(repo.RefKey(component))
|
||||
_ = batch.Delete(repo.RefKey(component))
|
||||
}
|
||||
|
||||
return batch.Write()
|
||||
|
||||
@@ -19,13 +19,13 @@ func BenchmarkListReferencedFiles(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
defer func() { _ = os.RemoveAll(tmpDir) }()
|
||||
|
||||
db, err := goleveldb.NewOpenDB(tmpDir)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
defer func() { _ = db.Close() }()
|
||||
|
||||
factory := NewCollectionFactory(db)
|
||||
packageCollection := factory.PackageCollection()
|
||||
@@ -49,7 +49,7 @@ func BenchmarkListReferencedFiles(b *testing.B) {
|
||||
Filename: fmt.Sprintf("pkg-shared_%d.deb", pkgIndex),
|
||||
}})
|
||||
|
||||
packageCollection.UpdateInTransaction(p, transaction)
|
||||
_ = packageCollection.UpdateInTransaction(p, transaction)
|
||||
sharedRefs.Refs = append(sharedRefs.Refs, p.Key(""))
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ func BenchmarkListReferencedFiles(b *testing.B) {
|
||||
Filename: fmt.Sprintf("pkg%d_%d.deb", repoIndex, pkgIndex),
|
||||
}})
|
||||
|
||||
packageCollection.UpdateInTransaction(p, transaction)
|
||||
_ = packageCollection.UpdateInTransaction(p, transaction)
|
||||
refs.Refs = append(refs.Refs, p.Key(""))
|
||||
}
|
||||
|
||||
@@ -92,16 +92,16 @@ func BenchmarkListReferencedFiles(b *testing.B) {
|
||||
repo.DefaultDistribution = fmt.Sprintf("dist%d", repoIndex)
|
||||
repo.DefaultComponent = defaultComponent
|
||||
repo.UpdateRefList(refs.Merge(sharedRefs, false, true))
|
||||
repoCollection.Add(repo)
|
||||
_ = repoCollection.Add(repo)
|
||||
|
||||
publish, err := NewPublishedRepo("", "test", "", nil, []string{defaultComponent}, []interface{}{repo}, factory, false)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
publishCollection.Add(publish)
|
||||
_ = publishCollection.Add(publish)
|
||||
}
|
||||
|
||||
db.CompactDB()
|
||||
_ = db.CompactDB()
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
||||
+45
-46
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@@ -51,11 +50,11 @@ func (n *NullSigner) SetPassphrase(passphrase, passphraseFile string) {
|
||||
}
|
||||
|
||||
func (n *NullSigner) DetachedSign(source string, destination string) error {
|
||||
return ioutil.WriteFile(destination, []byte{}, 0644)
|
||||
return os.WriteFile(destination, []byte{}, 0644)
|
||||
}
|
||||
|
||||
func (n *NullSigner) ClearSign(source string, destination string) error {
|
||||
return ioutil.WriteFile(destination, []byte{}, 0644)
|
||||
return os.WriteFile(destination, []byte{}, 0644)
|
||||
}
|
||||
|
||||
type FakeStorageProvider struct {
|
||||
@@ -104,7 +103,7 @@ func (s *PublishedRepoSuite) SetUpTest(c *C) {
|
||||
s.cs = files.NewMockChecksumStorage()
|
||||
|
||||
tmpFilepath := filepath.Join(c.MkDir(), "file")
|
||||
c.Assert(ioutil.WriteFile(tmpFilepath, nil, 0777), IsNil)
|
||||
c.Assert(os.WriteFile(tmpFilepath, nil, 0777), IsNil)
|
||||
|
||||
var err error
|
||||
s.p1.Files()[0].PoolPath, err = s.packagePool.Import(tmpFilepath, s.p1.Files()[0].Filename, &s.p1.Files()[0].Checksums, false, s.cs)
|
||||
@@ -118,22 +117,22 @@ func (s *PublishedRepoSuite) SetUpTest(c *C) {
|
||||
|
||||
repo, _ := NewRemoteRepo("yandex", "http://mirror.yandex.ru/debian/", "squeeze", []string{"main"}, []string{}, false, false, false)
|
||||
repo.packageRefs = s.reflist
|
||||
s.factory.RemoteRepoCollection().Add(repo)
|
||||
_ = s.factory.RemoteRepoCollection().Add(repo)
|
||||
|
||||
s.localRepo = NewLocalRepo("local1", "comment1")
|
||||
s.localRepo.packageRefs = s.reflist
|
||||
s.factory.LocalRepoCollection().Add(s.localRepo)
|
||||
_ = s.factory.LocalRepoCollection().Add(s.localRepo)
|
||||
|
||||
s.snapshot, _ = NewSnapshotFromRepository("snap", repo)
|
||||
s.factory.SnapshotCollection().Add(s.snapshot)
|
||||
_ = s.factory.SnapshotCollection().Add(s.snapshot)
|
||||
|
||||
s.snapshot2, _ = NewSnapshotFromRepository("snap", repo)
|
||||
s.factory.SnapshotCollection().Add(s.snapshot2)
|
||||
_ = s.factory.SnapshotCollection().Add(s.snapshot2)
|
||||
|
||||
s.packageCollection = s.factory.PackageCollection()
|
||||
s.packageCollection.Update(s.p1)
|
||||
s.packageCollection.Update(s.p2)
|
||||
s.packageCollection.Update(s.p3)
|
||||
_ = s.packageCollection.Update(s.p1)
|
||||
_ = s.packageCollection.Update(s.p2)
|
||||
_ = s.packageCollection.Update(s.p3)
|
||||
|
||||
s.repo, _ = NewPublishedRepo("", "ppa", "squeeze", nil, []string{"main"}, []interface{}{s.snapshot}, s.factory, false)
|
||||
s.repo.SkipContents = true
|
||||
@@ -152,7 +151,7 @@ func (s *PublishedRepoSuite) SetUpTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *PublishedRepoSuite) TearDownTest(c *C) {
|
||||
s.db.Close()
|
||||
_ = s.db.Close()
|
||||
}
|
||||
|
||||
func (s *PublishedRepoSuite) TestNewPublishedRepo(c *C) {
|
||||
@@ -179,12 +178,12 @@ func (s *PublishedRepoSuite) TestNewPublishedRepo(c *C) {
|
||||
c.Check(s.repo3.RefList("main").Len(), Equals, 3)
|
||||
c.Check(s.repo3.RefList("contrib").Len(), Equals, 3)
|
||||
|
||||
c.Check(func() { NewPublishedRepo("", ".", "a", nil, nil, nil, s.factory, false) }, PanicMatches, "publish with empty sources")
|
||||
c.Check(func() { _, _ = NewPublishedRepo("", ".", "a", nil, nil, nil, s.factory, false) }, PanicMatches, "publish with empty sources")
|
||||
c.Check(func() {
|
||||
NewPublishedRepo("", ".", "a", nil, []string{"main"}, []interface{}{s.snapshot, s.snapshot2}, s.factory, false)
|
||||
_, _ = NewPublishedRepo("", ".", "a", nil, []string{"main"}, []interface{}{s.snapshot, s.snapshot2}, s.factory, false)
|
||||
}, PanicMatches, "sources and components should be equal in size")
|
||||
c.Check(func() {
|
||||
NewPublishedRepo("", ".", "a", nil, []string{"main", "contrib"}, []interface{}{s.localRepo, s.snapshot2}, s.factory, false)
|
||||
_, _ = NewPublishedRepo("", ".", "a", nil, []string{"main", "contrib"}, []interface{}{s.localRepo, s.snapshot2}, s.factory, false)
|
||||
}, PanicMatches, "interface conversion:.*")
|
||||
|
||||
_, err := NewPublishedRepo("", ".", "a", nil, []string{"main", "main"}, []interface{}{s.snapshot, s.snapshot2}, s.factory, false)
|
||||
@@ -337,7 +336,7 @@ func (s *PublishedRepoSuite) TestDistributionComponentGuessing(c *C) {
|
||||
|
||||
s.localRepo.DefaultDistribution = "precise"
|
||||
s.localRepo.DefaultComponent = "contrib"
|
||||
s.factory.LocalRepoCollection().Update(s.localRepo)
|
||||
_ = s.factory.LocalRepoCollection().Update(s.localRepo)
|
||||
|
||||
repo, err = NewPublishedRepo("", "ppa", "", nil, []string{""}, []interface{}{s.localRepo}, s.factory, false)
|
||||
c.Check(err, IsNil)
|
||||
@@ -526,8 +525,8 @@ func (s *PublishedRepoSuite) TestPublishedRepoRevision(c *C) {
|
||||
bytes, err := json.Marshal(revision)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
json_expected := `{"Sources":[{"Component":"main","Name":"local1"},{"Component":"test1","Name":"snap1"},{"Component":"test2","Name":"snap2"}]}`
|
||||
c.Assert(string(bytes), Equals, json_expected)
|
||||
jsonExpected := `{"Sources":[{"Component":"main","Name":"local1"},{"Component":"test1","Name":"snap1"},{"Component":"test2","Name":"snap2"}]}`
|
||||
c.Assert(string(bytes), Equals, jsonExpected)
|
||||
|
||||
c.Assert(s.repo2.DropRevision(), DeepEquals, revision)
|
||||
c.Assert(s.repo2.Revision, IsNil)
|
||||
@@ -564,11 +563,11 @@ func (s *PublishedRepoCollectionSuite) SetUpTest(c *C) {
|
||||
sort.Sort(snap2Refs)
|
||||
s.snap2 = NewSnapshotFromRefList("snap2", []*Snapshot{}, snap2Refs, "desc2")
|
||||
|
||||
s.snapshotCollection.Add(s.snap1)
|
||||
s.snapshotCollection.Add(s.snap2)
|
||||
_ = s.snapshotCollection.Add(s.snap1)
|
||||
_ = s.snapshotCollection.Add(s.snap2)
|
||||
|
||||
s.localRepo = NewLocalRepo("local1", "comment1")
|
||||
s.factory.LocalRepoCollection().Add(s.localRepo)
|
||||
_ = s.factory.LocalRepoCollection().Add(s.localRepo)
|
||||
|
||||
s.repo1, _ = NewPublishedRepo("", "ppa", "anaconda", []string{}, []string{"main"}, []interface{}{s.snap1}, s.factory, false)
|
||||
s.repo2, _ = NewPublishedRepo("", "", "anaconda", []string{}, []string{"main", "contrib"}, []interface{}{s.snap2, s.snap1}, s.factory, false)
|
||||
@@ -580,7 +579,7 @@ func (s *PublishedRepoCollectionSuite) SetUpTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *PublishedRepoCollectionSuite) TearDownTest(c *C) {
|
||||
s.db.Close()
|
||||
_ = s.db.Close()
|
||||
}
|
||||
|
||||
func (s *PublishedRepoCollectionSuite) TestAddByStoragePrefixDistribution(c *C) {
|
||||
@@ -677,7 +676,7 @@ func (s *PublishedRepoCollectionSuite) TestLoadPre0_6(c *C) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
encoder := codec.NewEncoder(&buf, &codec.MsgpackHandle{})
|
||||
encoder.Encode(&old)
|
||||
_ = encoder.Encode(&old)
|
||||
|
||||
c.Assert(s.db.Put(s.repo1.Key(), buf.Bytes()), IsNil)
|
||||
c.Assert(s.db.Put(s.repo1.RefKey(""), s.localRepo.RefList().Encode()), IsNil)
|
||||
@@ -695,7 +694,7 @@ func (s *PublishedRepoCollectionSuite) TestLoadPre0_6(c *C) {
|
||||
}
|
||||
|
||||
func (s *PublishedRepoCollectionSuite) TestForEachAndLen(c *C) {
|
||||
s.collection.Add(s.repo1)
|
||||
_ = s.collection.Add(s.repo1)
|
||||
|
||||
count := 0
|
||||
err := s.collection.ForEach(func(*PublishedRepo) error {
|
||||
@@ -755,7 +754,7 @@ func (s *PublishedRepoCollectionSuite) TestListReferencedFiles(c *C) {
|
||||
})
|
||||
|
||||
snap3 := NewSnapshotFromRefList("snap3", []*Snapshot{}, s.snap2.RefList(), "desc3")
|
||||
s.snapshotCollection.Add(snap3)
|
||||
_ = s.snapshotCollection.Add(snap3)
|
||||
|
||||
// Ensure that adding a second publish point with matching files doesn't give duplicate results.
|
||||
repo3, err := NewPublishedRepo("", "", "anaconda-2", []string{}, []string{"main"}, []interface{}{snap3}, s.factory, false)
|
||||
@@ -799,7 +798,7 @@ func (s *PublishedRepoRemoveSuite) SetUpTest(c *C) {
|
||||
|
||||
s.snap1 = NewSnapshotFromPackageList("snap1", []*Snapshot{}, NewPackageList(), "desc1")
|
||||
|
||||
s.snapshotCollection.Add(s.snap1)
|
||||
_ = s.snapshotCollection.Add(s.snap1)
|
||||
|
||||
s.repo1, _ = NewPublishedRepo("", "ppa", "anaconda", []string{}, []string{"main"}, []interface{}{s.snap1}, s.factory, false)
|
||||
s.repo2, _ = NewPublishedRepo("", "", "anaconda", []string{}, []string{"main"}, []interface{}{s.snap1}, s.factory, false)
|
||||
@@ -808,26 +807,26 @@ func (s *PublishedRepoRemoveSuite) SetUpTest(c *C) {
|
||||
s.repo5, _ = NewPublishedRepo("files:other", "ppa", "osminog", []string{}, []string{"contrib"}, []interface{}{s.snap1}, s.factory, false)
|
||||
|
||||
s.collection = s.factory.PublishedRepoCollection()
|
||||
s.collection.Add(s.repo1)
|
||||
s.collection.Add(s.repo2)
|
||||
s.collection.Add(s.repo3)
|
||||
s.collection.Add(s.repo4)
|
||||
s.collection.Add(s.repo5)
|
||||
_ = s.collection.Add(s.repo1)
|
||||
_ = s.collection.Add(s.repo2)
|
||||
_ = s.collection.Add(s.repo3)
|
||||
_ = s.collection.Add(s.repo4)
|
||||
_ = s.collection.Add(s.repo5)
|
||||
|
||||
s.root = c.MkDir()
|
||||
s.publishedStorage = files.NewPublishedStorage(s.root, "", "")
|
||||
s.publishedStorage.MkDir("ppa/dists/anaconda")
|
||||
s.publishedStorage.MkDir("ppa/dists/meduza")
|
||||
s.publishedStorage.MkDir("ppa/dists/osminog")
|
||||
s.publishedStorage.MkDir("ppa/pool/main")
|
||||
s.publishedStorage.MkDir("ppa/pool/contrib")
|
||||
s.publishedStorage.MkDir("dists/anaconda")
|
||||
s.publishedStorage.MkDir("pool/main")
|
||||
_ = s.publishedStorage.MkDir("ppa/dists/anaconda")
|
||||
_ = s.publishedStorage.MkDir("ppa/dists/meduza")
|
||||
_ = s.publishedStorage.MkDir("ppa/dists/osminog")
|
||||
_ = s.publishedStorage.MkDir("ppa/pool/main")
|
||||
_ = s.publishedStorage.MkDir("ppa/pool/contrib")
|
||||
_ = s.publishedStorage.MkDir("dists/anaconda")
|
||||
_ = s.publishedStorage.MkDir("pool/main")
|
||||
|
||||
s.root2 = c.MkDir()
|
||||
s.publishedStorage2 = files.NewPublishedStorage(s.root2, "", "")
|
||||
s.publishedStorage2.MkDir("ppa/dists/osminog")
|
||||
s.publishedStorage2.MkDir("ppa/pool/contrib")
|
||||
_ = s.publishedStorage2.MkDir("ppa/dists/osminog")
|
||||
_ = s.publishedStorage2.MkDir("ppa/pool/contrib")
|
||||
|
||||
s.provider = &FakeStorageProvider{map[string]aptly.PublishedStorage{
|
||||
"": s.publishedStorage,
|
||||
@@ -835,11 +834,11 @@ func (s *PublishedRepoRemoveSuite) SetUpTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *PublishedRepoRemoveSuite) TearDownTest(c *C) {
|
||||
s.db.Close()
|
||||
_ = s.db.Close()
|
||||
}
|
||||
|
||||
func (s *PublishedRepoRemoveSuite) TestRemoveFilesOnlyDist(c *C) {
|
||||
s.repo1.RemoveFiles(s.provider, false, []string{}, nil)
|
||||
_ = s.repo1.RemoveFiles(s.provider, false, []string{}, nil)
|
||||
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/anaconda"), Not(PathExists))
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/meduza"), PathExists)
|
||||
@@ -853,7 +852,7 @@ func (s *PublishedRepoRemoveSuite) TestRemoveFilesOnlyDist(c *C) {
|
||||
}
|
||||
|
||||
func (s *PublishedRepoRemoveSuite) TestRemoveFilesWithPool(c *C) {
|
||||
s.repo1.RemoveFiles(s.provider, false, []string{"main"}, nil)
|
||||
_ = s.repo1.RemoveFiles(s.provider, false, []string{"main"}, nil)
|
||||
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/anaconda"), Not(PathExists))
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/meduza"), PathExists)
|
||||
@@ -867,7 +866,7 @@ func (s *PublishedRepoRemoveSuite) TestRemoveFilesWithPool(c *C) {
|
||||
}
|
||||
|
||||
func (s *PublishedRepoRemoveSuite) TestRemoveFilesWithTwoPools(c *C) {
|
||||
s.repo1.RemoveFiles(s.provider, false, []string{"main", "contrib"}, nil)
|
||||
_ = s.repo1.RemoveFiles(s.provider, false, []string{"main", "contrib"}, nil)
|
||||
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/anaconda"), Not(PathExists))
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/meduza"), PathExists)
|
||||
@@ -881,7 +880,7 @@ func (s *PublishedRepoRemoveSuite) TestRemoveFilesWithTwoPools(c *C) {
|
||||
}
|
||||
|
||||
func (s *PublishedRepoRemoveSuite) TestRemoveFilesWithPrefix(c *C) {
|
||||
s.repo1.RemoveFiles(s.provider, true, []string{"main"}, nil)
|
||||
_ = s.repo1.RemoveFiles(s.provider, true, []string{"main"}, nil)
|
||||
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/anaconda"), Not(PathExists))
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/meduza"), Not(PathExists))
|
||||
@@ -895,7 +894,7 @@ func (s *PublishedRepoRemoveSuite) TestRemoveFilesWithPrefix(c *C) {
|
||||
}
|
||||
|
||||
func (s *PublishedRepoRemoveSuite) TestRemoveFilesWithPrefixRoot(c *C) {
|
||||
s.repo2.RemoveFiles(s.provider, true, []string{"main"}, nil)
|
||||
_ = s.repo2.RemoveFiles(s.provider, true, []string{"main"}, nil)
|
||||
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/anaconda"), PathExists)
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/meduza"), PathExists)
|
||||
|
||||
+2
-2
@@ -89,7 +89,7 @@ func (q *OrQuery) Fast(list PackageCatalog) bool {
|
||||
func (q *OrQuery) Query(list PackageCatalog) (result *PackageList) {
|
||||
if q.Fast(list) {
|
||||
result = q.L.Query(list)
|
||||
result.Append(q.R.Query(list))
|
||||
_ = result.Append(q.R.Query(list))
|
||||
} else {
|
||||
result = list.Scan(q)
|
||||
}
|
||||
@@ -245,7 +245,7 @@ func (q *DependencyQuery) Query(list PackageCatalog) (result *PackageList) {
|
||||
if q.Fast(list) {
|
||||
result = NewPackageList()
|
||||
for _, pkg := range list.Search(q.Dep, true, true) {
|
||||
result.Add(pkg)
|
||||
_ = result.Add(pkg)
|
||||
}
|
||||
} else {
|
||||
result = list.Scan(q)
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ func (l *PackageRefList) Swap(i, j int) {
|
||||
l.Refs[i], l.Refs[j] = l.Refs[j], l.Refs[i]
|
||||
}
|
||||
|
||||
// Compare compares two refs in lexographical order
|
||||
// Less compares two refs in lexographical order
|
||||
func (l *PackageRefList) Less(i, j int) bool {
|
||||
return bytes.Compare(l.Refs[i], l.Refs[j]) < 0
|
||||
}
|
||||
@@ -64,7 +64,7 @@ func (l *PackageRefList) Encode() []byte {
|
||||
var buf bytes.Buffer
|
||||
|
||||
encoder := codec.NewEncoder(&buf, &codec.MsgpackHandle{})
|
||||
encoder.Encode(l)
|
||||
_ = encoder.Encode(l)
|
||||
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
@@ -42,6 +42,6 @@ func BenchmarkReflistDecode(b *testing.B) {
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
(&PackageRefList{}).Decode(data)
|
||||
_ = (&PackageRefList{}).Decode(data)
|
||||
}
|
||||
}
|
||||
|
||||
+59
-59
@@ -46,21 +46,21 @@ func (s *PackageRefListSuite) SetUpTest(c *C) {
|
||||
func (s *PackageRefListSuite) TestNewPackageListFromRefList(c *C) {
|
||||
db, _ := goleveldb.NewOpenDB(c.MkDir())
|
||||
coll := NewPackageCollection(db)
|
||||
coll.Update(s.p1)
|
||||
coll.Update(s.p3)
|
||||
_ = coll.Update(s.p1)
|
||||
_ = coll.Update(s.p3)
|
||||
|
||||
s.list.Add(s.p1)
|
||||
s.list.Add(s.p3)
|
||||
s.list.Add(s.p5)
|
||||
s.list.Add(s.p6)
|
||||
_ = s.list.Add(s.p1)
|
||||
_ = s.list.Add(s.p3)
|
||||
_ = s.list.Add(s.p5)
|
||||
_ = s.list.Add(s.p6)
|
||||
|
||||
reflist := NewPackageRefListFromPackageList(s.list)
|
||||
|
||||
_, err := NewPackageListFromRefList(reflist, coll, nil)
|
||||
c.Assert(err, ErrorMatches, "unable to load package with key.*")
|
||||
|
||||
coll.Update(s.p5)
|
||||
coll.Update(s.p6)
|
||||
_ = coll.Update(s.p5)
|
||||
_ = coll.Update(s.p6)
|
||||
|
||||
list, err := NewPackageListFromRefList(reflist, coll, nil)
|
||||
c.Assert(err, IsNil)
|
||||
@@ -73,10 +73,10 @@ func (s *PackageRefListSuite) TestNewPackageListFromRefList(c *C) {
|
||||
}
|
||||
|
||||
func (s *PackageRefListSuite) TestNewPackageRefList(c *C) {
|
||||
s.list.Add(s.p1)
|
||||
s.list.Add(s.p3)
|
||||
s.list.Add(s.p5)
|
||||
s.list.Add(s.p6)
|
||||
_ = s.list.Add(s.p1)
|
||||
_ = s.list.Add(s.p3)
|
||||
_ = s.list.Add(s.p5)
|
||||
_ = s.list.Add(s.p6)
|
||||
|
||||
reflist := NewPackageRefListFromPackageList(s.list)
|
||||
c.Assert(reflist.Len(), Equals, 4)
|
||||
@@ -90,10 +90,10 @@ func (s *PackageRefListSuite) TestNewPackageRefList(c *C) {
|
||||
}
|
||||
|
||||
func (s *PackageRefListSuite) TestPackageRefListEncodeDecode(c *C) {
|
||||
s.list.Add(s.p1)
|
||||
s.list.Add(s.p3)
|
||||
s.list.Add(s.p5)
|
||||
s.list.Add(s.p6)
|
||||
_ = s.list.Add(s.p1)
|
||||
_ = s.list.Add(s.p3)
|
||||
_ = s.list.Add(s.p5)
|
||||
_ = s.list.Add(s.p6)
|
||||
|
||||
reflist := NewPackageRefListFromPackageList(s.list)
|
||||
|
||||
@@ -105,10 +105,10 @@ func (s *PackageRefListSuite) TestPackageRefListEncodeDecode(c *C) {
|
||||
}
|
||||
|
||||
func (s *PackageRefListSuite) TestPackageRefListForeach(c *C) {
|
||||
s.list.Add(s.p1)
|
||||
s.list.Add(s.p3)
|
||||
s.list.Add(s.p5)
|
||||
s.list.Add(s.p6)
|
||||
_ = s.list.Add(s.p1)
|
||||
_ = s.list.Add(s.p3)
|
||||
_ = s.list.Add(s.p5)
|
||||
_ = s.list.Add(s.p6)
|
||||
|
||||
reflist := NewPackageRefListFromPackageList(s.list)
|
||||
|
||||
@@ -131,9 +131,9 @@ func (s *PackageRefListSuite) TestPackageRefListForeach(c *C) {
|
||||
}
|
||||
|
||||
func (s *PackageRefListSuite) TestHas(c *C) {
|
||||
s.list.Add(s.p1)
|
||||
s.list.Add(s.p3)
|
||||
s.list.Add(s.p5)
|
||||
_ = s.list.Add(s.p1)
|
||||
_ = s.list.Add(s.p3)
|
||||
_ = s.list.Add(s.p5)
|
||||
reflist := NewPackageRefListFromPackageList(s.list)
|
||||
|
||||
c.Check(reflist.Has(s.p1), Equals, true)
|
||||
@@ -180,21 +180,21 @@ func (s *PackageRefListSuite) TestDiff(c *C) {
|
||||
}
|
||||
|
||||
for _, p := range packages {
|
||||
coll.Update(p)
|
||||
_ = coll.Update(p)
|
||||
}
|
||||
|
||||
listA := NewPackageList()
|
||||
listA.Add(packages[0])
|
||||
listA.Add(packages[1])
|
||||
listA.Add(packages[2])
|
||||
listA.Add(packages[3])
|
||||
listA.Add(packages[6])
|
||||
_ = listA.Add(packages[0])
|
||||
_ = listA.Add(packages[1])
|
||||
_ = listA.Add(packages[2])
|
||||
_ = listA.Add(packages[3])
|
||||
_ = listA.Add(packages[6])
|
||||
|
||||
listB := NewPackageList()
|
||||
listB.Add(packages[0])
|
||||
listB.Add(packages[2])
|
||||
listB.Add(packages[4])
|
||||
listB.Add(packages[5])
|
||||
_ = listB.Add(packages[0])
|
||||
_ = listB.Add(packages[2])
|
||||
_ = listB.Add(packages[4])
|
||||
_ = listB.Add(packages[5])
|
||||
|
||||
reflistA := NewPackageRefListFromPackageList(listA)
|
||||
reflistB := NewPackageRefListFromPackageList(listB)
|
||||
@@ -248,15 +248,15 @@ func (s *PackageRefListSuite) TestDiffCompactsAtEnd(c *C) {
|
||||
}
|
||||
|
||||
for _, p := range packages {
|
||||
coll.Update(p)
|
||||
_ = coll.Update(p)
|
||||
}
|
||||
|
||||
listA := NewPackageList()
|
||||
listA.Add(packages[0])
|
||||
_ = listA.Add(packages[0])
|
||||
|
||||
listB := NewPackageList()
|
||||
listB.Add(packages[1])
|
||||
listB.Add(packages[2])
|
||||
_ = listB.Add(packages[1])
|
||||
_ = listB.Add(packages[2])
|
||||
|
||||
reflistA := NewPackageRefListFromPackageList(listA)
|
||||
reflistB := NewPackageRefListFromPackageList(listB)
|
||||
@@ -291,27 +291,27 @@ func (s *PackageRefListSuite) TestMerge(c *C) {
|
||||
|
||||
for _, p := range packages {
|
||||
p.V06Plus = true
|
||||
coll.Update(p)
|
||||
_ = coll.Update(p)
|
||||
}
|
||||
|
||||
listA := NewPackageList()
|
||||
listA.Add(packages[0])
|
||||
listA.Add(packages[1])
|
||||
listA.Add(packages[2])
|
||||
listA.Add(packages[3])
|
||||
listA.Add(packages[7])
|
||||
_ = listA.Add(packages[0])
|
||||
_ = listA.Add(packages[1])
|
||||
_ = listA.Add(packages[2])
|
||||
_ = listA.Add(packages[3])
|
||||
_ = listA.Add(packages[7])
|
||||
|
||||
listB := NewPackageList()
|
||||
listB.Add(packages[0])
|
||||
listB.Add(packages[2])
|
||||
listB.Add(packages[4])
|
||||
listB.Add(packages[5])
|
||||
listB.Add(packages[6])
|
||||
_ = listB.Add(packages[0])
|
||||
_ = listB.Add(packages[2])
|
||||
_ = listB.Add(packages[4])
|
||||
_ = listB.Add(packages[5])
|
||||
_ = listB.Add(packages[6])
|
||||
|
||||
listC := NewPackageList()
|
||||
listC.Add(packages[0])
|
||||
listC.Add(packages[8])
|
||||
listC.Add(packages[9])
|
||||
_ = listC.Add(packages[0])
|
||||
_ = listC.Add(packages[8])
|
||||
_ = listC.Add(packages[9])
|
||||
|
||||
reflistA := NewPackageRefListFromPackageList(listA)
|
||||
reflistB := NewPackageRefListFromPackageList(listB)
|
||||
@@ -372,14 +372,14 @@ func (s *PackageRefListSuite) TestFilterLatestRefs(c *C) {
|
||||
}
|
||||
|
||||
rl := NewPackageList()
|
||||
rl.Add(packages[0])
|
||||
rl.Add(packages[1])
|
||||
rl.Add(packages[2])
|
||||
rl.Add(packages[3])
|
||||
rl.Add(packages[4])
|
||||
rl.Add(packages[5])
|
||||
rl.Add(packages[6])
|
||||
rl.Add(packages[7])
|
||||
_ = rl.Add(packages[0])
|
||||
_ = rl.Add(packages[1])
|
||||
_ = rl.Add(packages[2])
|
||||
_ = rl.Add(packages[3])
|
||||
_ = rl.Add(packages[4])
|
||||
_ = rl.Add(packages[5])
|
||||
_ = rl.Add(packages[6])
|
||||
_ = rl.Add(packages[7])
|
||||
|
||||
result := NewPackageRefListFromPackageList(rl)
|
||||
result.FilterLatestRefs()
|
||||
|
||||
+11
-11
@@ -120,7 +120,7 @@ func NewRemoteRepo(name string, archiveRoot string, distribution string, compone
|
||||
// SetArchiveRoot of remote repo
|
||||
func (repo *RemoteRepo) SetArchiveRoot(archiveRoot string) {
|
||||
repo.ArchiveRoot = archiveRoot
|
||||
repo.prepare()
|
||||
_ = repo.prepare()
|
||||
}
|
||||
|
||||
func (repo *RemoteRepo) prepare() error {
|
||||
@@ -302,14 +302,14 @@ func (repo *RemoteRepo) Fetch(d aptly.Downloader, verifier pgp.Verifier, ignoreS
|
||||
if err != nil {
|
||||
goto splitsignature
|
||||
}
|
||||
defer inrelease.Close()
|
||||
defer func() { _ = inrelease.Close() }()
|
||||
|
||||
_, err = verifier.VerifyClearsigned(inrelease, true)
|
||||
if err != nil {
|
||||
goto splitsignature
|
||||
}
|
||||
|
||||
inrelease.Seek(0, 0)
|
||||
_, _ = inrelease.Seek(0, 0)
|
||||
|
||||
release, err = verifier.ExtractClearsigned(inrelease)
|
||||
if err != nil {
|
||||
@@ -342,7 +342,7 @@ func (repo *RemoteRepo) Fetch(d aptly.Downloader, verifier pgp.Verifier, ignoreS
|
||||
}
|
||||
ok:
|
||||
|
||||
defer release.Close()
|
||||
defer func() { _ = release.Close() }()
|
||||
|
||||
sreader := NewControlFileReader(release, true, false)
|
||||
stanza, err := sreader.ReadStanza()
|
||||
@@ -528,7 +528,7 @@ func (repo *RemoteRepo) DownloadPackageIndexes(progress aptly.Progress, d aptly.
|
||||
return err
|
||||
}
|
||||
}
|
||||
defer packagesFile.Close()
|
||||
defer func() { _ = packagesFile.Close() }()
|
||||
|
||||
if progress != nil {
|
||||
stat, _ := packagesFile.Stat()
|
||||
@@ -705,7 +705,7 @@ func (repo *RemoteRepo) Encode() []byte {
|
||||
var buf bytes.Buffer
|
||||
|
||||
encoder := codec.NewEncoder(&buf, &codec.MsgpackHandle{})
|
||||
encoder.Encode(repo)
|
||||
_ = encoder.Encode(repo)
|
||||
|
||||
return buf.Bytes()
|
||||
}
|
||||
@@ -804,7 +804,7 @@ func (collection *RemoteRepoCollection) search(filter func(*RemoteRepo) bool, un
|
||||
return result
|
||||
}
|
||||
|
||||
collection.db.ProcessByPrefix([]byte("R"), func(_, blob []byte) error {
|
||||
_ = collection.db.ProcessByPrefix([]byte("R"), func(_, blob []byte) error {
|
||||
r := &RemoteRepo{}
|
||||
if err := r.Decode(blob); err != nil {
|
||||
log.Printf("Error decoding remote repo: %s\n", err)
|
||||
@@ -848,9 +848,9 @@ func (collection *RemoteRepoCollection) Add(repo *RemoteRepo) error {
|
||||
func (collection *RemoteRepoCollection) Update(repo *RemoteRepo) error {
|
||||
batch := collection.db.CreateBatch()
|
||||
|
||||
batch.Put(repo.Key(), repo.Encode())
|
||||
_ = batch.Put(repo.Key(), repo.Encode())
|
||||
if repo.packageRefs != nil {
|
||||
batch.Put(repo.RefKey(), repo.packageRefs.Encode())
|
||||
_ = batch.Put(repo.RefKey(), repo.packageRefs.Encode())
|
||||
}
|
||||
return batch.Write()
|
||||
}
|
||||
@@ -936,7 +936,7 @@ func (collection *RemoteRepoCollection) Drop(repo *RemoteRepo) error {
|
||||
delete(collection.cache, repo.UUID)
|
||||
|
||||
batch := collection.db.CreateBatch()
|
||||
batch.Delete(repo.Key())
|
||||
batch.Delete(repo.RefKey())
|
||||
_ = batch.Delete(repo.Key())
|
||||
_ = batch.Delete(repo.RefKey())
|
||||
return batch.Write()
|
||||
}
|
||||
|
||||
+24
-24
@@ -38,9 +38,9 @@ func (n *NullVerifier) VerifyClearsigned(clearsigned io.Reader, hint bool) (*pgp
|
||||
|
||||
func (n *NullVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error) {
|
||||
text, _ = os.CreateTemp("", "aptly-test")
|
||||
io.Copy(text, clearsigned)
|
||||
text.Seek(0, 0)
|
||||
os.Remove(text.Name())
|
||||
_, _ = io.Copy(text, clearsigned)
|
||||
_, _ = text.Seek(0, 0)
|
||||
_ = os.Remove(text.Name())
|
||||
|
||||
return
|
||||
}
|
||||
@@ -68,9 +68,9 @@ func (s *PackageListMixinSuite) SetUpPackages() {
|
||||
stanza["Filename"] = "pool/contrib/l/lonely-strangers/lonely-strangers_7.40-2_i386.deb"
|
||||
s.p3 = NewPackageFromControlFile(stanza)
|
||||
|
||||
s.list.Add(s.p1)
|
||||
s.list.Add(s.p2)
|
||||
s.list.Add(s.p3)
|
||||
_ = s.list.Add(s.p1)
|
||||
_ = s.list.Add(s.p2)
|
||||
_ = s.list.Add(s.p3)
|
||||
|
||||
s.reflist = NewPackageRefListFromPackageList(s.list)
|
||||
}
|
||||
@@ -104,7 +104,7 @@ func (s *RemoteRepoSuite) SetUpTest(c *C) {
|
||||
|
||||
func (s *RemoteRepoSuite) TearDownTest(c *C) {
|
||||
s.progress.Shutdown()
|
||||
s.db.Close()
|
||||
_ = s.db.Close()
|
||||
}
|
||||
|
||||
func (s *RemoteRepoSuite) TestInvalidURL(c *C) {
|
||||
@@ -287,7 +287,7 @@ func (s *RemoteRepoSuite) TestDownload(c *C) {
|
||||
c.Check(queue, HasLen, 1)
|
||||
c.Check(queue[0].File.DownloadURL(), Equals, "pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb")
|
||||
|
||||
s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
_ = s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
c.Assert(s.repo.packageRefs, NotNil)
|
||||
|
||||
pkg, err := s.collectionFactory.PackageCollection().ByKey(s.repo.packageRefs.Refs[0])
|
||||
@@ -313,7 +313,7 @@ func (s *RemoteRepoSuite) TestDownload(c *C) {
|
||||
c.Check(size, Equals, int64(0))
|
||||
c.Check(queue, HasLen, 0)
|
||||
|
||||
s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
_ = s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
c.Assert(s.repo.packageRefs, NotNil)
|
||||
|
||||
// Next call must return the download list without option "skip-existing-packages"
|
||||
@@ -335,7 +335,7 @@ func (s *RemoteRepoSuite) TestDownload(c *C) {
|
||||
c.Check(queue, HasLen, 1)
|
||||
c.Check(queue[0].File.DownloadURL(), Equals, "pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb")
|
||||
|
||||
s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
_ = s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
c.Assert(s.repo.packageRefs, NotNil)
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ func (s *RemoteRepoSuite) TestDownloadWithInstaller(c *C) {
|
||||
c.Check(q[0], Equals, "dists/squeeze/main/installer-i386/current/images/MANIFEST")
|
||||
c.Check(q[1], Equals, "pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb")
|
||||
|
||||
s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
_ = s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
c.Assert(s.repo.packageRefs, NotNil)
|
||||
|
||||
pkg, err := s.collectionFactory.PackageCollection().ByKey(s.repo.packageRefs.Refs[0])
|
||||
@@ -415,7 +415,7 @@ func (s *RemoteRepoSuite) TestDownloadWithSources(c *C) {
|
||||
c.Check(q[2], Equals, "pool/main/a/access-modifier-checker/access-modifier-checker_1.0.orig.tar.gz")
|
||||
c.Check(q[0], Equals, "pool/main/a/access-modifier-checker/access-modifier-checker_1.0-4.debian.tar.gz")
|
||||
|
||||
s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
_ = s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
c.Assert(s.repo.packageRefs, NotNil)
|
||||
|
||||
pkg, err := s.collectionFactory.PackageCollection().ByKey(s.repo.packageRefs.Refs[0])
|
||||
@@ -449,7 +449,7 @@ func (s *RemoteRepoSuite) TestDownloadWithSources(c *C) {
|
||||
c.Check(size, Equals, int64(0))
|
||||
c.Check(queue, HasLen, 0)
|
||||
|
||||
s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
_ = s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
c.Assert(s.repo.packageRefs, NotNil)
|
||||
|
||||
// Next call must return the download list without option "skip-existing-packages"
|
||||
@@ -474,7 +474,7 @@ func (s *RemoteRepoSuite) TestDownloadWithSources(c *C) {
|
||||
c.Check(size, Equals, int64(15))
|
||||
c.Check(queue, HasLen, 4)
|
||||
|
||||
s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
_ = s.repo.FinalizeDownload(s.collectionFactory, nil)
|
||||
c.Assert(s.repo.packageRefs, NotNil)
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ func (s *RemoteRepoSuite) TestDownloadFlat(c *C) {
|
||||
c.Check(queue, HasLen, 1)
|
||||
c.Check(queue[0].File.DownloadURL(), Equals, "pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb")
|
||||
|
||||
s.flat.FinalizeDownload(s.collectionFactory, nil)
|
||||
_ = s.flat.FinalizeDownload(s.collectionFactory, nil)
|
||||
c.Assert(s.flat.packageRefs, NotNil)
|
||||
|
||||
pkg, err := s.collectionFactory.PackageCollection().ByKey(s.flat.packageRefs.Refs[0])
|
||||
@@ -526,7 +526,7 @@ func (s *RemoteRepoSuite) TestDownloadFlat(c *C) {
|
||||
c.Check(size, Equals, int64(0))
|
||||
c.Check(queue, HasLen, 0)
|
||||
|
||||
s.flat.FinalizeDownload(s.collectionFactory, nil)
|
||||
_ = s.flat.FinalizeDownload(s.collectionFactory, nil)
|
||||
c.Assert(s.flat.packageRefs, NotNil)
|
||||
|
||||
// Next call must return the download list without option "skip-existing-packages"
|
||||
@@ -549,7 +549,7 @@ func (s *RemoteRepoSuite) TestDownloadFlat(c *C) {
|
||||
c.Check(queue, HasLen, 1)
|
||||
c.Check(queue[0].File.DownloadURL(), Equals, "pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb")
|
||||
|
||||
s.flat.FinalizeDownload(s.collectionFactory, nil)
|
||||
_ = s.flat.FinalizeDownload(s.collectionFactory, nil)
|
||||
c.Assert(s.flat.packageRefs, NotNil)
|
||||
}
|
||||
|
||||
@@ -589,7 +589,7 @@ func (s *RemoteRepoSuite) TestDownloadWithSourcesFlat(c *C) {
|
||||
c.Check(q[2], Equals, "pool/main/a/access-modifier-checker/access-modifier-checker_1.0.orig.tar.gz")
|
||||
c.Check(q[0], Equals, "pool/main/a/access-modifier-checker/access-modifier-checker_1.0-4.debian.tar.gz")
|
||||
|
||||
s.flat.FinalizeDownload(s.collectionFactory, nil)
|
||||
_ = s.flat.FinalizeDownload(s.collectionFactory, nil)
|
||||
c.Assert(s.flat.packageRefs, NotNil)
|
||||
|
||||
pkg, err := s.collectionFactory.PackageCollection().ByKey(s.flat.packageRefs.Refs[0])
|
||||
@@ -625,7 +625,7 @@ func (s *RemoteRepoSuite) TestDownloadWithSourcesFlat(c *C) {
|
||||
c.Check(size, Equals, int64(0))
|
||||
c.Check(queue, HasLen, 0)
|
||||
|
||||
s.flat.FinalizeDownload(s.collectionFactory, nil)
|
||||
_ = s.flat.FinalizeDownload(s.collectionFactory, nil)
|
||||
c.Assert(s.flat.packageRefs, NotNil)
|
||||
|
||||
// Next call must return the download list without option "skip-existing-packages"
|
||||
@@ -651,7 +651,7 @@ func (s *RemoteRepoSuite) TestDownloadWithSourcesFlat(c *C) {
|
||||
c.Check(size, Equals, int64(15))
|
||||
c.Check(queue, HasLen, 4)
|
||||
|
||||
s.flat.FinalizeDownload(s.collectionFactory, nil)
|
||||
_ = s.flat.FinalizeDownload(s.collectionFactory, nil)
|
||||
c.Assert(s.flat.packageRefs, NotNil)
|
||||
}
|
||||
|
||||
@@ -670,7 +670,7 @@ func (s *RemoteRepoCollectionSuite) SetUpTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *RemoteRepoCollectionSuite) TearDownTest(c *C) {
|
||||
s.db.Close()
|
||||
_ = s.db.Close()
|
||||
}
|
||||
|
||||
func (s *RemoteRepoCollectionSuite) TestAddByName(c *C) {
|
||||
@@ -731,7 +731,7 @@ func (s *RemoteRepoCollectionSuite) TestUpdateLoadComplete(c *C) {
|
||||
|
||||
func (s *RemoteRepoCollectionSuite) TestForEachAndLen(c *C) {
|
||||
repo, _ := NewRemoteRepo("yandex", "http://mirror.yandex.ru/debian/", "squeeze", []string{"main"}, []string{}, false, false, false)
|
||||
s.collection.Add(repo)
|
||||
_ = s.collection.Add(repo)
|
||||
|
||||
count := 0
|
||||
err := s.collection.ForEach(func(*RemoteRepo) error {
|
||||
@@ -753,10 +753,10 @@ func (s *RemoteRepoCollectionSuite) TestForEachAndLen(c *C) {
|
||||
|
||||
func (s *RemoteRepoCollectionSuite) TestDrop(c *C) {
|
||||
repo1, _ := NewRemoteRepo("yandex", "http://mirror.yandex.ru/debian/", "squeeze", []string{"main"}, []string{}, false, false, false)
|
||||
s.collection.Add(repo1)
|
||||
_ = s.collection.Add(repo1)
|
||||
|
||||
repo2, _ := NewRemoteRepo("tyndex", "http://mirror.yandex.ru/debian/", "wheezy", []string{"main"}, []string{}, false, false, false)
|
||||
s.collection.Add(repo2)
|
||||
_ = s.collection.Add(repo2)
|
||||
|
||||
r1, _ := s.collection.ByUUID(repo1.UUID)
|
||||
c.Check(r1, Equals, repo1)
|
||||
|
||||
+6
-6
@@ -142,7 +142,7 @@ func (s *Snapshot) Encode() []byte {
|
||||
var buf bytes.Buffer
|
||||
|
||||
encoder := codec.NewEncoder(&buf, &codec.MsgpackHandle{})
|
||||
encoder.Encode(s)
|
||||
_ = encoder.Encode(s)
|
||||
|
||||
return buf.Bytes()
|
||||
}
|
||||
@@ -228,9 +228,9 @@ func (collection *SnapshotCollection) Add(snapshot *Snapshot) error {
|
||||
func (collection *SnapshotCollection) Update(snapshot *Snapshot) error {
|
||||
batch := collection.db.CreateBatch()
|
||||
|
||||
batch.Put(snapshot.Key(), snapshot.Encode())
|
||||
_ = batch.Put(snapshot.Key(), snapshot.Encode())
|
||||
if snapshot.packageRefs != nil {
|
||||
batch.Put(snapshot.RefKey(), snapshot.packageRefs.Encode())
|
||||
_ = batch.Put(snapshot.RefKey(), snapshot.packageRefs.Encode())
|
||||
}
|
||||
|
||||
return batch.Write()
|
||||
@@ -259,7 +259,7 @@ func (collection *SnapshotCollection) search(filter func(*Snapshot) bool, unique
|
||||
return result
|
||||
}
|
||||
|
||||
collection.db.ProcessByPrefix([]byte("S"), func(_, blob []byte) error {
|
||||
_ = collection.db.ProcessByPrefix([]byte("S"), func(_, blob []byte) error {
|
||||
s := &Snapshot{}
|
||||
if err := s.Decode(blob); err != nil {
|
||||
log.Printf("Error decoding snapshot: %s\n", err)
|
||||
@@ -400,8 +400,8 @@ func (collection *SnapshotCollection) Drop(snapshot *Snapshot) error {
|
||||
delete(collection.cache, snapshot.UUID)
|
||||
|
||||
batch := collection.db.CreateBatch()
|
||||
batch.Delete(snapshot.Key())
|
||||
batch.Delete(snapshot.RefKey())
|
||||
_ = batch.Delete(snapshot.Key())
|
||||
_ = batch.Delete(snapshot.RefKey())
|
||||
return batch.Write()
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ func BenchmarkSnapshotCollectionForEach(b *testing.B) {
|
||||
const count = 1024
|
||||
|
||||
tmpDir := os.TempDir()
|
||||
defer os.RemoveAll(tmpDir)
|
||||
defer func() { _ = os.RemoveAll(tmpDir) }()
|
||||
|
||||
db, _ := goleveldb.NewOpenDB(tmpDir)
|
||||
defer db.Close()
|
||||
defer func() { _ = db.Close() }()
|
||||
|
||||
collection := NewSnapshotCollection(db)
|
||||
|
||||
@@ -31,7 +31,8 @@ func BenchmarkSnapshotCollectionForEach(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
collection = NewSnapshotCollection(db)
|
||||
|
||||
collection.ForEach(func(s *Snapshot) error {
|
||||
|
||||
_ = collection.ForEach(func(s *Snapshot) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -41,10 +42,10 @@ func BenchmarkSnapshotCollectionByUUID(b *testing.B) {
|
||||
const count = 1024
|
||||
|
||||
tmpDir := os.TempDir()
|
||||
defer os.RemoveAll(tmpDir)
|
||||
defer func() { _ = os.RemoveAll(tmpDir) }()
|
||||
|
||||
db, _ := goleveldb.NewOpenDB(tmpDir)
|
||||
defer db.Close()
|
||||
defer func() { _ = db.Close() }()
|
||||
|
||||
collection := NewSnapshotCollection(db)
|
||||
|
||||
@@ -72,10 +73,10 @@ func BenchmarkSnapshotCollectionByName(b *testing.B) {
|
||||
const count = 1024
|
||||
|
||||
tmpDir := os.TempDir()
|
||||
defer os.RemoveAll(tmpDir)
|
||||
defer func() { _ = os.RemoveAll(tmpDir) }()
|
||||
|
||||
db, _ := goleveldb.NewOpenDB(tmpDir)
|
||||
defer db.Close()
|
||||
defer func() { _ = db.Close() }()
|
||||
|
||||
collection := NewSnapshotCollection(db)
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ func (s *SnapshotCollectionSuite) SetUpTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *SnapshotCollectionSuite) TearDownTest(c *C) {
|
||||
s.db.Close()
|
||||
_ = s.db.Close()
|
||||
}
|
||||
|
||||
func (s *SnapshotCollectionSuite) TestAddByNameByUUID(c *C) {
|
||||
@@ -179,8 +179,8 @@ func (s *SnapshotCollectionSuite) TestUpdateLoadComplete(c *C) {
|
||||
}
|
||||
|
||||
func (s *SnapshotCollectionSuite) TestForEachAndLen(c *C) {
|
||||
s.collection.Add(s.snapshot1)
|
||||
s.collection.Add(s.snapshot2)
|
||||
_ = s.collection.Add(s.snapshot1)
|
||||
_ = s.collection.Add(s.snapshot2)
|
||||
|
||||
count := 0
|
||||
err := s.collection.ForEach(func(*Snapshot) error {
|
||||
@@ -200,10 +200,10 @@ func (s *SnapshotCollectionSuite) TestForEachAndLen(c *C) {
|
||||
}
|
||||
|
||||
func (s *SnapshotCollectionSuite) TestForEachSorted(c *C) {
|
||||
s.collection.Add(s.snapshot2)
|
||||
s.collection.Add(s.snapshot1)
|
||||
s.collection.Add(s.snapshot4)
|
||||
s.collection.Add(s.snapshot3)
|
||||
_ = s.collection.Add(s.snapshot2)
|
||||
_ = s.collection.Add(s.snapshot1)
|
||||
_ = s.collection.Add(s.snapshot4)
|
||||
_ = s.collection.Add(s.snapshot3)
|
||||
|
||||
names := []string{}
|
||||
|
||||
@@ -263,8 +263,8 @@ func (s *SnapshotCollectionSuite) TestFindSnapshotSource(c *C) {
|
||||
}
|
||||
|
||||
func (s *SnapshotCollectionSuite) TestDrop(c *C) {
|
||||
s.collection.Add(s.snapshot1)
|
||||
s.collection.Add(s.snapshot2)
|
||||
_ = s.collection.Add(s.snapshot1)
|
||||
_ = s.collection.Add(s.snapshot2)
|
||||
|
||||
snap, _ := s.collection.ByUUID(s.snapshot1.UUID)
|
||||
c.Check(snap, Equals, s.snapshot1)
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ func NewUploadersFromFile(path string) (*Uploaders, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error loading uploaders file: %s", err)
|
||||
}
|
||||
defer f.Close()
|
||||
defer func() { _ = f.Close() }()
|
||||
|
||||
err = json.NewDecoder(JsonConfigReader.New(f)).Decode(&uploaders)
|
||||
if err != nil {
|
||||
|
||||
+1
-5
@@ -50,11 +50,7 @@ func compareLexicographic(s1, s2 string) int {
|
||||
i := 0
|
||||
l1, l2 := len(s1), len(s2)
|
||||
|
||||
for {
|
||||
if i == l1 && i == l2 {
|
||||
// s1 equal to s2
|
||||
break
|
||||
}
|
||||
for !(i == l1 && i == l2) { // break if s1 equal to s2
|
||||
|
||||
if i == l2 {
|
||||
// s1 is longer than s2
|
||||
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
aptly (1.6.0+ds1-1) unstable; urgency=medium
|
||||
|
||||
- aptly-api: configuration file is now /etc/aptly.conf, and `rootDir`
|
||||
defaults to `~/.aptly`
|
||||
|
||||
- aptly-api: default port is 8080, as declared in
|
||||
`/etc/default/aptly-api`
|
||||
|
||||
- aptly: swagger support is disabled, but will be re-enabled after the
|
||||
corresponding golang packages make it to unstable
|
||||
|
||||
- aptly: default format is yaml, but the old format is still supported
|
||||
for now
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Sun, 29 Dec 2024 08:46:07 +0100
|
||||
|
||||
aptly (1.3.0+ds1-2.2) unstable; urgency=medium
|
||||
|
||||
This version tries to fix the database backwards compatibility,
|
||||
so you don't need to rebuild the database if you upgrade from
|
||||
aptly <= 1.3.0-6.
|
||||
|
||||
However some fields are missing, like created time of a snapshot.
|
||||
|
||||
-- Shengjing Zhu <zhsj@debian.org> Sat, 13 Apr 2019 23:26:39 +0800
|
||||
|
||||
aptly (1.3.0+ds1-2) unstable; urgency=medium
|
||||
|
||||
* The database created by aptly <= 1.3.0-6 is not compatible
|
||||
with greater versions. Users must create a new database.
|
||||
The `aptly db recover` will not fix the issue.
|
||||
|
||||
-- Alexandre Viau <aviau@debian.org> Fri, 26 Oct 2018 13:20:53 -0400
|
||||
Vendored
+2
-1
@@ -80,8 +80,9 @@ serve_in_api_mode: false
|
||||
# Enable metrics for Prometheus client
|
||||
enable_metrics_endpoint: false
|
||||
|
||||
# Not implemented in this version.
|
||||
# Enable API documentation on /docs
|
||||
enable_swagger_endpoint: false
|
||||
#enable_swagger_endpoint: false
|
||||
|
||||
# OBSOLETE: use via url param ?_async=true
|
||||
async_api: false
|
||||
|
||||
Vendored
+517
-34
@@ -1,39 +1,522 @@
|
||||
aptly (1.6.1) stable; urgency=medium
|
||||
aptly (1.6.2-3) unstable; urgency=medium
|
||||
|
||||
* update golang-github-syndtr-goleveldb-dev dependency (v1.0.1-0.20220721030215-126854af5e6d) to fix segfault on arm64
|
||||
(bug in golang-github-golang-snappy-dev)
|
||||
* allow snapshotting empty mirrors again (regression)
|
||||
* debian compliance: add postrm (note: `apt purge aptly-api` will remove all data in ~aptly-api/)
|
||||
* update other dependencies (x/net 0.33.0, gin-gonic/gin 1.9.1)
|
||||
[ Sébastien Delafond ]
|
||||
* tests: disable t04_mirror/create/CreateMirror18Test (Closes: #1135740)
|
||||
* tests: disable t12_api/gpg/GPGAPITestAddKey (Closes: #1135672)
|
||||
* d/control: bump-up Standards-Version
|
||||
|
||||
-- André Roth <neolynx@gmail.com> Sat, 15 Feb 2025 13:03:16 +0100
|
||||
-- Sebastien Delafond <seb@debian.org> Tue, 05 May 2026 18:14:44 +0200
|
||||
|
||||
aptly (1.6.0) stable; urgency=medium
|
||||
aptly (1.6.2-2) unstable; urgency=medium
|
||||
|
||||
* support reading filters from file or stdin
|
||||
* fix mirroring source packages
|
||||
* support yaml config per default
|
||||
* provide swagger API documentation
|
||||
* provide API for querying aptly storage usage
|
||||
* provide snapshot pull via API
|
||||
* support creating repos from snapshots
|
||||
* fix mirroring flat remote repos
|
||||
* support skeleton files for publishing
|
||||
* use new azure sdk
|
||||
* support updating the components of a published repo
|
||||
* support publishing multiple distributions (-multi-dist)
|
||||
* support etcd database
|
||||
* allow slash (/) in distribution names
|
||||
* support for storing the "local" pool on Azure
|
||||
* provide copy package API
|
||||
* fix publish concurrency and improve performance
|
||||
* improved mirroring
|
||||
* fix download throttling
|
||||
* fix resuming package downloads
|
||||
* fix ignoring signatures
|
||||
* fix packages dependency resolution (Virtual Packages, version numbers in Provides)
|
||||
* improved S3 support and performance
|
||||
* fix race condition with goleveldb
|
||||
* use go 1.22
|
||||
[ Sébastien Delafond ]
|
||||
* Remove Built-Using
|
||||
* Mark patches as "Forwarded: not-needed"
|
||||
|
||||
-- André Roth <neolynx@gmail.com> Tue, 24 Dec 2024 17:44:35 +0100
|
||||
-- Sebastien Delafond <seb@debian.org> Fri, 21 Nov 2025 15:46:51 +0100
|
||||
|
||||
aptly (1.6.2-1) unstable; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* d/watch: v5
|
||||
* Bump up Standards-Version
|
||||
* Remove +ds suffix
|
||||
* Add Static-Built-Using
|
||||
* New upstream version 1.6.2
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Wed, 24 Sep 2025 06:19:54 +0200
|
||||
|
||||
aptly (1.6.1+ds1-3) unstable; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* tests: declare needs-internet for system-test
|
||||
* tests: disable unit test TestVerifyClearsigned & system test
|
||||
CreateMirror31Test (Closes: #1108828)
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Tue, 08 Jul 2025 14:12:52 +0200
|
||||
|
||||
aptly (1.6.1+ds1-2) unstable; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* Do not re-publish unchanged files to S3 every single time (Closes: #1104299)
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Mon, 28 Apr 2025 15:38:43 +0200
|
||||
|
||||
aptly (1.6.1+ds1-1) unstable; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* New upstream version 1.6.1
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Mon, 24 Feb 2025 09:04:35 +0100
|
||||
|
||||
aptly (1.6.0+ds1-8) unstable; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* tests: disable riscv64-flaky EditRepo4Test
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Fri, 21 Feb 2025 06:54:18 +0100
|
||||
|
||||
aptly (1.6.0+ds1-7) unstable; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* tests: clean way to disable single tests, disable s390-flaky CreateMirror35Test
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Thu, 20 Feb 2025 07:26:41 +0100
|
||||
|
||||
aptly (1.6.0+ds1-6) unstable; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* tests: disable system-test's etcd tests as the corresponding fixture is also arch-specific
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Wed, 19 Feb 2025 14:02:19 +0100
|
||||
|
||||
aptly (1.6.0+ds1-5) unstable; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* tests: do not use upstream's etcd installer
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Wed, 19 Feb 2025 07:20:44 +0100
|
||||
|
||||
aptly (1.6.0+ds1-4) unstable; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* postrm: remove aptly-api user and home directory on purge
|
||||
* tests: use extensive coverage from make's test and system-test
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Tue, 18 Feb 2025 10:36:13 +0100
|
||||
|
||||
aptly (1.6.0+ds1-3) unstable; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* aptly.conf: fix s3 example
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Mon, 13 Jan 2025 14:51:29 +0100
|
||||
|
||||
aptly (1.6.0+ds1-2) unstable; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* Document disabled swagger in default config file
|
||||
* Rediff patches: swagger references in man page
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Mon, 30 Dec 2024 11:11:07 +0100
|
||||
|
||||
aptly (1.6.0+ds1-1) unstable; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* Official 1.6 release
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Fri, 27 Dec 2024 14:23:29 +0100
|
||||
|
||||
aptly (1.6.0+ds1~beta3-1) experimental; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* Latest upstream version
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Wed, 11 Dec 2024 18:16:19 +0100
|
||||
|
||||
aptly (1.6.0+ds1~beta2-1) experimental; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* Latest upstream version
|
||||
|
||||
[ André Roth ]
|
||||
* set systemd service file limit to 32768
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Thu, 21 Nov 2024 16:08:05 +0100
|
||||
|
||||
aptly (1.6.0+ds1~beta1-1) experimental; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* Latest upstream version
|
||||
* Disable "use new azure-sdk"
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Sun, 17 Nov 2024 18:52:06 +0100
|
||||
|
||||
aptly (1.6.0+ds1~alpha5-1) experimental; urgency=medium
|
||||
|
||||
* Sort out dependencies on gpg*
|
||||
* Reduce diff with upstream some more
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Sun, 17 Nov 2024 15:59:23 +0100
|
||||
|
||||
aptly (1.6.0+ds1~alpha4-1) experimental; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* Remove build-dep on git
|
||||
* Adjust systemd unit for aptly-api
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Sun, 17 Nov 2024 14:51:49 +0100
|
||||
|
||||
aptly (1.6.0+ds1~alpha3-1) experimental; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* Latest upstream version
|
||||
* Remove useless maintainer scripts
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Sun, 17 Nov 2024 07:50:06 +0100
|
||||
|
||||
aptly (1.6.0+ds1~alpha2-1) experimental; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* Latest upstream version
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Sat, 16 Nov 2024 14:42:10 +0100
|
||||
|
||||
aptly (1.6.0+ds1~alpha1-2) experimental; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* Add zsh completion
|
||||
* aptly-api: revert arch:all, so mv_conffile does the right thing
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Wed, 16 Oct 2024 09:10:05 +0200
|
||||
|
||||
aptly (1.6.0+ds1~alpha1-1) experimental; urgency=medium
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* d/patches: remove old patch, and disable swagger support
|
||||
* d/control: bump up Standards-Version
|
||||
* Adjust packaging for 1.6.0~alpha1
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Tue, 15 Oct 2024 14:40:57 +0200
|
||||
|
||||
aptly (1.5.0+ds1-2) unstable; urgency=medium
|
||||
|
||||
[ Shengjing Zhu ]
|
||||
* Replace golang-gopkg-cheggaaa-pb.v1-dev with
|
||||
golang-github-cheggaaa-pb-dev (Closes: #1050900)
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Mon, 04 Sep 2023 08:49:36 +0200
|
||||
|
||||
aptly (1.5.0+ds1-1) unstable; urgency=medium
|
||||
|
||||
* Team upload.
|
||||
* New upstream release (Closes: #1022721), including fix for "Order of
|
||||
fields in Packages/Sources is unpredictable" (Closes: #907121).
|
||||
|
||||
-- Roland Mas <lolando@debian.org> Tue, 31 Jan 2023 14:47:04 +0100
|
||||
|
||||
aptly (1.4.0+ds1-7) unstable; urgency=medium
|
||||
|
||||
* Team upload.
|
||||
* Add support for zstd compression (Closes: #1010465)
|
||||
|
||||
-- Anton Gladky <gladk@debian.org> Tue, 17 May 2022 22:42:29 +0200
|
||||
|
||||
aptly (1.4.0+ds1-6) unstable; urgency=medium
|
||||
|
||||
* Conflict on gpgv1 (Closes: #990821)
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Thu, 04 Nov 2021 10:24:53 +0100
|
||||
|
||||
aptly (1.4.0+ds1-5) unstable; urgency=medium
|
||||
|
||||
* Conflict on gnupg1 (Closes: #990821)
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Thu, 14 Oct 2021 18:43:04 +0200
|
||||
|
||||
aptly (1.4.0+ds1-4) unstable; urgency=medium
|
||||
|
||||
* Install correct bash completion snippet (Closes: #984979)
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Thu, 11 Mar 2021 15:20:57 +0100
|
||||
|
||||
aptly (1.4.0+ds1-3) unstable; urgency=medium
|
||||
|
||||
* Fix s3 etag issue (Closes: #983877)
|
||||
* Bump-up d/watch version
|
||||
* Bump-up Standards-Version
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Wed, 03 Mar 2021 10:50:51 +0100
|
||||
|
||||
aptly (1.4.0+ds1-2) unstable; urgency=medium
|
||||
|
||||
* Use pipeline from salsa-ci-team
|
||||
* Allow reprotest failure
|
||||
* Pass version from d/rules (Closes: #968585)
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Fri, 21 Aug 2020 10:13:44 +0200
|
||||
|
||||
aptly (1.4.0+ds1-1) unstable; urgency=medium
|
||||
|
||||
* New upstream version 1.4.0+ds1
|
||||
* Rediff patches
|
||||
* Depend on gnupg 2
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Sun, 22 Dec 2019 15:16:25 +0100
|
||||
|
||||
aptly (1.3.0+ds1-4) unstable; urgency=medium
|
||||
|
||||
[ Debian Janitor ]
|
||||
* Rename obsolete path debian/tests/control.autodep8 to debian/tests/control.
|
||||
* Use secure URI in Homepage field.
|
||||
* Bump debhelper from old 11 to 12.
|
||||
* Set debhelper-compat version in Build-Depends.
|
||||
|
||||
[ Sébastien Delafond ]
|
||||
* Bump up Standards-Version
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Sun, 22 Dec 2019 14:10:19 +0100
|
||||
|
||||
aptly (1.3.0+ds1-3) unstable; urgency=medium
|
||||
|
||||
* Build-Depend on golang-golang-x-tools-dev instead of golang-go.tools (Closes: #945884)
|
||||
* Lintian fix
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Sat, 21 Dec 2019 10:29:09 +0100
|
||||
|
||||
aptly (1.3.0+ds1-2.3) unstable; urgency=medium
|
||||
|
||||
* Non-maintainer upload.
|
||||
* Remove myself from uploaders.
|
||||
|
||||
-- Alexandre Viau <aviau@debian.org> Sun, 15 Sep 2019 19:27:47 -0400
|
||||
|
||||
aptly (1.3.0+ds1-2.2) unstable; urgency=medium
|
||||
|
||||
* Non-maintainer upload.
|
||||
* Add patch to fix DB backwards compatibility (Closes: #911924)
|
||||
* Fix struct field tag typo
|
||||
* Update debian/NEWS about DB compatibility
|
||||
|
||||
-- Shengjing Zhu <zhsj@debian.org> Tue, 16 Apr 2019 00:18:23 +0800
|
||||
|
||||
aptly (1.3.0+ds1-2.1) unstable; urgency=medium
|
||||
|
||||
[ Shengjing Zhu ]
|
||||
* Non-maintainer upload.
|
||||
* Add patch to fix UUID struct field not encoded in msgpack (Closes: #923866)
|
||||
|
||||
[ Tobias Frost ]
|
||||
* Prepare upload.
|
||||
|
||||
-- Tobias Frost <tobi@debian.org> Fri, 05 Apr 2019 17:19:14 +0200
|
||||
|
||||
aptly (1.3.0+ds1-2) unstable; urgency=medium
|
||||
|
||||
* Add NEWS to warn about database compatibility.
|
||||
|
||||
-- Alexandre Viau <aviau@debian.org> Fri, 26 Oct 2018 13:22:38 -0400
|
||||
|
||||
aptly (1.3.0+ds1-1) unstable; urgency=medium
|
||||
|
||||
[ Ondřej Nový ]
|
||||
* d/changelog: Remove trailing whitespaces
|
||||
|
||||
[ Alexandre Viau ]
|
||||
* d/watch: Append +ds suffix.
|
||||
* d/copyright: ignore vendor/*. (Closes: #902128)
|
||||
* d/copyright: remove vendor/* sections.
|
||||
* d/copyright: MIT -> Expat.
|
||||
* d/control: add vendor/* build dependencies.
|
||||
* Patch: Use Debian's uuid package.
|
||||
* Patch: Use Debian's lzma package.
|
||||
* d/rules: remove trailing whitespace.
|
||||
|
||||
-- Alexandre Viau <aviau@debian.org> Mon, 15 Oct 2018 11:54:03 -0400
|
||||
|
||||
aptly (1.3.0-6) unstable; urgency=medium
|
||||
|
||||
* Combine autodep8 and autopkgtest.
|
||||
|
||||
-- Alexandre Viau <aviau@debian.org> Fri, 29 Jun 2018 18:11:41 -0400
|
||||
|
||||
aptly (1.3.0-5) unstable; urgency=medium
|
||||
|
||||
* Fix syntax-error-in-dep5-copyright.
|
||||
* Fix unnecessary-testsuite-autopkgtest-field.
|
||||
* Fix broken autopkgtest.
|
||||
* Depend on gpgv1.
|
||||
|
||||
-- Alexandre Viau <aviau@debian.org> Tue, 26 Jun 2018 23:01:36 -0400
|
||||
|
||||
aptly (1.3.0-4) unstable; urgency=medium
|
||||
|
||||
* Document #902128 in debian/copyright
|
||||
* Point debian/watch to new git repo on GitHub
|
||||
* Add simple autopkgtest
|
||||
* Add debian/.gitlab-ci.yml
|
||||
* Depend on gnupg1 (Closes: #902419)
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Tue, 26 Jun 2018 14:24:34 +0200
|
||||
|
||||
aptly (1.3.0-3) unstable; urgency=medium
|
||||
|
||||
* Create aptly-api package. (Closes: #902032)
|
||||
|
||||
-- Alexandre Viau <aviau@debian.org> Fri, 22 Jun 2018 13:51:50 -0400
|
||||
|
||||
aptly (1.3.0-2) unstable; urgency=medium
|
||||
|
||||
* Team upload, many thanks to Alexandre Viau for this work
|
||||
* Switch to dh-golang. (Closes: #902038)
|
||||
* Fix vcs-field-not-canonical.
|
||||
* Fix insecure-copyright-format-uri.
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Fri, 22 Jun 2018 13:53:11 +0200
|
||||
|
||||
aptly (1.3.0-1) unstable; urgency=medium
|
||||
|
||||
* Fix copyright
|
||||
* New upstream version 1.3.0
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Thu, 21 Jun 2018 15:14:57 +0200
|
||||
|
||||
aptly (1.2.0-4) unstable; urgency=medium
|
||||
|
||||
* Enable Built-Using in debian/control (thanks M. Staperberg)
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Tue, 06 Mar 2018 10:10:42 +0100
|
||||
|
||||
aptly (1.2.0-3) unstable; urgency=medium
|
||||
|
||||
* Switch to DEP 14
|
||||
* Update Vcs-* to point to salsa.d.o
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Fri, 16 Feb 2018 17:02:25 +0100
|
||||
|
||||
aptly (1.2.0-2) unstable; urgency=medium
|
||||
|
||||
* Team upload.
|
||||
* Build-Depend on golang-any, not golang
|
||||
* Set XS-Go-Import-Path
|
||||
|
||||
-- Michael Stapelberg <stapelberg@debian.org> Sat, 10 Feb 2018 18:41:37 +0100
|
||||
|
||||
aptly (1.2.0-1) unstable; urgency=medium
|
||||
|
||||
* New upstream version 1.2.0
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Wed, 03 Jan 2018 13:43:30 +0100
|
||||
|
||||
aptly (1.1.1-2) unstable; urgency=medium
|
||||
|
||||
* Support both uncompressed control.tar, and xz-compressed
|
||||
control.tar.xz. Thanks to Boyuan Yang for the patch (Closes: 879718)
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Thu, 02 Nov 2017 13:23:29 +0100
|
||||
|
||||
aptly (1.1.1-1) unstable; urgency=medium
|
||||
|
||||
* New upstream version 1.1.1
|
||||
* Use bash-completion snippet from upstream
|
||||
* Bump up Standards-Version
|
||||
* Update debian/copyright
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Thu, 02 Nov 2017 09:03:23 +0100
|
||||
|
||||
aptly (1.0.1-1) unstable; urgency=medium
|
||||
|
||||
* Imported Upstream version 1.0.1
|
||||
* Update debian/copyright
|
||||
* Adapt debian/rules
|
||||
* Update Vcs-Git
|
||||
* Bump-up Standards-Version
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Tue, 18 Jul 2017 11:53:29 +0200
|
||||
|
||||
aptly (0.9.7-1) unstable; urgency=medium
|
||||
|
||||
* Imported new upstream version 0.9.7
|
||||
* Add new licenses and copyrights info
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Tue, 24 May 2016 09:17:08 +0200
|
||||
|
||||
aptly (0.9.6-1) unstable; urgency=medium
|
||||
|
||||
* Import new upstream version 0.9.6
|
||||
* Add dependency on xz-utils
|
||||
* Licenses and copyrights
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Wed, 10 Feb 2016 18:28:51 +0100
|
||||
|
||||
aptly (0.9.5-2) unstable; urgency=medium
|
||||
|
||||
* Remove empty component in GOPATH (Closes: #793838)
|
||||
|
||||
[ Sebastien Delafond ]
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Sun, 16 Aug 2015 18:42:22 +0200
|
||||
|
||||
aptly (0.9.5-1) unstable; urgency=medium
|
||||
|
||||
* Imported Upstream version 0.9.5
|
||||
* Up-to-date bash completion
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Fri, 15 May 2015 10:46:51 +0200
|
||||
|
||||
aptly (0.9.1-1) unstable; urgency=medium
|
||||
|
||||
* Imported Upstream version 0.9.1
|
||||
* Document licenses and copyrights for new dependencies
|
||||
* Suggest graphviz
|
||||
* Proper name for bash-completion file
|
||||
* Bump-up Standards-Version
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Sat, 02 May 2015 12:57:16 +0200
|
||||
|
||||
aptly (0.8-3) unstable; urgency=medium
|
||||
|
||||
* Correct Vcs-Browser entry (Closes: #764622)
|
||||
* Correct dependency from "gpg" to "gnupg" (Closes: #764619)
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Thu, 09 Oct 2014 18:41:38 +0200
|
||||
|
||||
aptly (0.8-2) unstable; urgency=medium
|
||||
|
||||
* Add missing dependencies on bzip2, gpg and gpgv
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Thu, 09 Oct 2014 11:15:21 +0200
|
||||
|
||||
aptly (0.8-1) unstable; urgency=medium
|
||||
|
||||
* Imported Upstream version 0.8
|
||||
* Document new copyrights and licenses
|
||||
* Add bash completion snippet
|
||||
* Reference full paths in debian/copyright, and remove unused
|
||||
references, so lintian does not complain
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Sat, 04 Oct 2014 17:46:24 +0200
|
||||
|
||||
aptly (0.7.1-1) unstable; urgency=medium
|
||||
|
||||
* Imported Upstream version 0.7.1
|
||||
* Add copyright information for new libraries
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Wed, 10 Sep 2014 10:03:27 +0200
|
||||
|
||||
aptly (0.5-5) unstable; urgency=medium
|
||||
|
||||
* Turn off verbose mode
|
||||
* Correct Vcs-* information
|
||||
* gocov is licensed MIT, not BSD-3
|
||||
* Add missing MIT license text
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Tue, 09 Sep 2014 09:20:40 +0200
|
||||
|
||||
aptly (0.5-4) unstable; urgency=medium
|
||||
|
||||
* Collect licenses by going over files one by one
|
||||
* Use packaged golang-go.tools
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Thu, 10 Jul 2014 00:49:09 +0200
|
||||
|
||||
aptly (0.5-3) unstable; urgency=low
|
||||
|
||||
* Licensing:
|
||||
- goleveldb is BSD-2, not BSD-3
|
||||
- _vendor/src/code.google.com/p/gographviz/scanner/scanner is BSD-3,
|
||||
copyright 2009 The Go Authors
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Wed, 28 May 2014 10:04:01 +0200
|
||||
|
||||
aptly (0.5-2) unstable; urgency=low
|
||||
|
||||
* Go interpreter not needed at runtime
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Fri, 02 May 2014 12:04:02 +0200
|
||||
|
||||
aptly (0.5-1) unstable; urgency=low
|
||||
|
||||
* Initial release (Closes: #746343)
|
||||
|
||||
-- Sebastien Delafond <seb@debian.org> Tue, 29 Apr 2014 15:47:31 +0200
|
||||
|
||||
Vendored
+7
-16
@@ -1,7 +1,7 @@
|
||||
Source: aptly
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Maintainer: André Roth <neolynx@gmail.com>
|
||||
Maintainer: Sebastien Delafond <seb@debian.org>
|
||||
Build-Depends: bash-completion,
|
||||
debhelper-compat (= 13),
|
||||
dh-golang,
|
||||
@@ -77,20 +77,18 @@ Build-Depends: bash-completion,
|
||||
golang-go.uber-zap-dev,
|
||||
golang-etcd-server-dev (>= 3.5.15-7),
|
||||
golang-gopkg-yaml.v3-dev,
|
||||
git
|
||||
Standards-Version: 4.7.0
|
||||
Standards-Version: 4.7.4
|
||||
Homepage: https://www.aptly.info
|
||||
Vcs-Git: https://github.com/aptly-dev/aptly.git
|
||||
Vcs-Browser: https://github.com/aptly-dev/aptly
|
||||
Vcs-Git: https://salsa.debian.org/debian/aptly.git
|
||||
Vcs-Browser: https://salsa.debian.org/debian/aptly
|
||||
XS-Go-Import-Path: github.com/aptly-dev/aptly
|
||||
Testsuite: autopkgtest-pkg-go
|
||||
|
||||
Package: aptly
|
||||
Architecture: any
|
||||
Depends: ${misc:Depends}, ${shlibs:Depends}, bzip2, xz-utils, gpgv, gpg
|
||||
Suggests: graphviz
|
||||
Static-Built-Using: ${misc:Static-Built-Using}
|
||||
Conflicts: gnupg1, gpgv1
|
||||
Built-Using: ${misc:Static-Built-Using}, ${misc:Built-Using}
|
||||
Suggests: graphviz
|
||||
Description: Swiss army knife for Debian repository management - main package
|
||||
It offers several features making it easy to manage Debian package
|
||||
repositories:
|
||||
@@ -107,7 +105,7 @@ Description: Swiss army knife for Debian repository management - main package
|
||||
This is the main package, it contains the aptly command-line utility.
|
||||
|
||||
Package: aptly-api
|
||||
Architecture: any
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}, aptly
|
||||
Description: Swiss army knife for Debian repository management - API
|
||||
It offers several features making it easy to manage Debian package
|
||||
@@ -123,10 +121,3 @@ Description: Swiss army knife for Debian repository management - API
|
||||
- merge two or more snapshots into one
|
||||
.
|
||||
This package contains the aptly-api service.
|
||||
|
||||
Package: aptly-dbg
|
||||
Architecture: any
|
||||
Depends: ${misc:Depends}
|
||||
Built-Using: ${misc:Static-Built-Using}, ${misc:Built-Using}
|
||||
Description: Debian repository management tool (debug files)
|
||||
Debug symbols for aptly
|
||||
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
[DEFAULT]
|
||||
debian-branch = debian/master
|
||||
upstream-branch = upstream/latest
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
usr/bin/files
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
From: =?utf-8?q?Andr=C3=A9_Roth?= <neolynx@gmail.com>
|
||||
Date: Tue, 15 Oct 2024 12:09:33 +0200
|
||||
Subject: Disable swagger
|
||||
|
||||
This can be enabled once the following modules make it into Debian:
|
||||
|
||||
- github.com/swaggo/files v1.0.1
|
||||
- github.com/swaggo/gin-swagger v1.6.0
|
||||
- github.com/swaggo/swag v1.16.3
|
||||
|
||||
Forwarded: not-needed
|
||||
---
|
||||
api/router.go | 22 +++++++++++-----------
|
||||
docs/index.go | 10 ----------
|
||||
docs/index.go.disabled | 10 ++++++++++
|
||||
man/aptly.1 | 3 ++-
|
||||
man/aptly.1.ronn.tmpl | 3 ++-
|
||||
5 files changed, 25 insertions(+), 23 deletions(-)
|
||||
delete mode 100644 docs/index.go
|
||||
create mode 100644 docs/index.go.disabled
|
||||
|
||||
diff --git a/api/router.go b/api/router.go
|
||||
index 3cd7d42..cf53cd2 100644
|
||||
--- a/api/router.go
|
||||
+++ b/api/router.go
|
||||
@@ -11,9 +11,9 @@
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
- "github.com/aptly-dev/aptly/docs"
|
||||
- swaggerFiles "github.com/swaggo/files"
|
||||
- ginSwagger "github.com/swaggo/gin-swagger"
|
||||
+ // _ "github.com/aptly-dev/aptly/docs" // import docs
|
||||
+ // swaggerFiles "github.com/swaggo/files"
|
||||
+ // ginSwagger "github.com/swaggo/gin-swagger"
|
||||
)
|
||||
|
||||
var context *ctx.AptlyContext
|
||||
@@ -63,14 +63,14 @@ func Router(c *ctx.AptlyContext) http.Handler {
|
||||
|
||||
router.Use(gin.Recovery(), gin.ErrorLogger())
|
||||
|
||||
- if c.Config().EnableSwaggerEndpoint {
|
||||
- router.GET("docs.html", func(c *gin.Context) {
|
||||
- c.Data(http.StatusOK, "text/html; charset=utf-8", docs.DocsHTML)
|
||||
- })
|
||||
- router.Use(redirectSwagger)
|
||||
- url := ginSwagger.URL("/docs/doc.json")
|
||||
- router.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url))
|
||||
- }
|
||||
+ // if c.Config().EnableSwaggerEndpoint {
|
||||
+ // router.GET("docs.html", func(c *gin.Context) {
|
||||
+ // c.Data(http.StatusOK, "text/html; charset=utf-8", docs.DocsHTML)
|
||||
+ // })
|
||||
+ // router.Use(redirectSwagger)
|
||||
+ // url := ginSwagger.URL("/docs/doc.json")
|
||||
+ // router.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url))
|
||||
+ // }
|
||||
|
||||
if c.Config().EnableMetricsEndpoint {
|
||||
MetricsCollectorRegistrar.Register(router)
|
||||
diff --git a/docs/index.go b/docs/index.go
|
||||
deleted file mode 100644
|
||||
index ca4c914..0000000
|
||||
--- a/docs/index.go
|
||||
+++ /dev/null
|
||||
@@ -1,10 +0,0 @@
|
||||
-package docs
|
||||
-
|
||||
-import (
|
||||
- _ "embed" // embed html below
|
||||
-
|
||||
- _ "github.com/swaggo/swag" // make sure swag is in go.mod
|
||||
-)
|
||||
-
|
||||
-//go:embed docs.html
|
||||
-var DocsHTML []byte
|
||||
diff --git a/docs/index.go.disabled b/docs/index.go.disabled
|
||||
new file mode 100644
|
||||
index 0000000..ca4c914
|
||||
--- /dev/null
|
||||
+++ b/docs/index.go.disabled
|
||||
@@ -0,0 +1,10 @@
|
||||
+package docs
|
||||
+
|
||||
+import (
|
||||
+ _ "embed" // embed html below
|
||||
+
|
||||
+ _ "github.com/swaggo/swag" // make sure swag is in go.mod
|
||||
+)
|
||||
+
|
||||
+//go:embed docs.html
|
||||
+var DocsHTML []byte
|
||||
diff --git a/man/aptly.1 b/man/aptly.1
|
||||
index bd6ad22..11ed990 100644
|
||||
--- a/man/aptly.1
|
||||
+++ b/man/aptly.1
|
||||
@@ -111,8 +111,9 @@ The legacy json configuration is still supported (and also supports comments):
|
||||
// Enable metrics for Prometheus client
|
||||
"enableMetricsEndpoint": false,
|
||||
|
||||
+ // Not implemented in this version\.
|
||||
// Enable API documentation on /docs
|
||||
- "enableSwaggerEndpoint": false,
|
||||
+ //"enableSwaggerEndpoint": false,
|
||||
|
||||
// OBSOLETE: use via url param ?_async=true
|
||||
"AsyncAPI": false,
|
||||
diff --git a/man/aptly.1.ronn.tmpl b/man/aptly.1.ronn.tmpl
|
||||
index 203cc7f..ed2c87c 100644
|
||||
--- a/man/aptly.1.ronn.tmpl
|
||||
+++ b/man/aptly.1.ronn.tmpl
|
||||
@@ -100,8 +100,9 @@ The legacy json configuration is still supported (and also supports comments):
|
||||
// Enable metrics for Prometheus client
|
||||
"enableMetricsEndpoint": false,
|
||||
|
||||
+ // Not implemented in this version.
|
||||
// Enable API documentation on /docs
|
||||
- "enableSwaggerEndpoint": false,
|
||||
+ //"enableSwaggerEndpoint": false,
|
||||
|
||||
// OBSOLETE: use via url param ?_async=true
|
||||
"AsyncAPI": false,
|
||||
+880
@@ -0,0 +1,880 @@
|
||||
From: =?utf-8?q?Andr=C3=A9_Roth?= <neolynx@gmail.com>
|
||||
Date: Sun, 17 Nov 2024 17:58:04 +0100
|
||||
Subject: Disable new azure-sdk
|
||||
|
||||
This reverts commit e2cbd637b82a153a6756f2af0519e8fe769ee9ab.
|
||||
|
||||
We can enable this once the golang-github-azure-azure-sdk-for-go-dev
|
||||
packages are upgraded in Debian:
|
||||
|
||||
- github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0
|
||||
- github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0
|
||||
- github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.4.1
|
||||
|
||||
Forwarded: not-needed
|
||||
---
|
||||
azure/azure.go | 89 +++++++++++++++-----------------
|
||||
azure/package_pool.go | 45 ++++++++--------
|
||||
azure/package_pool_test.go | 8 ++-
|
||||
azure/public.go | 125 +++++++++++++++++++++------------------------
|
||||
azure/public_test.go | 49 +++++++++---------
|
||||
context/context.go | 1 +
|
||||
deb/list.go | 1 +
|
||||
go.mod | 8 +--
|
||||
go.sum | 52 +++++++++++--------
|
||||
9 files changed, 185 insertions(+), 193 deletions(-)
|
||||
|
||||
diff --git a/azure/azure.go b/azure/azure.go
|
||||
index 3f12678..b313f90 100644
|
||||
--- a/azure/azure.go
|
||||
+++ b/azure/azure.go
|
||||
@@ -5,35 +5,28 @@
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
- "errors"
|
||||
"fmt"
|
||||
"io"
|
||||
- "os"
|
||||
+ "net/url"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
- "github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
- "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
|
||||
- "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
|
||||
+ "github.com/Azure/azure-storage-blob-go/azblob"
|
||||
"github.com/aptly-dev/aptly/aptly"
|
||||
)
|
||||
|
||||
func isBlobNotFound(err error) bool {
|
||||
- var respErr *azcore.ResponseError
|
||||
- if errors.As(err, &respErr) {
|
||||
- return respErr.StatusCode == 404 // BlobNotFound
|
||||
- }
|
||||
- return false
|
||||
+ storageError, ok := err.(azblob.StorageError)
|
||||
+ return ok && storageError.ServiceCode() == azblob.ServiceCodeBlobNotFound
|
||||
}
|
||||
|
||||
type azContext struct {
|
||||
- client *azblob.Client
|
||||
- container string
|
||||
+ container azblob.ContainerURL
|
||||
prefix string
|
||||
}
|
||||
|
||||
func newAzContext(accountName, accountKey, container, prefix, endpoint string) (*azContext, error) {
|
||||
- cred, err := azblob.NewSharedKeyCredential(accountName, accountKey)
|
||||
+ credential, err := azblob.NewSharedKeyCredential(accountName, accountKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -42,14 +35,15 @@ func newAzContext(accountName, accountKey, container, prefix, endpoint string) (
|
||||
endpoint = fmt.Sprintf("https://%s.blob.core.windows.net", accountName)
|
||||
}
|
||||
|
||||
- serviceClient, err := azblob.NewClientWithSharedKeyCredential(endpoint, cred, nil)
|
||||
+ url, err := url.Parse(fmt.Sprintf("%s/%s", endpoint, container))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+ containerURL := azblob.NewContainerURL(*url, azblob.NewPipeline(credential, azblob.PipelineOptions{}))
|
||||
+
|
||||
result := &azContext{
|
||||
- client: serviceClient,
|
||||
- container: container,
|
||||
+ container: containerURL,
|
||||
prefix: prefix,
|
||||
}
|
||||
|
||||
@@ -60,6 +54,10 @@ func (az *azContext) blobPath(path string) string {
|
||||
return filepath.Join(az.prefix, path)
|
||||
}
|
||||
|
||||
+func (az *azContext) blobURL(path string) azblob.BlobURL {
|
||||
+ return az.container.NewBlobURL(az.blobPath(path))
|
||||
+}
|
||||
+
|
||||
func (az *azContext) internalFilelist(prefix string, progress aptly.Progress) (paths []string, md5s []string, err error) {
|
||||
const delimiter = "/"
|
||||
paths = make([]string, 0, 1024)
|
||||
@@ -69,33 +67,27 @@ func (az *azContext) internalFilelist(prefix string, progress aptly.Progress) (p
|
||||
prefix += delimiter
|
||||
}
|
||||
|
||||
- ctx := context.Background()
|
||||
- maxResults := int32(1)
|
||||
- pager := az.client.NewListBlobsFlatPager(az.container, &azblob.ListBlobsFlatOptions{
|
||||
- Prefix: &prefix,
|
||||
- MaxResults: &maxResults,
|
||||
- Include: azblob.ListBlobsInclude{Metadata: true},
|
||||
- })
|
||||
-
|
||||
- // Iterate over each page
|
||||
- for pager.More() {
|
||||
- page, err := pager.NextPage(ctx)
|
||||
+ for marker := (azblob.Marker{}); marker.NotDone(); {
|
||||
+ listBlob, err := az.container.ListBlobsFlatSegment(
|
||||
+ context.Background(), marker, azblob.ListBlobsSegmentOptions{
|
||||
+ Prefix: prefix,
|
||||
+ MaxResults: 1,
|
||||
+ Details: azblob.BlobListingDetails{Metadata: true}})
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error listing under prefix %s in %s: %s", prefix, az, err)
|
||||
}
|
||||
|
||||
- for _, blob := range page.Segment.BlobItems {
|
||||
- if prefix == "" {
|
||||
- paths = append(paths, *blob.Name)
|
||||
- } else {
|
||||
- name := *blob.Name
|
||||
- paths = append(paths, name[len(prefix):])
|
||||
- }
|
||||
- b := *blob
|
||||
- md5 := b.Properties.ContentMD5
|
||||
- md5s = append(md5s, fmt.Sprintf("%x", md5))
|
||||
+ marker = listBlob.NextMarker
|
||||
|
||||
+ for _, blob := range listBlob.Segment.BlobItems {
|
||||
+ if prefix == "" {
|
||||
+ paths = append(paths, blob.Name)
|
||||
+ } else {
|
||||
+ paths = append(paths, blob.Name[len(prefix):])
|
||||
+ }
|
||||
+ md5s = append(md5s, fmt.Sprintf("%x", blob.Properties.ContentMD5))
|
||||
}
|
||||
+
|
||||
if progress != nil {
|
||||
time.Sleep(time.Duration(500) * time.Millisecond)
|
||||
progress.AddBar(1)
|
||||
@@ -105,27 +97,28 @@ func (az *azContext) internalFilelist(prefix string, progress aptly.Progress) (p
|
||||
return paths, md5s, nil
|
||||
}
|
||||
|
||||
-func (az *azContext) putFile(blobName string, source io.Reader, sourceMD5 string) error {
|
||||
- uploadOptions := &azblob.UploadFileOptions{
|
||||
- BlockSize: 4 * 1024 * 1024,
|
||||
- Concurrency: 8,
|
||||
+func (az *azContext) putFile(blob azblob.BlobURL, source io.Reader, sourceMD5 string) error {
|
||||
+ uploadOptions := azblob.UploadStreamToBlockBlobOptions{
|
||||
+ BufferSize: 4 * 1024 * 1024,
|
||||
+ MaxBuffers: 8,
|
||||
}
|
||||
|
||||
- path := az.blobPath(blobName)
|
||||
if len(sourceMD5) > 0 {
|
||||
decodedMD5, err := hex.DecodeString(sourceMD5)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
- uploadOptions.HTTPHeaders = &blob.HTTPHeaders{
|
||||
- BlobContentMD5: decodedMD5,
|
||||
+ uploadOptions.BlobHTTPHeaders = azblob.BlobHTTPHeaders{
|
||||
+ ContentMD5: decodedMD5,
|
||||
}
|
||||
}
|
||||
|
||||
- var err error
|
||||
- if file, ok := source.(*os.File); ok {
|
||||
- _, err = az.client.UploadFile(context.TODO(), az.container, path, file, uploadOptions)
|
||||
- }
|
||||
+ _, err := azblob.UploadStreamToBlockBlob(
|
||||
+ context.Background(),
|
||||
+ source,
|
||||
+ blob.ToBlockBlobURL(),
|
||||
+ uploadOptions,
|
||||
+ )
|
||||
|
||||
return err
|
||||
}
|
||||
diff --git a/azure/package_pool.go b/azure/package_pool.go
|
||||
index 97be8e6..6d7af1a 100644
|
||||
--- a/azure/package_pool.go
|
||||
+++ b/azure/package_pool.go
|
||||
@@ -5,6 +5,7 @@
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
+ "github.com/Azure/azure-storage-blob-go/azblob"
|
||||
"github.com/aptly-dev/aptly/aptly"
|
||||
"github.com/aptly-dev/aptly/utils"
|
||||
"github.com/pkg/errors"
|
||||
@@ -40,7 +41,10 @@ func (pool *PackagePool) buildPoolPath(filename string, checksums *utils.Checksu
|
||||
return filepath.Join(hash[0:2], hash[2:4], hash[4:32]+"_"+filename)
|
||||
}
|
||||
|
||||
-func (pool *PackagePool) ensureChecksums(poolPath string, checksumStorage aptly.ChecksumStorage) (*utils.ChecksumInfo, error) {
|
||||
+func (pool *PackagePool) ensureChecksums(
|
||||
+ poolPath string,
|
||||
+ checksumStorage aptly.ChecksumStorage,
|
||||
+) (*utils.ChecksumInfo, error) {
|
||||
targetChecksums, err := checksumStorage.Get(poolPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -48,7 +52,8 @@ func (pool *PackagePool) ensureChecksums(poolPath string, checksumStorage aptly.
|
||||
|
||||
if targetChecksums == nil {
|
||||
// we don't have checksums stored yet for this file
|
||||
- download, err := pool.az.client.DownloadStream(context.Background(), pool.az.container, poolPath, nil)
|
||||
+ blob := pool.az.blobURL(poolPath)
|
||||
+ download, err := blob.Download(context.Background(), 0, 0, azblob.BlobAccessConditions{}, false, azblob.ClientProvidedKeyOptions{})
|
||||
if err != nil {
|
||||
if isBlobNotFound(err) {
|
||||
return nil, nil
|
||||
@@ -58,7 +63,7 @@ func (pool *PackagePool) ensureChecksums(poolPath string, checksumStorage aptly.
|
||||
}
|
||||
|
||||
targetChecksums = &utils.ChecksumInfo{}
|
||||
- *targetChecksums, err = utils.ChecksumsForReader(download.Body)
|
||||
+ *targetChecksums, err = utils.ChecksumsForReader(download.Body(azblob.RetryReaderOptions{}))
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error checksumming blob at %s", poolPath)
|
||||
}
|
||||
@@ -87,49 +92,46 @@ func (pool *PackagePool) LegacyPath(_ string, _ *utils.ChecksumInfo) (string, er
|
||||
}
|
||||
|
||||
func (pool *PackagePool) Size(path string) (int64, error) {
|
||||
- serviceClient := pool.az.client.ServiceClient()
|
||||
- containerClient := serviceClient.NewContainerClient(pool.az.container)
|
||||
- blobClient := containerClient.NewBlobClient(path)
|
||||
-
|
||||
- props, err := blobClient.GetProperties(context.TODO(), nil)
|
||||
+ blob := pool.az.blobURL(path)
|
||||
+ props, err := blob.GetProperties(context.Background(), azblob.BlobAccessConditions{}, azblob.ClientProvidedKeyOptions{})
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "error examining %s from %s", path, pool)
|
||||
}
|
||||
|
||||
- return *props.ContentLength, nil
|
||||
+ return props.ContentLength(), nil
|
||||
}
|
||||
|
||||
func (pool *PackagePool) Open(path string) (aptly.ReadSeekerCloser, error) {
|
||||
+ blob := pool.az.blobURL(path)
|
||||
+
|
||||
temp, err := os.CreateTemp("", "blob-download")
|
||||
if err != nil {
|
||||
- return nil, errors.Wrapf(err, "error creating tempfile for %s", path)
|
||||
+ return nil, errors.Wrap(err, "error creating temporary file for blob download")
|
||||
}
|
||||
+
|
||||
defer func () { _ = os.Remove(temp.Name()) }()
|
||||
|
||||
- _, err = pool.az.client.DownloadFile(context.TODO(), pool.az.container, path, temp, nil)
|
||||
+ err = azblob.DownloadBlobToFile(context.Background(), blob, 0, 0, temp, azblob.DownloadFromBlobOptions{})
|
||||
if err != nil {
|
||||
- return nil, errors.Wrapf(err, "error downloading blob %s", path)
|
||||
+ return nil, errors.Wrapf(err, "error downloading blob at %s", path)
|
||||
}
|
||||
|
||||
return temp, nil
|
||||
}
|
||||
|
||||
func (pool *PackagePool) Remove(path string) (int64, error) {
|
||||
- serviceClient := pool.az.client.ServiceClient()
|
||||
- containerClient := serviceClient.NewContainerClient(pool.az.container)
|
||||
- blobClient := containerClient.NewBlobClient(path)
|
||||
-
|
||||
- props, err := blobClient.GetProperties(context.TODO(), nil)
|
||||
+ blob := pool.az.blobURL(path)
|
||||
+ props, err := blob.GetProperties(context.Background(), azblob.BlobAccessConditions{}, azblob.ClientProvidedKeyOptions{})
|
||||
if err != nil {
|
||||
- return 0, errors.Wrapf(err, "error examining %s from %s", path, pool)
|
||||
+ return 0, errors.Wrapf(err, "error getting props of %s from %s", path, pool)
|
||||
}
|
||||
|
||||
- _, err = pool.az.client.DeleteBlob(context.Background(), pool.az.container, path, nil)
|
||||
+ _, err = blob.Delete(context.Background(), azblob.DeleteSnapshotsOptionNone, azblob.BlobAccessConditions{})
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "error deleting %s from %s", path, pool)
|
||||
}
|
||||
|
||||
- return *props.ContentLength, nil
|
||||
+ return props.ContentLength(), nil
|
||||
}
|
||||
|
||||
func (pool *PackagePool) Import(srcPath, basename string, checksums *utils.ChecksumInfo, _ bool, checksumStorage aptly.ChecksumStorage) (string, error) {
|
||||
@@ -143,6 +145,7 @@ func (pool *PackagePool) Import(srcPath, basename string, checksums *utils.Check
|
||||
}
|
||||
|
||||
path := pool.buildPoolPath(basename, checksums)
|
||||
+ blob := pool.az.blobURL(path)
|
||||
targetChecksums, err := pool.ensureChecksums(path, checksumStorage)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -158,7 +161,7 @@ func (pool *PackagePool) Import(srcPath, basename string, checksums *utils.Check
|
||||
}
|
||||
defer func() { _ = source.Close() }()
|
||||
|
||||
- err = pool.az.putFile(path, source, checksums.MD5)
|
||||
+ err = pool.az.putFile(blob, source, checksums.MD5)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
diff --git a/azure/package_pool_test.go b/azure/package_pool_test.go
|
||||
index ef562cb..6b1341d 100644
|
||||
--- a/azure/package_pool_test.go
|
||||
+++ b/azure/package_pool_test.go
|
||||
@@ -7,7 +7,7 @@
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
- "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
|
||||
+ "github.com/Azure/azure-storage-blob-go/azblob"
|
||||
"github.com/aptly-dev/aptly/aptly"
|
||||
"github.com/aptly-dev/aptly/files"
|
||||
"github.com/aptly-dev/aptly/utils"
|
||||
@@ -50,10 +50,8 @@ func (s *PackagePoolSuite) SetUpTest(c *C) {
|
||||
|
||||
s.pool, err = NewPackagePool(s.accountName, s.accountKey, container, "", s.endpoint)
|
||||
c.Assert(err, IsNil)
|
||||
- publicAccessType := azblob.PublicAccessTypeContainer
|
||||
- _, err = s.pool.az.client.CreateContainer(context.TODO(), s.pool.az.container, &azblob.CreateContainerOptions{
|
||||
- Access: &publicAccessType,
|
||||
- })
|
||||
+ cnt := s.pool.az.container
|
||||
+ _, err = cnt.Create(context.Background(), azblob.Metadata{}, azblob.PublicAccessContainer)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
s.prefixedPool, err = NewPackagePool(s.accountName, s.accountKey, container, prefix, s.endpoint)
|
||||
diff --git a/azure/public.go b/azure/public.go
|
||||
index 6775e14..efd2e7a 100644
|
||||
--- a/azure/public.go
|
||||
+++ b/azure/public.go
|
||||
@@ -3,22 +3,21 @@
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
+ "net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
- "github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
- "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
|
||||
- "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/lease"
|
||||
+ "github.com/Azure/azure-storage-blob-go/azblob"
|
||||
"github.com/aptly-dev/aptly/aptly"
|
||||
"github.com/aptly-dev/aptly/utils"
|
||||
- "github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// PublishedStorage abstract file system with published files (actually hosted on Azure)
|
||||
type PublishedStorage struct {
|
||||
// FIXME: unused ???? prefix string
|
||||
+ container azblob.ContainerURL
|
||||
az *azContext
|
||||
pathCache map[string]map[string]string
|
||||
}
|
||||
@@ -67,7 +66,7 @@ func (storage *PublishedStorage) PutFile(path string, sourceFilename string) err
|
||||
}
|
||||
defer func() { _ = source.Close() }()
|
||||
|
||||
- err = storage.az.putFile(path, source, sourceMD5)
|
||||
+ err = storage.az.putFile(storage.az.blobURL(path), source, sourceMD5)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("error uploading %s to %s", sourceFilename, storage))
|
||||
}
|
||||
@@ -77,15 +76,14 @@ func (storage *PublishedStorage) PutFile(path string, sourceFilename string) err
|
||||
|
||||
// RemoveDirs removes directory structure under public path
|
||||
func (storage *PublishedStorage) RemoveDirs(path string, _ aptly.Progress) error {
|
||||
- path = storage.az.blobPath(path)
|
||||
filelist, err := storage.Filelist(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, filename := range filelist {
|
||||
- blob := filepath.Join(path, filename)
|
||||
- _, err := storage.az.client.DeleteBlob(context.Background(), storage.az.container, blob, nil)
|
||||
+ blob := storage.az.blobURL(filepath.Join(path, filename))
|
||||
+ _, err := blob.Delete(context.Background(), azblob.DeleteSnapshotsOptionNone, azblob.BlobAccessConditions{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("error deleting path %s from %s: %s", filename, storage, err)
|
||||
}
|
||||
@@ -96,8 +94,8 @@ func (storage *PublishedStorage) RemoveDirs(path string, _ aptly.Progress) error
|
||||
|
||||
// Remove removes single file under public path
|
||||
func (storage *PublishedStorage) Remove(path string) error {
|
||||
- path = storage.az.blobPath(path)
|
||||
- _, err := storage.az.client.DeleteBlob(context.Background(), storage.az.container, path, nil)
|
||||
+ blob := storage.az.blobURL(path)
|
||||
+ _, err := blob.Delete(context.Background(), azblob.DeleteSnapshotsOptionNone, azblob.BlobAccessConditions{})
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("error deleting %s from %s: %s", path, storage, err))
|
||||
}
|
||||
@@ -116,8 +114,9 @@ func (storage *PublishedStorage) LinkFromPool(publishedPrefix, publishedRelPath,
|
||||
sourcePath string, sourceChecksums utils.ChecksumInfo, force bool) error {
|
||||
|
||||
relFilePath := filepath.Join(publishedRelPath, fileName)
|
||||
- prefixRelFilePath := filepath.Join(publishedPrefix, relFilePath)
|
||||
- poolPath := storage.az.blobPath(prefixRelFilePath)
|
||||
+ // prefixRelFilePath := filepath.Join(publishedPrefix, relFilePath)
|
||||
+ // FIXME: check how to integrate publishedPrefix:
|
||||
+ poolPath := storage.az.blobPath(fileName)
|
||||
|
||||
if storage.pathCache == nil {
|
||||
storage.pathCache = make(map[string]map[string]string)
|
||||
@@ -160,7 +159,7 @@ func (storage *PublishedStorage) LinkFromPool(publishedPrefix, publishedRelPath,
|
||||
}
|
||||
defer func() { _ = source.Close() }()
|
||||
|
||||
- err = storage.az.putFile(relFilePath, source, sourceMD5)
|
||||
+ err = storage.az.putFile(storage.az.blobURL(relFilePath), source, sourceMD5)
|
||||
if err == nil {
|
||||
pathCache[relFilePath] = sourceMD5
|
||||
} else {
|
||||
@@ -177,60 +176,59 @@ func (storage *PublishedStorage) Filelist(prefix string) ([]string, error) {
|
||||
}
|
||||
|
||||
// Internal copy or move implementation
|
||||
-func (storage *PublishedStorage) internalCopyOrMoveBlob(src, dst string, metadata map[string]*string, move bool) error {
|
||||
+func (storage *PublishedStorage) internalCopyOrMoveBlob(src, dst string, metadata azblob.Metadata, move bool) error {
|
||||
const leaseDuration = 30
|
||||
- leaseID := uuid.NewString()
|
||||
|
||||
- serviceClient := storage.az.client.ServiceClient()
|
||||
- containerClient := serviceClient.NewContainerClient(storage.az.container)
|
||||
- srcBlobClient := containerClient.NewBlobClient(src)
|
||||
- blobLeaseClient, err := lease.NewBlobClient(srcBlobClient, &lease.BlobClientOptions{LeaseID: to.Ptr(leaseID)})
|
||||
- if err != nil {
|
||||
- return fmt.Errorf("error acquiring lease on source blob %s", src)
|
||||
- }
|
||||
-
|
||||
- _, err = blobLeaseClient.AcquireLease(context.Background(), leaseDuration, nil)
|
||||
- if err != nil {
|
||||
- return fmt.Errorf("error acquiring lease on source blob %s", src)
|
||||
+ dstBlobURL := storage.az.blobURL(dst)
|
||||
+ srcBlobURL := storage.az.blobURL(src)
|
||||
+ leaseResp, err := srcBlobURL.AcquireLease(context.Background(), "", leaseDuration, azblob.ModifiedAccessConditions{})
|
||||
+ if err != nil || leaseResp.StatusCode() != http.StatusCreated {
|
||||
+ return fmt.Errorf("error acquiring lease on source blob %s", srcBlobURL)
|
||||
}
|
||||
defer func() {
|
||||
- _, _ = blobLeaseClient.BreakLease(context.Background(), &lease.BlobBreakOptions{BreakPeriod: to.Ptr(int32(60))})
|
||||
+ _, _ = srcBlobURL.BreakLease(context.Background(), azblob.LeaseBreakNaturally, azblob.ModifiedAccessConditions{})
|
||||
}()
|
||||
+ srcBlobLeaseID := leaseResp.LeaseID()
|
||||
|
||||
- dstBlobClient := containerClient.NewBlobClient(dst)
|
||||
- copyResp, err := dstBlobClient.StartCopyFromURL(context.Background(), srcBlobClient.URL(), &blob.StartCopyFromURLOptions{
|
||||
- Metadata: metadata,
|
||||
- })
|
||||
-
|
||||
+ copyResp, err := dstBlobURL.StartCopyFromURL(
|
||||
+ context.Background(),
|
||||
+ srcBlobURL.URL(),
|
||||
+ metadata,
|
||||
+ azblob.ModifiedAccessConditions{},
|
||||
+ azblob.BlobAccessConditions{},
|
||||
+ azblob.DefaultAccessTier,
|
||||
+ nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error copying %s -> %s in %s: %s", src, dst, storage, err)
|
||||
}
|
||||
|
||||
- copyStatus := *copyResp.CopyStatus
|
||||
+ copyStatus := copyResp.CopyStatus()
|
||||
for {
|
||||
- if copyStatus == blob.CopyStatusTypeSuccess {
|
||||
+ if copyStatus == azblob.CopyStatusSuccess {
|
||||
if move {
|
||||
- _, err := storage.az.client.DeleteBlob(context.Background(), storage.az.container, src, &blob.DeleteOptions{
|
||||
- AccessConditions: &blob.AccessConditions{
|
||||
- LeaseAccessConditions: &blob.LeaseAccessConditions{
|
||||
- LeaseID: &leaseID,
|
||||
- },
|
||||
- },
|
||||
- })
|
||||
+ _, err = srcBlobURL.Delete(
|
||||
+ context.Background(),
|
||||
+ azblob.DeleteSnapshotsOptionNone,
|
||||
+ azblob.BlobAccessConditions{
|
||||
+ LeaseAccessConditions: azblob.LeaseAccessConditions{LeaseID: srcBlobLeaseID},
|
||||
+ })
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
- } else if copyStatus == blob.CopyStatusTypePending {
|
||||
+ } else if copyStatus == azblob.CopyStatusPending {
|
||||
time.Sleep(1 * time.Second)
|
||||
- getMetadata, err := dstBlobClient.GetProperties(context.TODO(), nil)
|
||||
+ blobPropsResp, err := dstBlobURL.GetProperties(
|
||||
+ context.Background(),
|
||||
+ azblob.BlobAccessConditions{LeaseAccessConditions: azblob.LeaseAccessConditions{LeaseID: srcBlobLeaseID}},
|
||||
+ azblob.ClientProvidedKeyOptions{})
|
||||
if err != nil {
|
||||
- return fmt.Errorf("error getting copy progress %s", dst)
|
||||
+ return fmt.Errorf("error getting destination blob properties %s", dstBlobURL)
|
||||
}
|
||||
- copyStatus = *getMetadata.CopyStatus
|
||||
+ copyStatus = blobPropsResp.CopyStatus()
|
||||
|
||||
- _, err = blobLeaseClient.RenewLease(context.Background(), nil)
|
||||
+ _, err = srcBlobURL.RenewLease(context.Background(), srcBlobLeaseID, azblob.ModifiedAccessConditions{})
|
||||
if err != nil {
|
||||
- return fmt.Errorf("error renewing source blob lease %s", src)
|
||||
+ return fmt.Errorf("error renewing source blob lease %s", srcBlobURL)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("error copying %s -> %s in %s: %s", dst, src, storage, copyStatus)
|
||||
@@ -245,9 +243,7 @@ func (storage *PublishedStorage) RenameFile(oldName, newName string) error {
|
||||
|
||||
// SymLink creates a copy of src file and adds link information as meta data
|
||||
func (storage *PublishedStorage) SymLink(src string, dst string) error {
|
||||
- metadata := make(map[string]*string)
|
||||
- metadata["SymLink"] = &src
|
||||
- return storage.internalCopyOrMoveBlob(src, dst, metadata, false /* do not remove src */)
|
||||
+ return storage.internalCopyOrMoveBlob(src, dst, azblob.Metadata{"SymLink": src}, false /* move */)
|
||||
}
|
||||
|
||||
// HardLink using symlink functionality as hard links do not exist
|
||||
@@ -257,33 +253,28 @@ func (storage *PublishedStorage) HardLink(src string, dst string) error {
|
||||
|
||||
// FileExists returns true if path exists
|
||||
func (storage *PublishedStorage) FileExists(path string) (bool, error) {
|
||||
- serviceClient := storage.az.client.ServiceClient()
|
||||
- containerClient := serviceClient.NewContainerClient(storage.az.container)
|
||||
- blobClient := containerClient.NewBlobClient(path)
|
||||
- _, err := blobClient.GetProperties(context.Background(), nil)
|
||||
+ blob := storage.az.blobURL(path)
|
||||
+ resp, err := blob.GetProperties(context.Background(), azblob.BlobAccessConditions{}, azblob.ClientProvidedKeyOptions{})
|
||||
if err != nil {
|
||||
if isBlobNotFound(err) {
|
||||
return false, nil
|
||||
}
|
||||
- return false, fmt.Errorf("error checking if blob %s exists: %v", path, err)
|
||||
+ return false, err
|
||||
+ } else if resp.StatusCode() == http.StatusOK {
|
||||
+ return true, nil
|
||||
}
|
||||
- return true, nil
|
||||
+ return false, fmt.Errorf("error checking if blob %s exists %d", blob, resp.StatusCode())
|
||||
}
|
||||
|
||||
// ReadLink returns the symbolic link pointed to by path.
|
||||
// This simply reads text file created with SymLink
|
||||
func (storage *PublishedStorage) ReadLink(path string) (string, error) {
|
||||
- serviceClient := storage.az.client.ServiceClient()
|
||||
- containerClient := serviceClient.NewContainerClient(storage.az.container)
|
||||
- blobClient := containerClient.NewBlobClient(path)
|
||||
- props, err := blobClient.GetProperties(context.Background(), nil)
|
||||
+ blob := storage.az.blobURL(path)
|
||||
+ resp, err := blob.GetProperties(context.Background(), azblob.BlobAccessConditions{}, azblob.ClientProvidedKeyOptions{})
|
||||
if err != nil {
|
||||
- return "", fmt.Errorf("failed to get blob properties: %v", err)
|
||||
+ return "", err
|
||||
+ } else if resp.StatusCode() != http.StatusOK {
|
||||
+ return "", fmt.Errorf("error checking if blob %s exists %d", blob, resp.StatusCode())
|
||||
}
|
||||
-
|
||||
- metadata := props.Metadata
|
||||
- if originalBlob, exists := metadata["original_blob"]; exists {
|
||||
- return *originalBlob, nil
|
||||
- }
|
||||
- return "", fmt.Errorf("error reading link %s: %v", path, err)
|
||||
+ return resp.NewMetadata()["SymLink"], nil
|
||||
}
|
||||
diff --git a/azure/public_test.go b/azure/public_test.go
|
||||
index 5c912c5..f58ad51 100644
|
||||
--- a/azure/public_test.go
|
||||
+++ b/azure/public_test.go
|
||||
@@ -7,11 +7,8 @@
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
- "bytes"
|
||||
|
||||
- "github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
- "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
|
||||
- "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
|
||||
+ "github.com/Azure/azure-storage-blob-go/azblob"
|
||||
"github.com/aptly-dev/aptly/files"
|
||||
"github.com/aptly-dev/aptly/utils"
|
||||
. "gopkg.in/check.v1"
|
||||
@@ -69,10 +66,8 @@ func (s *PublishedStorageSuite) SetUpTest(c *C) {
|
||||
|
||||
s.storage, err = NewPublishedStorage(s.accountName, s.accountKey, container, "", s.endpoint)
|
||||
c.Assert(err, IsNil)
|
||||
- publicAccessType := azblob.PublicAccessTypeContainer
|
||||
- _, err = s.storage.az.client.CreateContainer(context.Background(), s.storage.az.container, &azblob.CreateContainerOptions{
|
||||
- Access: &publicAccessType,
|
||||
- })
|
||||
+ cnt := s.storage.az.container
|
||||
+ _, err = cnt.Create(context.Background(), azblob.Metadata{}, azblob.PublicAccessContainer)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
s.prefixedStorage, err = NewPublishedStorage(s.accountName, s.accountKey, container, prefix, s.endpoint)
|
||||
@@ -80,39 +75,41 @@ func (s *PublishedStorageSuite) SetUpTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *PublishedStorageSuite) TearDownTest(c *C) {
|
||||
- _, err := s.storage.az.client.DeleteContainer(context.Background(), s.storage.az.container, nil)
|
||||
+ cnt := s.storage.az.container
|
||||
+ _, err := cnt.Delete(context.Background(), azblob.ContainerAccessConditions{})
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
func (s *PublishedStorageSuite) GetFile(c *C, path string) []byte {
|
||||
- resp, err := s.storage.az.client.DownloadStream(context.Background(), s.storage.az.container, path, nil)
|
||||
+ blob := s.storage.az.container.NewBlobURL(path)
|
||||
+ resp, err := blob.Download(context.Background(), 0, azblob.CountToEnd, azblob.BlobAccessConditions{}, false, azblob.ClientProvidedKeyOptions{})
|
||||
c.Assert(err, IsNil)
|
||||
- data, err := io.ReadAll(resp.Body)
|
||||
+ body := resp.Body(azblob.RetryReaderOptions{MaxRetryRequests: 3})
|
||||
+ data, err := io.ReadAll(body)
|
||||
c.Assert(err, IsNil)
|
||||
return data
|
||||
}
|
||||
|
||||
func (s *PublishedStorageSuite) AssertNoFile(c *C, path string) {
|
||||
- serviceClient := s.storage.az.client.ServiceClient()
|
||||
- containerClient := serviceClient.NewContainerClient(s.storage.az.container)
|
||||
- blobClient := containerClient.NewBlobClient(path)
|
||||
- _, err := blobClient.GetProperties(context.Background(), nil)
|
||||
+ _, err := s.storage.az.container.NewBlobURL(path).GetProperties(
|
||||
+ context.Background(), azblob.BlobAccessConditions{}, azblob.ClientProvidedKeyOptions{})
|
||||
c.Assert(err, NotNil)
|
||||
-
|
||||
- storageError, ok := err.(*azcore.ResponseError)
|
||||
+ storageError, ok := err.(azblob.StorageError)
|
||||
c.Assert(ok, Equals, true)
|
||||
- c.Assert(storageError.StatusCode, Equals, 404)
|
||||
+ c.Assert(string(storageError.ServiceCode()), Equals, string(string(azblob.StorageErrorCodeBlobNotFound)))
|
||||
}
|
||||
|
||||
func (s *PublishedStorageSuite) PutFile(c *C, path string, data []byte) {
|
||||
hash := md5.Sum(data)
|
||||
- uploadOptions := &azblob.UploadStreamOptions{
|
||||
- HTTPHeaders: &blob.HTTPHeaders{
|
||||
- BlobContentMD5: hash[:],
|
||||
- },
|
||||
- }
|
||||
- reader := bytes.NewReader(data)
|
||||
- _, err := s.storage.az.client.UploadStream(context.Background(), s.storage.az.container, path, reader, uploadOptions)
|
||||
+ _, err := azblob.UploadBufferToBlockBlob(
|
||||
+ context.Background(),
|
||||
+ data,
|
||||
+ s.storage.az.container.NewBlockBlobURL(path),
|
||||
+ azblob.UploadToBlockBlobOptions{
|
||||
+ BlobHTTPHeaders: azblob.BlobHTTPHeaders{
|
||||
+ ContentMD5: hash[:],
|
||||
+ },
|
||||
+ })
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
@@ -333,7 +330,7 @@ func (s *PublishedStorageSuite) TestLinkFromPool(c *C) {
|
||||
|
||||
// 2nd link from pool, providing wrong path for source file
|
||||
//
|
||||
- // this test should check that file already exists in Azure and skip upload (which would fail if not skipped)
|
||||
+ // this test should check that file already exists in S3 and skip upload (which would fail if not skipped)
|
||||
s.prefixedStorage.pathCache = nil
|
||||
err = s.prefixedStorage.LinkFromPool("", filepath.Join("pool", "main", "m/mars-invaders"), "mars-invaders_1.03.deb", pool, "wrong-looks-like-pathcache-doesnt-work", cksum1, false)
|
||||
c.Check(err, IsNil)
|
||||
diff --git a/context/context.go b/context/context.go
|
||||
index 0ffc3f7..503cad2 100644
|
||||
--- a/context/context.go
|
||||
+++ b/context/context.go
|
||||
@@ -100,6 +100,7 @@ func (context *AptlyContext) config() *utils.ConfigStructure {
|
||||
configLocations := []string{homeLocation, "/usr/local/etc/aptly.conf", "/etc/aptly.conf"}
|
||||
|
||||
for _, configLocation := range configLocations {
|
||||
+ // FIXME: check if exists, check if readable
|
||||
err = utils.LoadConfig(configLocation, &utils.Config)
|
||||
if os.IsPermission(err) || os.IsNotExist(err) {
|
||||
continue
|
||||
diff --git a/deb/list.go b/deb/list.go
|
||||
index 25a2d28..9eda528 100644
|
||||
--- a/deb/list.go
|
||||
+++ b/deb/list.go
|
||||
@@ -598,6 +598,7 @@ func (l *PackageList) Filter(options FilterOptions) (*PackageList, error) {
|
||||
//
|
||||
// when follow-all-variants is enabled, we need to try to expand anyway,
|
||||
// as even if dependency is satisfied now, there might be other ways to satisfy dependency
|
||||
+ // FIXME: do not search twice
|
||||
if result.Search(dep, false, true) != nil {
|
||||
if options.DependencyOptions&DepVerboseResolve == DepVerboseResolve && options.Progress != nil {
|
||||
options.Progress.ColoredPrintf("@{y}Already satisfied dependency@|: %s with %s", &dep, result.Search(dep, true, true))
|
||||
diff --git a/go.mod b/go.mod
|
||||
index 53c5e78..d7f145a 100644
|
||||
--- a/go.mod
|
||||
+++ b/go.mod
|
||||
@@ -4,6 +4,7 @@ go 1.24
|
||||
|
||||
require (
|
||||
github.com/AlekSi/pointer v1.1.0
|
||||
+ github.com/Azure/azure-storage-blob-go v0.15.0
|
||||
github.com/DisposaBoy/JsonConfigReader v0.0.0-20171218180944-5ea4d0ddac55
|
||||
github.com/awalterschulze/gographviz v2.0.1+incompatible
|
||||
github.com/cavaliergopher/grab/v3 v3.0.1
|
||||
@@ -41,7 +42,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
- github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
|
||||
+ github.com/Azure/azure-pipeline-go v0.2.3 // indirect
|
||||
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||
@@ -87,6 +88,7 @@ require (
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/leodido/go-urn v1.2.4 // indirect
|
||||
github.com/mailru/easyjson v0.7.6 // indirect
|
||||
+ github.com/mattn/go-ieproxy v0.0.9 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
@@ -96,7 +98,7 @@ require (
|
||||
github.com/prometheus/common v0.59.1 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
- github.com/rogpeppe/go-internal v1.12.0 // indirect
|
||||
+ github.com/rogpeppe/go-internal v1.10.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.15 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.15 // indirect
|
||||
@@ -115,8 +117,6 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
- github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0
|
||||
- github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.4.1
|
||||
github.com/ProtonMail/go-crypto v1.0.0
|
||||
github.com/aws/aws-sdk-go-v2 v1.32.5
|
||||
github.com/aws/aws-sdk-go-v2/config v1.28.5
|
||||
diff --git a/go.sum b/go.sum
|
||||
index 502f4b2..453a288 100644
|
||||
--- a/go.sum
|
||||
+++ b/go.sum
|
||||
@@ -1,17 +1,20 @@
|
||||
github.com/AlekSi/pointer v1.1.0 h1:SSDMPcXD9jSl8FPy9cRzoRaMJtm9g9ggGTxecRUbQoI=
|
||||
github.com/AlekSi/pointer v1.1.0/go.mod h1:y7BvfRI3wXPWKXEBhU71nbnIEEZX0QTSB2Bj48UJIZE=
|
||||
-github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 h1:nyQWyZvwGTvunIMxi1Y9uXkcyr+I7TeNrr/foo4Kpk8=
|
||||
-github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0=
|
||||
-github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc=
|
||||
-github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg=
|
||||
-github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY=
|
||||
-github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY=
|
||||
-github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.6.0 h1:PiSrjRPpkQNjrM8H0WwKMnZUdu1RGMtd/LdGKUrOo+c=
|
||||
-github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.6.0/go.mod h1:oDrbWx4ewMylP7xHivfgixbfGBT6APAwsSoHRKotnIc=
|
||||
-github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.4.1 h1:cf+OIKbkmMHBaC3u78AXomweqM0oxQSgBXRZf3WH4yM=
|
||||
-github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.4.1/go.mod h1:ap1dmS6vQKJxSMNiGJcq4QuUQkOynyD93gLw6MDF7ek=
|
||||
-github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU=
|
||||
-github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
|
||||
+github.com/Azure/azure-pipeline-go v0.2.3 h1:7U9HBg1JFK3jHl5qmo4CTZKFTVgMwdFHMVtCdfBE21U=
|
||||
+github.com/Azure/azure-pipeline-go v0.2.3/go.mod h1:x841ezTBIMG6O3lAcl8ATHnsOPVl2bqk7S3ta6S6u4k=
|
||||
+github.com/Azure/azure-storage-blob-go v0.15.0 h1:rXtgp8tN1p29GvpGgfJetavIG0V7OgcSXPpwp3tx6qk=
|
||||
+github.com/Azure/azure-storage-blob-go v0.15.0/go.mod h1:vbjsVbX0dlxnRc4FFMPsS9BsJWPcne7GB7onqlPvz58=
|
||||
+github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs=
|
||||
+github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
|
||||
+github.com/Azure/go-autorest/autorest/adal v0.9.13 h1:Mp5hbtOePIzM8pJVRa3YLrWWmZtoxRXqUEzCfJt3+/Q=
|
||||
+github.com/Azure/go-autorest/autorest/adal v0.9.13/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M=
|
||||
+github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw=
|
||||
+github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74=
|
||||
+github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k=
|
||||
+github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+ZtXWSmf4Tg=
|
||||
+github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8=
|
||||
+github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo=
|
||||
+github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU=
|
||||
github.com/DisposaBoy/JsonConfigReader v0.0.0-20171218180944-5ea4d0ddac55 h1:jbGlDKdzAZ92NzK65hUP98ri0/r50vVVvmZsFP/nIqo=
|
||||
github.com/DisposaBoy/JsonConfigReader v0.0.0-20171218180944-5ea4d0ddac55/go.mod h1:GCzqZQHydohgVLSIqRKZeTt8IGb1Y4NaFfim3H40uUI=
|
||||
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
||||
@@ -91,6 +94,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
|
||||
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
|
||||
+github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk=
|
||||
+github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
|
||||
@@ -127,8 +132,6 @@ github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
-github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
||||
-github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
@@ -149,7 +152,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
-github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
+github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
+github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg=
|
||||
@@ -197,6 +201,9 @@ github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
+github.com/mattn/go-ieproxy v0.0.1/go.mod h1:pYabZ6IHcRpFh7vIaLfK7rdcWgFEb3SFJ6/gNWuh88E=
|
||||
+github.com/mattn/go-ieproxy v0.0.9 h1:RvVbLiMv/Hbjf1gRaC2AQyzwbdVhdId7D2vPnXIml4k=
|
||||
+github.com/mattn/go-ieproxy v0.0.9/go.mod h1:eF30/rfdQUO9EnzNIZQr0r9HiLMlZNCpJkHbmMuOAE0=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
@@ -235,8 +242,6 @@ github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
|
||||
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
|
||||
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
|
||||
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
|
||||
-github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
-github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
@@ -254,8 +259,8 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
-github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
|
||||
-github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
||||
+github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||
+github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc=
|
||||
github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU=
|
||||
@@ -319,6 +324,8 @@ golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
+golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
+golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||
@@ -333,14 +340,14 @@ golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
+golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
|
||||
-golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
-golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
-golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
+golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
+golang.org/x/net v0.0.0-20220630215102-69896b714898/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
@@ -362,6 +369,7 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
+golang.org/x/sys v0.0.0-20191112214154-59a1497f0cea/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
From: =?utf-8?q?S=C3=A9bastien_Delafond?= <seb@debian.org>
|
||||
Date: Mon, 17 Feb 2025 10:11:55 +0100
|
||||
Subject: tests: no upstream's etcd install as it's arch-specific,
|
||||
and no swagger-related or modules tasks
|
||||
|
||||
Forwarded: not-needed
|
||||
---
|
||||
Makefile | 11 +++--------
|
||||
1 file changed, 3 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index ffe2e8a..91f96a8 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -89,17 +89,12 @@ install:
|
||||
# go install -v
|
||||
@out=`mktemp`; if ! go install -v > $$out 2>&1; then cat $$out; rm -f $$out; echo "\nBuild failed\n"; exit 1; else rm -f $$out; fi
|
||||
|
||||
-test: prepare swagger etcd-install ## Run unit tests (add TEST=regex to specify which tests to run)
|
||||
- @echo "\e[33m\e[1mStarting etcd ...\e[0m"
|
||||
- @mkdir -p /tmp/aptly-etcd-data; system/t13_etcd/start-etcd.sh > /tmp/aptly-etcd-data/etcd.log 2>&1 &
|
||||
+test: ## Run unit tests
|
||||
@echo "\e[33m\e[1mRunning go test ...\e[0m"
|
||||
- faketime "$(TEST_FAKETIME)" go test -v ./... -gocheck.v=true -check.f "$(TEST)" -coverprofile=unit.out; echo $$? > .unit-test.ret
|
||||
- @echo "\e[33m\e[1mStopping etcd ...\e[0m"
|
||||
- @pid=`cat /tmp/etcd.pid`; kill $$pid
|
||||
- @rm -f /tmp/aptly-etcd-data/etcd.log
|
||||
+ go test -v ./... -gocheck.v=true -coverprofile=unit.out; echo $$? > .unit-test.ret
|
||||
@ret=`cat .unit-test.ret`; if [ "$$ret" = "0" ]; then echo "\n\e[32m\e[1mUnit Tests SUCCESSFUL\e[0m"; else echo "\n\e[31m\e[1mUnit Tests FAILED\e[0m"; fi; rm -f .unit-test.ret; exit $$ret
|
||||
|
||||
-system-test: prepare swagger etcd-install ## Run system tests
|
||||
+system-test: ## Run system tests
|
||||
# build coverage binary
|
||||
go test -v -coverpkg="./..." -c -tags testruncli
|
||||
# Download fixture-db, fixture-pool, etcd.db
|
||||
@@ -0,0 +1,40 @@
|
||||
From: =?utf-8?q?S=C3=A9bastien_Delafond?= <seb@debian.org>
|
||||
Date: Wed, 24 Sep 2025 07:23:24 +0200
|
||||
Subject: Revert "system-tests: abort on failure"
|
||||
|
||||
We'd rather have the test suite always run completely, and report
|
||||
every failed test at the end.
|
||||
|
||||
Forwarded: not-needed
|
||||
---
|
||||
system/run.py | 8 --------
|
||||
1 file changed, 8 deletions(-)
|
||||
|
||||
diff --git a/system/run.py b/system/run.py
|
||||
index 4e73fb2..599afe5 100755
|
||||
--- a/system/run.py
|
||||
+++ b/system/run.py
|
||||
@@ -50,7 +50,6 @@ def run(include_long_tests=False, capture_results=False, tests=None, filters=Non
|
||||
if not coverage_dir:
|
||||
coverage_dir = mkdtemp(suffix="aptly-coverage")
|
||||
|
||||
- failed = False
|
||||
for test in tests:
|
||||
orig_stdout = sys.stdout
|
||||
orig_stderr = sys.stderr
|
||||
@@ -158,15 +157,8 @@ def run(include_long_tests=False, capture_results=False, tests=None, filters=Non
|
||||
|
||||
t.shutdown()
|
||||
|
||||
- if failed:
|
||||
- break
|
||||
- if failed:
|
||||
- break
|
||||
-
|
||||
sys.stdout = orig_stdout
|
||||
sys.stderr = orig_stderr
|
||||
- if failed:
|
||||
- break
|
||||
|
||||
if lastBase is not None:
|
||||
lastBase.shutdown_class()
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
0001-disable-swagger.patch
|
||||
0002-disable-new-azure-sdk.patch
|
||||
0003-tests-no-upstream-s-etcd-install-as-it-s-arch-specif.patch
|
||||
0004-Revert-system-tests-abort-on-failure.patch
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user