From 0422b9ecbef69bd6e5c96f7cc7ae22ed1d11d367 Mon Sep 17 00:00:00 2001 From: Danny Date: Tue, 19 Jul 2022 17:28:23 -0400 Subject: [PATCH] Restore Policy options added (#350) * Issue #349: Added policy for restore to code base. Policy Items are placed in the `internal/common` directory --- .github/workflows/lint.yml | 19 +++++++++++++++ src/internal/common/policy.go | 12 ++++++++++ src/internal/common/restorepolicy_string.go | 26 +++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/internal/common/policy.go create mode 100644 src/internal/common/restorepolicy_string.go diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b8f417c1c..395887873 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,9 +21,28 @@ jobs: with: go-version: 1.18 + - name: Cache Go build + uses: actions/cache@v3 + id: mybuild + with: + path: ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum')}} + + - name: Cache Go Mod + uses: actions/cache@v3 + id: cache + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-mod${{ hashFiles('**/go.sum')}} + - name: Download package dependencies + if: steps.cache.outputs.cache-hit != 'true' run: go mod download + - name: Build for Lint + if: steps.mybuild.outputs.cache-hit != 'true' + run: go build ./... + - name: Go Lint uses: golangci/golangci-lint-action@v3.2.0 with: diff --git a/src/internal/common/policy.go b/src/internal/common/policy.go new file mode 100644 index 000000000..066fb93b2 --- /dev/null +++ b/src/internal/common/policy.go @@ -0,0 +1,12 @@ +package common + +// Policy is a type that defines the actions taken +type RestorePolicy int + +//go:generate stringer -type=RestorePolicy +const ( + Unknown RestorePolicy = iota + Copy + Drop + Replace +) diff --git a/src/internal/common/restorepolicy_string.go b/src/internal/common/restorepolicy_string.go new file mode 100644 index 000000000..7786d224a --- /dev/null +++ b/src/internal/common/restorepolicy_string.go @@ -0,0 +1,26 @@ +// Code generated by "stringer -type=RestorePolicy"; DO NOT EDIT. + +package common + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Unknown-0] + _ = x[Copy-1] + _ = x[Drop-2] + _ = x[Replace-3] +} + +const _RestorePolicy_name = "UnknownCopyDropReplace" + +var _RestorePolicy_index = [...]uint8{0, 7, 11, 15, 22} + +func (i RestorePolicy) String() string { + if i < 0 || i >= RestorePolicy(len(_RestorePolicy_index)-1) { + return "RestorePolicy(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _RestorePolicy_name[_RestorePolicy_index[i]:_RestorePolicy_index[i+1]] +}