Skip to content

Commit cf978ec

Browse files
authored
STAC-23483: Restoring Elasticsearch (#1)
* STAC-23483: Restoring Elasticsearch
1 parent 1fc04ae commit cf978ec

39 files changed

Lines changed: 6209 additions & 0 deletions

.github/actions/quay/action.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: 'Run command in Quay image'
2+
description: 'Run a command in a quay.io container'
3+
inputs:
4+
image:
5+
description: 'Image'
6+
required: true
7+
options:
8+
description: 'Options for the container'
9+
required: false
10+
run:
11+
description: 'Args for the container entrypoint'
12+
required: false
13+
entrypoint:
14+
description: 'Container entrypoint to use'
15+
required: false
16+
runs:
17+
using: 'composite'
18+
steps:
19+
- name: Log in to the Container registry
20+
uses: docker/login-action@v3
21+
with:
22+
registry: quay.io
23+
username: ${{ env.QUAY_USER }}
24+
password: ${{ env.QUAY_PASSWORD }}
25+
- name: Run command
26+
shell: bash
27+
run: |
28+
export ENTRYPOINT='${{ inputs.entrypoint }}'
29+
export COMMAND='${{ inputs.run }}'
30+
export COMMAND_PREFIX=''
31+
32+
# Prep for a shell script.
33+
if [[ $ENTRYPOINT == '' ]]; then
34+
ENTRYPOINT='sh'
35+
COMMAND_PREFIX='-c'
36+
COMMAND=$(echo "$COMMAND" | sed -r '/^\s*$/d')
37+
COMMAND=${COMMAND//$'\n'/ ; }
38+
fi
39+
40+
# Strip newlines in options.
41+
export OPTIONS='${{ inputs.options }}'
42+
OPTIONS=${OPTIONS//$'\n'/ }
43+
44+
# Sanitize the image name.
45+
export IMAGE='${{ inputs.image }}'
46+
IMAGE=${IMAGE//$'\n'/}
47+
48+
# Prep the workspace.
49+
export WORKSPACE='${{ github.workspace }}'
50+
WORKSPACE=${WORKSPACE//$'\n'/}
51+
52+
# Prep volumes.
53+
export VOLUMES="-v /var/run/docker.sock:/var/run/docker.sock -v $WORKSPACE:/workspace"
54+
55+
# Run the command in docker.
56+
if [[ $COMMAND == *\;* ]]; then
57+
docker run $VOLUMES $OPTIONS --entrypoint=$ENTRYPOINT $IMAGE $COMMAND_PREFIX "$COMMAND"
58+
else
59+
docker run $VOLUMES $OPTIONS --entrypoint=$ENTRYPOINT $IMAGE $COMMAND_PREFIX $COMMAND
60+
fi

.github/workflows/ci.yml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
push:
7+
branches:
8+
- main
9+
tags:
10+
- v*
11+
12+
# Allows to run this via the Actions tab
13+
workflow_dispatch:
14+
15+
env:
16+
REGISTRY: quay.io
17+
18+
jobs:
19+
lint:
20+
permissions:
21+
# Required: allow read access to the content for analysis.
22+
contents: read
23+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
24+
pull-requests: read
25+
# Optional: Allow write access to checks to allow the action to annotate code in the PR.
26+
checks: write
27+
name: Linter
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 10
30+
steps:
31+
- uses: actions/checkout@v5
32+
- uses: actions/setup-go@v5
33+
with:
34+
go-version: "1.25.x"
35+
cache: false
36+
- name: golangci-lint
37+
uses: golangci/golangci-lint-action@v8
38+
with:
39+
# Require: The version of golangci-lint to use.
40+
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
41+
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
42+
version: v2.5.0
43+
44+
check-license:
45+
name: License scan
46+
runs-on: ubuntu-latest
47+
timeout-minutes: 5
48+
env:
49+
REPORT_FILE: gl-license-scanning-report.json
50+
51+
steps:
52+
- uses: actions/checkout@v4
53+
- uses: actions/setup-go@v5
54+
with:
55+
go-version: "1.25.x"
56+
- name: License scanning
57+
run: |
58+
go install github.com/google/go-licenses@latest
59+
go-licenses check . --disallowed_types=forbidden,restricted
60+
- name: Generate license report
61+
run: |
62+
go-licenses report . > licenses.csv
63+
- name: Save license scan report
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: license_scanning
67+
path: licenses.csv
68+
69+
check-go-releaser:
70+
name: Go releaser check
71+
runs-on: ubuntu-latest
72+
timeout-minutes: 5
73+
74+
steps:
75+
- uses: actions/checkout@v4
76+
- uses: actions/setup-go@v5
77+
with:
78+
go-version: "1.25.x"
79+
- name: Run GoReleaser
80+
uses: goreleaser/goreleaser-action@v5
81+
with:
82+
# either 'goreleaser' (default) or 'goreleaser-pro'
83+
distribution: goreleaser
84+
# 'latest', 'nightly', or a semver
85+
version: v1.25.1
86+
args: check
87+
88+
test:
89+
name: Tests
90+
needs:
91+
- lint
92+
runs-on: ubuntu-latest
93+
timeout-minutes: 10
94+
95+
steps:
96+
- uses: actions/checkout@v4
97+
- uses: actions/setup-go@v5
98+
with:
99+
go-version: "1.25.x"
100+
- name: Run tests
101+
run: go test -v ./...
102+
103+
publish:
104+
name: Publish the release
105+
if: ${{ github.ref_type == 'tag' }}
106+
needs:
107+
- test
108+
runs-on: ubuntu-latest
109+
timeout-minutes: 15
110+
env:
111+
TAG: ${{ github.ref_name }}
112+
S3_BUCKET: "s3://cli-dl.stackstate.com/stackstate-backup-cli/"
113+
QUAY_USER: ${{ secrets.QUAY_USER }}
114+
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
115+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
steps:
117+
- uses: actions/checkout@v4
118+
- uses: actions/setup-go@v5
119+
with:
120+
go-version: "1.25.x"
121+
- name: Log in to the Container registry
122+
uses: docker/login-action@v3
123+
if: github.event_name != 'pull_request'
124+
with:
125+
registry: quay.io
126+
username: ${{ secrets.QUAY_USER }}
127+
password: ${{ secrets.QUAY_PASSWORD }}
128+
- name: Log in to the Container registry
129+
uses: docker/login-action@v3
130+
if: github.event_name != 'pull_request'
131+
with:
132+
registry: docker.io
133+
username: ${{ secrets.DOCKER_USER }}
134+
password: ${{ secrets.DOCKER_PASSWORD }}
135+
- name: Go releaser publish
136+
uses: goreleaser/goreleaser-action@v5
137+
env:
138+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
140+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
141+
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
142+
with:
143+
# either 'goreleaser' (default) or 'goreleaser-pro'
144+
distribution: goreleaser
145+
# 'latest', 'nightly', or a semver
146+
version: v1.25.1
147+
args: release
148+
- name: Write latest version to file
149+
run: mkdir -p dist && echo "${{ env.TAG }}" > dist/LATEST_VERSION
150+
151+
- name: Authenticate with AWS
152+
uses: aws-actions/configure-aws-credentials@v4
153+
with:
154+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
155+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
156+
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
157+
158+
- name: Publish latest version to S3
159+
run: |
160+
echo "aws s3 cp dist/LATEST_VERSION ${{ env.S3_BUCKET }}"
161+
aws s3 cp dist/LATEST_VERSION ${{ env.S3_BUCKET }}
162+
163+
- name: Publish installers to S3
164+
run: |
165+
echo "aws s3 cp scripts/publish/installers/ ${{ env.S3_BUCKET }} --recursive"
166+
aws s3 cp scripts/publish/installers/ ${{ env.S3_BUCKET }} --recursive

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
bin/
2+
dist/
3+
.idea/
4+
sts-backup
5+
stackstate-backup-cli
6+
7+
sts-toolbox.yaml
8+
values.yaml
9+
10+
.vscode/launch.json
11+
12+
__debug_bin
13+
14+
pkged.go
15+
vendor/
16+
result
17+
18+
*.swp
19+
20+
.go/
21+
.gocache/
22+
release-notes.md
23+
release-notes.json
24+
25+
.localdev/

.golangci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
version: "2"
2+
run:
3+
concurrency: 4
4+
issues-exit-code: 1
5+
tests: true
6+
linters:
7+
default: none
8+
enable:
9+
- copyloopvar
10+
- dogsled
11+
- dupl
12+
- errcheck
13+
- exhaustive
14+
- funlen
15+
- goconst
16+
- gocritic
17+
- gocyclo
18+
- goprintffuncname
19+
- govet
20+
- ineffassign
21+
- lll
22+
- misspell
23+
- mnd
24+
- nakedret
25+
- noctx
26+
- nolintlint
27+
- rowserrcheck
28+
- staticcheck
29+
- unconvert
30+
- unparam
31+
- unused
32+
- whitespace
33+
- gosec
34+
- bodyclose
35+
- depguard
36+
- revive
37+
settings:
38+
depguard:
39+
rules:
40+
main:
41+
list-mode: lax
42+
allow:
43+
- $gostd
44+
- github.com/stackvista
45+
funlen:
46+
lines: 100
47+
statements: 60
48+
lll:
49+
line-length: 250
50+
mnd:
51+
checks:
52+
- argument
53+
- case
54+
- condition
55+
- return
56+
nolintlint:
57+
require-specific: true
58+
allow-unused: true
59+
exclusions:
60+
generated: lax
61+
presets:
62+
- comments
63+
- common-false-positives
64+
- legacy
65+
- std-error-handling
66+
paths:
67+
- third_party$
68+
- builtin$
69+
- examples$
70+
formatters:
71+
enable:
72+
- gofmt
73+
- goimports
74+
exclusions:
75+
generated: lax
76+
paths:
77+
- third_party$
78+
- builtin$
79+
- examples$

0 commit comments

Comments
 (0)