Skip to content

Commit

Permalink
fix: resize partition
Browse files Browse the repository at this point in the history
Resize function checks free space and grow it to the next partition.

Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
sergelogvinov authored and smira committed Nov 15, 2021
1 parent 70d2865 commit b9517d5
Show file tree
Hide file tree
Showing 24 changed files with 288 additions and 93 deletions.
20 changes: 10 additions & 10 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2020-09-04T03:46:02Z by kres latest.
# Generated on 2021-11-15T13:22:12Z by kres c4d092b.

codecov:
require_ci_to_pass: false
require_ci_to_pass: false

coverage:
status:
project:
default:
target: 50%
threshold: 0.5%
base: auto
if_ci_failed: success
patch: off
status:
project:
default:
target: 50%
threshold: 0.5%
base: auto
if_ci_failed: success
patch: off

comment: false
17 changes: 10 additions & 7 deletions .conform.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2020-09-08T22:09:46Z by kres latest.
# Generated on 2021-11-15T13:22:12Z by kres c4d092b.

---
policies:
- type: commit
spec:
dco: true
gpg: false
gpg:
required: true
identity:
gitHubOrganization: talos-systems
spellcheck:
locale: US
maximumOfOneCommit: true
Expand All @@ -19,16 +23,15 @@ policies:
required: true
conventional:
types: ["chore","docs","perf","refactor","style","test","release"]
scopes: ["*"]
scopes: [".*"]
- type: license
spec:
skipPaths:
- .git/
- testdata/
includeSuffixes:
- .go
excludeSuffixes:
- .pb.go
header: |
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
- .pb.gw.go
header: "// This Source Code Form is subject to the terms of the Mozilla Public\u000A// License, v. 2.0. If a copy of the MPL was not distributed with this\u000A// file, You can obtain one at http://mozilla.org/MPL/2.0/.\u000A"
56 changes: 53 additions & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2020-10-23T19:31:03Z by kres e82c767-dirty.
# Generated on 2021-11-15T13:28:14Z by kres c4d092b.

kind: pipeline
type: kubernetes
Expand All @@ -19,7 +19,7 @@ steps:
- sleep 5
- git fetch --tags
- install-ci-key
- docker buildx create --driver docker-container --platform linux/amd64 --name local-insecure --buildkitd-flags '--allow-insecure-entitlement security.insecure' --use unix:///var/outer-run/docker.sock
- docker buildx create --driver docker-container --platform linux/amd64 --name local-insecure-v2 --buildkitd-flags '--allow-insecure-entitlement security.insecure' --driver-opt image=ghcr.io/smira/buildkit:cap-fix --use unix:///var/outer-run/docker.sock
- docker buildx inspect --bootstrap
environment:
SSH_KEY:
Expand Down Expand Up @@ -122,9 +122,59 @@ steps:
depends_on:
- base

- name: release-notes
pull: always
image: autonomy/build-container:latest
commands:
- make release-notes
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
when:
event:
- tag
depends_on:
- unit-tests
- coverage
- lint

- name: release
pull: always
image: plugins/github-release
settings:
api_key:
from_secret: github_token
checksum:
- sha256
- sha512
draft: true
files:
- _out/*
note: _out/RELEASE_NOTES.md
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
when:
event:
- tag
depends_on:
- release-notes

services:
- name: docker
image: docker:19.03-dind
image: ghcr.io/smira/docker:20.10-dind-hacked
entrypoint:
- dockerd
commands:
Expand Down
37 changes: 21 additions & 16 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2021-01-21T16:47:42Z by kres latest.

# Generated on 2021-11-15T13:22:12Z by kres c4d092b.

# options for analysis running
run:
Expand All @@ -22,7 +21,6 @@ output:
uniq-by-line: true
path-prefix: ""


# all available settings of specific linters
linters-settings:
dogsled:
Expand Down Expand Up @@ -75,8 +73,6 @@ linters-settings:
lll:
line-length: 200
tab-width: 4
maligned:
suggest-new: true
misspell:
locale: US
ignore-words: []
Expand All @@ -93,7 +89,7 @@ linters-settings:
require-explanation: false
require-specific: true
rowserrcheck: {}
testpackage:
testpackage: {}
unparam:
check-exported: false
unused:
Expand All @@ -112,25 +108,36 @@ linters-settings:
allow-separated-leading-comment: false
gofumpt:
extra-rules: false
cyclop:
# the maximal code complexity to report
max-complexity: 20

linters:
enable-all: true
disable-all: false
fast: false
disable:
- exhaustivestruct
- forbidigo
- funlen
- gas
- typecheck
- gochecknoglobals
- gochecknoinits
- funlen
- godox
- gomnd
- goerr113
- gomnd
- gomoddirectives
- nestif
- wrapcheck
- paralleltest
- exhaustivestruct
disable-all: false
fast: false

- tagliatelle
- thelper
- typecheck
- wrapcheck
# abandoned linters for which golangci shows the warning that the repo is archived by the owner
- interfacer
- maligned
- golint
- scopelint

issues:
exclude: []
Expand All @@ -139,10 +146,8 @@ issues:
exclude-case-sensitive: false
max-issues-per-linter: 10
max-same-issues: 3

new: false

severity:
default-severity: error

case-sensitive: false
18 changes: 10 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,34 @@

# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2021-01-21T16:47:42Z by kres latest.
# Generated on 2021-11-15T13:22:12Z by kres c4d092b.

ARG TOOLCHAIN

# cleaned up specs and compiled versions
FROM scratch AS generate

# runs markdownlint
FROM node:14.8.0-alpine AS lint-markdown
RUN npm i -g markdownlint-cli@0.23.2
RUN npm i sentences-per-line@0.2.1
WORKDIR /src
COPY .markdownlint.json .
COPY ./README.md ./README.md
RUN markdownlint --ignore "**/node_modules/**" --ignore '**/hack/chglog/**' --rules /node_modules/sentences-per-line/index.js .
RUN markdownlint --ignore "CHANGELOG.md" --ignore "**/node_modules/**" --ignore '**/hack/chglog/**' --rules /node_modules/sentences-per-line/index.js .

# base toolchain image
FROM ${TOOLCHAIN} AS toolchain
RUN apk --update --no-cache add bash curl build-base dosfstools
RUN apk --update --no-cache add bash curl build-base protoc protobuf-dev

# build tools
FROM toolchain AS tools
ENV GO111MODULE on
ENV CGO_ENABLED 0
ENV GOPATH /go
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b /bin v1.33.0
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b /bin v1.42.1
ARG GOFUMPT_VERSION
RUN cd $(mktemp -d) \
&& go mod init tmp \
&& go get mvdan.cc/gofumpt/gofumports@${GOFUMPT_VERSION} \
RUN go install mvdan.cc/gofumpt/gofumports@${GOFUMPT_VERSION} \
&& mv /go/bin/gofumports /bin/gofumports

# tools and sources
Expand All @@ -44,6 +45,7 @@ RUN --mount=type=cache,target=/go/pkg go list -mod=readonly all >/dev/null
# runs gofumpt
FROM base AS lint-gofumpt
RUN find . -name '*.pb.go' | xargs -r rm
RUN find . -name '*.pb.gw.go' | xargs -r rm
RUN FILES="$(gofumports -l -local github.com/talos-systems/go-blockdevice .)" && test -z "${FILES}" || (echo -e "Source code is not formatted with 'gofumports -w -local github.com/talos-systems/go-blockdevice .':\n${FILES}"; exit 1)

# runs golangci-lint
Expand All @@ -60,7 +62,7 @@ RUN --security=insecure --mount=type=cache,target=/root/.cache/go-build --mount=
# runs unit-tests
FROM base AS unit-tests-run
ARG TESTPKGS
RUN --security=insecure --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp go test -v -covermode=atomic -coverprofile=coverage.txt -count 1 ${TESTPKGS}
RUN --security=insecure --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp go test -v -covermode=atomic -coverprofile=coverage.txt -coverpkg=${TESTPKGS} -count 1 ${TESTPKGS}

FROM scratch AS unit-tests
COPY --from=unit-tests-run /src/coverage.txt /coverage.txt
Expand Down
23 changes: 18 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2020-10-23T19:30:04Z by kres e82c767-dirty.
# Generated on 2021-11-15T13:22:12Z by kres c4d092b.

# common variables

Expand All @@ -12,7 +12,11 @@ REGISTRY ?= ghcr.io
USERNAME ?= talos-systems
REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME)
GOFUMPT_VERSION ?= abc0db2c416aca0f60ea33c23c76665f6e7ba0b6
GO_VERSION ?= 1.14
GO_VERSION ?= 1.17
PROTOBUF_GO_VERSION ?= 1.27.1
GRPC_GO_VERSION ?= 1.1.0
GRPC_GATEWAY_VERSION ?= 2.4.0
VTPROTOBUF_VERSION ?= 81d623a9a700ede8ef765e5ab08b3aa1f5b4d5a8
TESTPKGS ?= ./...
KRES_IMAGE ?= ghcr.io/talos-systems/kres:latest

Expand All @@ -33,8 +37,12 @@ COMMON_ARGS += --build-arg=TAG=$(TAG)
COMMON_ARGS += --build-arg=USERNAME=$(USERNAME)
COMMON_ARGS += --build-arg=TOOLCHAIN=$(TOOLCHAIN)
COMMON_ARGS += --build-arg=GOFUMPT_VERSION=$(GOFUMPT_VERSION)
COMMON_ARGS += --build-arg=PROTOBUF_GO_VERSION=$(PROTOBUF_GO_VERSION)
COMMON_ARGS += --build-arg=GRPC_GO_VERSION=$(GRPC_GO_VERSION)
COMMON_ARGS += --build-arg=GRPC_GATEWAY_VERSION=$(GRPC_GATEWAY_VERSION)
COMMON_ARGS += --build-arg=VTPROTOBUF_VERSION=$(VTPROTOBUF_VERSION)
COMMON_ARGS += --build-arg=TESTPKGS=$(TESTPKGS)
TOOLCHAIN ?= docker.io/golang:1.15-alpine
TOOLCHAIN ?= docker.io/golang:1.17-alpine

# help menu

Expand Down Expand Up @@ -91,8 +99,8 @@ lint-gofumpt: ## Runs gofumpt linter.
fmt: ## Formats the source code
@docker run --rm -it -v $(PWD):/src -w /src golang:$(GO_VERSION) \
bash -c "export GO111MODULE=on; export GOPROXY=https://proxy.golang.org; \
cd /tmp && go mod init tmp && go get mvdan.cc/gofumpt/gofumports@$(GOFUMPT_VERSION) && \
cd - && gofumports -w -local github.com/talos-systems/go-blockdevice ."
go install mvdan.cc/gofumpt/gofumports@$(GOFUMPT_VERSION) && \
gofumports -w -local github.com/talos-systems/go-blockdevice ."

.PHONY: base
base: ## Prepare base toolchain
Expand Down Expand Up @@ -127,3 +135,8 @@ help: ## This help menu.
@echo "$$HELP_MENU_HEADER"
@grep -E '^[a-zA-Z%_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: release-notes
release-notes:
mkdir -p $(ARTIFACTS)
@ARTIFACTS=$(ARTIFACTS) ./hack/release.sh $@ $(ARTIFACTS)/RELEASE_NOTES.md $(TAG)

8 changes: 4 additions & 4 deletions blockdevice/encryption/luks/luks.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ func (l *LUKS) Close(devname string) error {
func (l *LUKS) AddKey(devname string, key, newKey *encryption.Key) error {
var buffer bytes.Buffer

keyfileLen, _ := buffer.Write(key.Value) //nolint:errcheck
buffer.Write(newKey.Value) //nolint:errcheck
keyfileLen, _ := buffer.Write(key.Value)
buffer.Write(newKey.Value)

args := []string{
"luksAddKey",
Expand All @@ -206,8 +206,8 @@ func (l *LUKS) SetKey(devname string, oldKey, newKey *encryption.Key) error {

var buffer bytes.Buffer

keyfileLen, _ := buffer.Write(oldKey.Value) //nolint:errcheck
buffer.Write(newKey.Value) //nolint:errcheck
keyfileLen, _ := buffer.Write(oldKey.Value)
buffer.Write(newKey.Value)

args := []string{
"luksChangeKey",
Expand Down
4 changes: 2 additions & 2 deletions blockdevice/encryption/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ type Provider interface {
}

// ErrEncryptionKeyRejected triggered when encryption key does not match.
var ErrEncryptionKeyRejected error = fmt.Errorf("encryption key rejected")
var ErrEncryptionKeyRejected = fmt.Errorf("encryption key rejected")

// ErrDeviceBusy returned when mapped device is still in use.
var ErrDeviceBusy error = fmt.Errorf("mapped device is still in use")
var ErrDeviceBusy = fmt.Errorf("mapped device is still in use")

// Keyslots represents LUKS2 keyslots metadata.
type Keyslots struct {
Expand Down
3 changes: 1 addition & 2 deletions blockdevice/filesystem/iso9660/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
package iso9660

// Options is the functional options struct.
type Options struct {
}
type Options struct{}

// Option is the functional option func.
type Option func(*Options)
Expand Down

0 comments on commit b9517d5

Please sign in to comment.