mirror of
https://github.com/dnote/dnote
synced 2026-03-14 22:45:50 +01:00
Compare commits
60 commits
clean-up-d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f34a96abbe |
||
|
|
9fa312e3fc |
||
|
|
8f37d34df6 |
||
|
|
5c416e3a32 |
||
|
|
d5e11c23f6 |
||
|
|
f1d7123596 |
||
|
|
ce5c9b242a |
||
|
|
e72322f847 |
||
|
|
e0c4cb1545 |
||
|
|
6314749263 |
||
|
|
ae290a226f |
||
|
|
a46afb821f |
||
|
|
f6a4c6344c |
||
|
|
e3380a4dfa |
||
|
|
0a5728faf3 |
||
|
|
b03ca999a5 |
||
|
|
83ac43b737 |
||
|
|
505fc67966 |
||
|
|
7d44c541a4 |
||
|
|
850f9cc6c9 |
||
|
|
41f25514f0 |
||
|
|
03889a3d7e |
||
|
|
c8238aa327 |
||
|
|
346bd9afb1 |
||
|
|
74119b1d0b |
||
|
|
24491bc68a |
||
|
|
e0f68fc8d8 |
||
|
|
fd7b2a78b2 |
||
|
|
ca5af5e34a |
||
|
|
162ceb4ad1 |
||
|
|
637d4c6861 |
||
|
|
a62c7f9e93 |
||
|
|
5df3e7af70 |
||
|
|
b141b677bb |
||
|
|
61162e2add |
||
|
|
5928f9619f |
||
|
|
a26037f83a |
||
|
|
b37820da1f |
||
|
|
8ffd44f362 |
||
|
|
895dcaa59f |
||
|
|
1ff4c07528 |
||
|
|
bdc980e5ce |
||
|
|
f1c0d0bc04 |
||
|
|
f0ba8a1fa6 |
||
|
|
4dded18395 |
||
|
|
818ebcce69 |
||
|
|
94ad949453 |
||
|
|
5eae1299f7 |
||
|
|
2de1798fdd |
||
|
|
558bf8dbe1 |
||
|
|
664520e027 |
||
|
|
f18677e498 |
||
|
|
b47c792d5f |
||
|
|
489d4f407a |
||
|
|
17b4c7d6cf |
||
|
|
fd5f92c247 |
||
|
|
0ef9e20e8d |
||
|
|
c3214f12f0 |
||
|
|
4258ea1715 |
||
|
|
d52a5bdf48 |
321 changed files with 16241 additions and 12482 deletions
29
.github/workflows/ci.yml
vendored
29
.github/workflows/ci.yml
vendored
|
|
@ -11,30 +11,11 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
services:
|
|
||||||
postgres:
|
|
||||||
image: postgres:14
|
|
||||||
env:
|
|
||||||
POSTGRES_USER: postgres
|
|
||||||
POSTGRES_PASSWORD: postgres
|
|
||||||
POSTGRES_DB: dnote_test
|
|
||||||
POSTGRES_PORT: 5432
|
|
||||||
# Wait until postgres has started
|
|
||||||
options: >-
|
|
||||||
--health-cmd pg_isready
|
|
||||||
--health-interval 10s
|
|
||||||
--health-timeout 5s
|
|
||||||
--health-retries 5
|
|
||||||
|
|
||||||
# Expose port to the host
|
|
||||||
ports:
|
|
||||||
- 5432:5432
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-go@v3
|
- uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version: '1.20.0'
|
go-version: '>=1.25.0'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -47,3 +28,7 @@ jobs:
|
||||||
- name: Test app
|
- name: Test app
|
||||||
run: |
|
run: |
|
||||||
make test-api
|
make test-api
|
||||||
|
|
||||||
|
- name: Test e2e
|
||||||
|
run: |
|
||||||
|
make test-e2e
|
||||||
|
|
|
||||||
77
.github/workflows/release-cli.yml
vendored
Normal file
77
.github/workflows/release-cli.yml
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
name: Release CLI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'cli-v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version: '>=1.25.0'
|
||||||
|
|
||||||
|
- name: Extract version from tag
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
TAG=${GITHUB_REF#refs/tags/cli-v}
|
||||||
|
echo "version=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
echo "Releasing version: $TAG"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: make install
|
||||||
|
|
||||||
|
- name: Run CLI tests
|
||||||
|
run: make test-cli
|
||||||
|
|
||||||
|
- name: Run E2E tests
|
||||||
|
run: make test-e2e
|
||||||
|
|
||||||
|
- name: Build CLI
|
||||||
|
run: make version=${{ steps.version.outputs.version }} build-cli
|
||||||
|
|
||||||
|
- name: Generate changelog
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
TAG="cli-v${VERSION}"
|
||||||
|
|
||||||
|
# Find previous CLI tag
|
||||||
|
PREV_TAG=$(git tag --sort=-version:refname | grep "^cli-" | grep -v "^${TAG}$" | head -n 1)
|
||||||
|
|
||||||
|
if [ -z "$PREV_TAG" ]; then
|
||||||
|
echo "Error: No previous CLI tag found"
|
||||||
|
echo "This appears to be the first release."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
./scripts/generate-changelog.sh cli "$TAG" "$PREV_TAG" > /tmp/changelog.txt
|
||||||
|
cat /tmp/changelog.txt
|
||||||
|
|
||||||
|
- name: Create GitHub release
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
TAG="cli-v${VERSION}"
|
||||||
|
|
||||||
|
# Determine if prerelease (version not matching major.minor.patch)
|
||||||
|
FLAGS=""
|
||||||
|
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
FLAGS="--prerelease"
|
||||||
|
fi
|
||||||
|
|
||||||
|
gh release create "$TAG" \
|
||||||
|
build/cli/*.tar.gz \
|
||||||
|
build/cli/*_checksums.txt \
|
||||||
|
$FLAGS \
|
||||||
|
--title="$TAG" \
|
||||||
|
--notes-file=/tmp/changelog.txt \
|
||||||
|
--draft
|
||||||
109
.github/workflows/release-server.yml
vendored
Normal file
109
.github/workflows/release-server.yml
vendored
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
name: Release Server
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'server-v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version: '>=1.25.0'
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Extract version from tag
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
TAG=${GITHUB_REF#refs/tags/server-v}
|
||||||
|
echo "version=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
echo "Releasing version: $TAG"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: make install
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: make test
|
||||||
|
|
||||||
|
- name: Build server
|
||||||
|
run: make version=${{ steps.version.outputs.version }} build-server
|
||||||
|
|
||||||
|
- name: Generate changelog
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
TAG="server-v${VERSION}"
|
||||||
|
|
||||||
|
# Find previous server tag
|
||||||
|
PREV_TAG=$(git tag --sort=-version:refname | grep "^server-" | grep -v "^${TAG}$" | head -n 1)
|
||||||
|
|
||||||
|
if [ -z "$PREV_TAG" ]; then
|
||||||
|
echo "Error: No previous server tag found"
|
||||||
|
echo "This appears to be the first release."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
./scripts/generate-changelog.sh server "$TAG" "$PREV_TAG" > /tmp/changelog.txt
|
||||||
|
cat /tmp/changelog.txt
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Prepare Docker build context
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
cp build/server/dnote_server_${VERSION}_linux_amd64.tar.gz host/docker/
|
||||||
|
cp build/server/dnote_server_${VERSION}_linux_arm64.tar.gz host/docker/
|
||||||
|
cp build/server/dnote_server_${VERSION}_linux_arm.tar.gz host/docker/
|
||||||
|
cp build/server/dnote_server_${VERSION}_linux_386.tar.gz host/docker/
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: ./host/docker
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386
|
||||||
|
tags: |
|
||||||
|
dnote/dnote:${{ steps.version.outputs.version }}
|
||||||
|
dnote/dnote:latest
|
||||||
|
build-args: |
|
||||||
|
version=${{ steps.version.outputs.version }}
|
||||||
|
|
||||||
|
- name: Create GitHub release
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
TAG="server-v${VERSION}"
|
||||||
|
|
||||||
|
# Determine if prerelease (version not matching major.minor.patch)
|
||||||
|
FLAGS=""
|
||||||
|
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
FLAGS="--prerelease"
|
||||||
|
fi
|
||||||
|
|
||||||
|
gh release create "$TAG" \
|
||||||
|
build/server/*.tar.gz \
|
||||||
|
build/server/*_checksums.txt \
|
||||||
|
$FLAGS \
|
||||||
|
--title="$TAG" \
|
||||||
|
--notes-file=/tmp/changelog.txt \
|
||||||
|
--draft
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -4,3 +4,6 @@
|
||||||
*.log
|
*.log
|
||||||
node_modules
|
node_modules
|
||||||
/test
|
/test
|
||||||
|
tmp
|
||||||
|
*.db
|
||||||
|
/server
|
||||||
|
|
|
||||||
267
CHANGELOG.md
267
CHANGELOG.md
|
|
@ -1,267 +0,0 @@
|
||||||
# CHANAGELOG
|
|
||||||
|
|
||||||
All notable changes to the projects under this repository will be documented in this file.
|
|
||||||
|
|
||||||
* [Server](#server)
|
|
||||||
* [CLI](#cli)
|
|
||||||
|
|
||||||
## Server
|
|
||||||
|
|
||||||
The following log documents the history of the server project.
|
|
||||||
|
|
||||||
### Unreleased
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
### 2.0.0 2021-05-09
|
|
||||||
|
|
||||||
#### Removed
|
|
||||||
|
|
||||||
- The web interface for managing notes and books (#594)
|
|
||||||
|
|
||||||
### 1.0.4 2020-05-23
|
|
||||||
|
|
||||||
#### Removed
|
|
||||||
|
|
||||||
- Simplify the bundle by removing unnecessary payment logic
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
- Fix timestamp in the note content view
|
|
||||||
- Invalidate existing sessions when password is changed
|
|
||||||
|
|
||||||
### 1.0.3 2020-05-03
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
- Fix timeline grouping notes by added time rather than updated time.
|
|
||||||
|
|
||||||
#### Changed
|
|
||||||
|
|
||||||
- Sort notes by last activity to make it easier to see the most recently accessed information.
|
|
||||||
|
|
||||||
### 1.0.2 2020-05-03
|
|
||||||
|
|
||||||
#### Changed
|
|
||||||
|
|
||||||
* Support arm64.
|
|
||||||
|
|
||||||
### 1.0.1 - 2020-03-29
|
|
||||||
|
|
||||||
- Fix fresh install running migrations against tables that no longer exists.
|
|
||||||
|
|
||||||
### 1.0.0 - 2020-03-22
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
- Fix unsubscribe link from the inactive reminder (#433)
|
|
||||||
|
|
||||||
#### Removed
|
|
||||||
|
|
||||||
- Remove the deprecated features related to digests and repetition rules (#432)
|
|
||||||
- Remove the migration for the deprecated, encrypted Dnote (#433)
|
|
||||||
|
|
||||||
#### Changed
|
|
||||||
|
|
||||||
- Please set `OnPremise` environment to `true` in order to automatically use the Pro version.
|
|
||||||
|
|
||||||
### 0.5.0 - 2020-02-06
|
|
||||||
|
|
||||||
#### Changed
|
|
||||||
|
|
||||||
- **Deprecated** the digest and digest emails (#397)
|
|
||||||
- **Deprecated** the repetition rules (#397)
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
- Fix refocusing to the end of the textarea input (#405)
|
|
||||||
|
|
||||||
### 0.4.0 - 2020-01-09
|
|
||||||
|
|
||||||
#### Added
|
|
||||||
|
|
||||||
- A web-based digest (#380)
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
- Send inactive reminders with a correct email type (#385)
|
|
||||||
- Wrap words in note content (#389)
|
|
||||||
|
|
||||||
### 0.3.4 - 2019-12-24
|
|
||||||
|
|
||||||
#### Added
|
|
||||||
|
|
||||||
- Remind when the knowledge base stops growing (#375)
|
|
||||||
- Alert when a password is changed (#375)
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
- Implement syntax highlighting for code blocks ($377)
|
|
||||||
|
|
||||||
### 0.3.3 - 2019-12-17
|
|
||||||
|
|
||||||
#### Added
|
|
||||||
|
|
||||||
- Send welcome email with login instructions upon reigstering (#352)
|
|
||||||
- Add an option to disable registration (#365)
|
|
||||||
|
|
||||||
#### Changed
|
|
||||||
|
|
||||||
- Send emails from the domain that hosts the application for on premise installations (#355)
|
|
||||||
- For on premise installations, automatically upgrade user accounts (#361)
|
|
||||||
|
|
||||||
### 0.3.2 - 2019-11-20
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
- Fix server crash upon landing on a note page (#324).
|
|
||||||
- Allow to synchronize a large number of records (#321)
|
|
||||||
|
|
||||||
### 0.3.1 - 2019-11-12
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
- Fix static files not being embedded in the binary. (#309)
|
|
||||||
- Fix mobile menu not covering the whole screen. (#308)
|
|
||||||
|
|
||||||
### 0.3.0 - 2019-11-12
|
|
||||||
|
|
||||||
#### Added
|
|
||||||
|
|
||||||
- Share notes (#300)
|
|
||||||
- Allow to recover from a missed repetition processing (#305)
|
|
||||||
|
|
||||||
### 0.2.1 - 2019-11-04
|
|
||||||
|
|
||||||
#### Upgrade Guide
|
|
||||||
|
|
||||||
* Please define the follwoing new environment variables:
|
|
||||||
|
|
||||||
- `WebURL`: the URL to your Dnote server, without the trailing slash. (e.g. `https://my-server.com`) (Please see #290)
|
|
||||||
- `SmtpPort`: the SMTP port. (e.g. `465`) optional - required *if you want to configure email*
|
|
||||||
|
|
||||||
#### Added
|
|
||||||
|
|
||||||
- Display version number in the settings (#293)
|
|
||||||
- Allow unsecure database connection in production (#276)
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
- Allow to customize the app URL in the emails (#290)
|
|
||||||
- Allow to customize the SMTP port (#292)
|
|
||||||
|
|
||||||
### 0.2.0 - 2019-10-28
|
|
||||||
|
|
||||||
#### Added
|
|
||||||
|
|
||||||
- Specify spaced repetition rule (#280)
|
|
||||||
|
|
||||||
#### Changed
|
|
||||||
|
|
||||||
- Treat a linebreak as a new line in the preview (#261)
|
|
||||||
- Allow to have multiple editor states for adding and editing notes (#260)
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
- Fix jumping focus on editor (#265)
|
|
||||||
|
|
||||||
### 0.1.1 - 2019-09-30
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
- Fix asset loading (#257)
|
|
||||||
|
|
||||||
|
|
||||||
### 0.1.0 - 2019-09-30
|
|
||||||
|
|
||||||
#### Added
|
|
||||||
|
|
||||||
- Full-text search (#254)
|
|
||||||
- Password recovery (#254)
|
|
||||||
- Embedded notes in the digest emails (#254)
|
|
||||||
|
|
||||||
#### Removed
|
|
||||||
|
|
||||||
- **Breaking Change**: End-to-end encryption was removed. Existing users need to go to `/classic` and follow the automated migration steps. (#254)
|
|
||||||
- **Breaking Change**: `v1` and `v2` API endpoints were removed, and `v3` API was added as a replacement.
|
|
||||||
|
|
||||||
#### Migration guide
|
|
||||||
|
|
||||||
- In your application, navigate to `/classic` and follow the automated migration steps.
|
|
||||||
|
|
||||||
|
|
||||||
## CLI
|
|
||||||
|
|
||||||
The following log documentes the history of the CLI project
|
|
||||||
|
|
||||||
### Unreleased
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
### 0.13.0 - 2023-02-10
|
|
||||||
|
|
||||||
* Allow to add note from stdin.
|
|
||||||
|
|
||||||
```
|
|
||||||
echo "test" | dnote add mybook
|
|
||||||
|
|
||||||
dnote add mybook << EOF
|
|
||||||
test line 1
|
|
||||||
test line 2
|
|
||||||
EOF
|
|
||||||
```
|
|
||||||
|
|
||||||
### 0.12.0 - 2020-01-03
|
|
||||||
|
|
||||||
#### Upgrade guide
|
|
||||||
|
|
||||||
* **On Linux or macOS** Please move your Dnote files to new directories based on the XDG base directory specfication. **On Windows**, no action is required.
|
|
||||||
|
|
||||||
```
|
|
||||||
# Move the database file
|
|
||||||
mv ~/.dnote/dnote.db ~/.local/share/dnote/dnote.db
|
|
||||||
|
|
||||||
# Move the config file
|
|
||||||
mv ~/.dnote/dnoterc ~/.config/dnote/dnoterc
|
|
||||||
|
|
||||||
# Delete ~/.dnote. (it is safe to delete DNOTE_TMPCONTENT.md files, if they exist.)
|
|
||||||
rm -rf ~/.dnote
|
|
||||||
```
|
|
||||||
|
|
||||||
If `~/.dnote` directory exists, dnote will continue to use that directory for backward compatibility until the next major release.
|
|
||||||
|
|
||||||
#### Added
|
|
||||||
|
|
||||||
- Add `--content-only` flag to print the note content only (#528)
|
|
||||||
|
|
||||||
#### Changed
|
|
||||||
|
|
||||||
- Use XDG base directory on Linux and macOS (#527)
|
|
||||||
|
|
||||||
### 0.11.1 - 2020-04-25
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
- Fix upgrade URL (#453)
|
|
||||||
|
|
||||||
#### Changed
|
|
||||||
|
|
||||||
- Display hostname of the self-hosted instance while logging in (#454)
|
|
||||||
- Display helpful error if endpoint is misconfigured (#455)
|
|
||||||
|
|
||||||
### 0.11.0 - 2020-02-05
|
|
||||||
|
|
||||||
#### Added
|
|
||||||
|
|
||||||
- Allow to pass credentials through flags while logging in (#403)
|
|
||||||
|
|
||||||
### 0.10.0 - 2019-09-30
|
|
||||||
|
|
||||||
#### Removed
|
|
||||||
|
|
||||||
- **Breaking Change**: End-to-end encryption was removed. Previous versions will no longer be able to interact with the web API, because `v1` and `v2` endpoints were replaced by a new `v3` endpoint to remove encryption.
|
|
||||||
|
|
||||||
#### Migration guide
|
|
||||||
|
|
||||||
- If you are using Dnote Pro, change the value of `apiEndpoint` in `~/.dnote/dnoterc` to `https://api.getdnote.com`.
|
|
||||||
|
|
||||||
|
|
@ -8,89 +8,61 @@ Dnote is an open source project.
|
||||||
|
|
||||||
## Setting up
|
## Setting up
|
||||||
|
|
||||||
Dnote uses [Vagrant](https://github.com/hashicorp/vagrant) to provision a consistent development environment.
|
The CLI and server are single single binary files with SQLite embedded - no databases to install, no containers to run, no VMs required.
|
||||||
|
|
||||||
*Prerequisites*
|
**Prerequisites**
|
||||||
|
|
||||||
* Vagrant ([Download](https://www.vagrantup.com/downloads.html))
|
* Go 1.25+ ([Download](https://go.dev/dl/))
|
||||||
* VirtualBox ([Download](https://www.virtualbox.org/))
|
* Node.js 18+ ([Download](https://nodejs.org/) - only needed for building frontend assets)
|
||||||
|
|
||||||
Run the following command from the project root. It starts the virtual machine and bootstraps the project.
|
**Quick Start**
|
||||||
|
|
||||||
```
|
1. Clone the repository
|
||||||
vagrant up
|
2. Install dependencies:
|
||||||
```
|
```bash
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
3. Start developing! Run tests:
|
||||||
|
```bash
|
||||||
|
make test
|
||||||
|
```
|
||||||
|
Or start the dev server:
|
||||||
|
```bash
|
||||||
|
make dev-server
|
||||||
|
```
|
||||||
|
|
||||||
*Workflow*
|
That's it. You're ready to contribute.
|
||||||
|
|
||||||
* You can make changes to the source code from the host machine.
|
|
||||||
* Any commands need to be run inside the virtual machine. You can connect to it by running `vagrant ssh`.
|
|
||||||
* If you want to run tests in a WATCH mode, please do so from the host machine. We cannot watch file changes due to the limitation of file system used in a virtual machine.
|
|
||||||
|
|
||||||
## Server
|
## Server
|
||||||
|
|
||||||
The server consists of the frontend web application and a web server.
|
|
||||||
|
|
||||||
### Development
|
|
||||||
|
|
||||||
* Run `make dev-server` to start a local server.
|
|
||||||
* You can access the server on `localhost:3000` on your machine.
|
|
||||||
|
|
||||||
### Test
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Run tests for app
|
# Start dev server (runs on localhost:3001)
|
||||||
|
make dev-server
|
||||||
|
|
||||||
|
# Run tests
|
||||||
make test-api
|
make test-api
|
||||||
|
|
||||||
# Run in watch mode
|
# Run tests in watch mode
|
||||||
WATCH=true make test-api
|
WATCH=true make test-api
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Command Line Interface
|
## Command Line Interface
|
||||||
|
|
||||||
### Build
|
```bash
|
||||||
|
# Run tests
|
||||||
|
make test-cli
|
||||||
|
|
||||||
You can build either a development version or a production version:
|
# Build dev version (places in your PATH)
|
||||||
|
|
||||||
```
|
|
||||||
# Build a development version for your platform and place it in your `PATH`.
|
|
||||||
make debug=true build-cli
|
make debug=true build-cli
|
||||||
|
|
||||||
# Build a production version for all platforms
|
# Build production version for all platforms
|
||||||
make version=v0.1.0 build-cli
|
make version=v0.1.0 build-cli
|
||||||
|
|
||||||
# Build a production version for a specific platform
|
# Build for a specific platform
|
||||||
# Note: You cannot cross-compile using this method because Dnote uses CGO
|
# Note: You cannot cross-compile using this method because Dnote uses CGO
|
||||||
# and requires the OS specific headers.
|
# and requires the OS specific headers.
|
||||||
GOOS=[insert OS] GOARCH=[insert arch] make version=v0.1.0 build-cli
|
GOOS=[insert OS] GOARCH=[insert arch] make version=v0.1.0 build-cli
|
||||||
```
|
|
||||||
|
|
||||||
### Test
|
# Debug mode
|
||||||
|
|
||||||
* Run all tests for the command line interface:
|
|
||||||
|
|
||||||
```
|
|
||||||
make test-cli
|
|
||||||
```
|
|
||||||
|
|
||||||
### Debug
|
|
||||||
|
|
||||||
Run Dnote with `DNOTE_DEBUG=1` to print debugging statements. For instance:
|
|
||||||
|
|
||||||
```
|
|
||||||
DNOTE_DEBUG=1 dnote sync
|
DNOTE_DEBUG=1 dnote sync
|
||||||
```
|
```
|
||||||
|
|
||||||
### Release
|
|
||||||
|
|
||||||
* Run `make version=v0.1.0 release-cli` to achieve the following:
|
|
||||||
* Build for all target platforms, create a git tag, push all tags to the repository
|
|
||||||
* Create a release on GitHub and [Dnote Homebrew tap](https://github.com/dnote/homebrew-dnote).
|
|
||||||
|
|
||||||
**Note**
|
|
||||||
|
|
||||||
- If a release is not stable,
|
|
||||||
- disable the homebrew release by commenting out relevant code in the release script.
|
|
||||||
- mark release as pre-release on GitHub release
|
|
||||||
|
|
||||||
|
|
|
||||||
209
LICENSE
209
LICENSE
|
|
@ -1,8 +1,203 @@
|
||||||
Source code in this repository is variously licensed under the GNU Affero General Public
|
|
||||||
License v3.0 (GNU AGPLv3), and GNU General Public License v3.0 (GNU GPLv3). A copy of each
|
|
||||||
license can be found in the licenses directory. The Source code for the cli is licensed under
|
|
||||||
GNU GPLv3. The source code for the server and the web is licensed under GNU AGPLv3. Unless
|
|
||||||
otherwise noted, source code in a given file is licensed under the GNU AGPLv3.
|
|
||||||
|
|
||||||
Unless otherwise noted at the beginning of the file, the copyright belongs to
|
Apache License
|
||||||
Monomax Software Pty Ltd.
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
|
|
||||||
82
Makefile
82
Makefile
|
|
@ -30,10 +30,10 @@ endif
|
||||||
.PHONY: install-js
|
.PHONY: install-js
|
||||||
|
|
||||||
## test
|
## test
|
||||||
test: test-cli test-api
|
test: test-cli test-api test-e2e
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
|
|
||||||
test-cli:
|
test-cli: generate-cli-schema
|
||||||
@echo "==> running CLI test"
|
@echo "==> running CLI test"
|
||||||
@(${currentDir}/scripts/cli/test.sh)
|
@(${currentDir}/scripts/cli/test.sh)
|
||||||
.PHONY: test-cli
|
.PHONY: test-cli
|
||||||
|
|
@ -43,11 +43,10 @@ test-api:
|
||||||
@(${currentDir}/scripts/server/test-local.sh)
|
@(${currentDir}/scripts/server/test-local.sh)
|
||||||
.PHONY: test-api
|
.PHONY: test-api
|
||||||
|
|
||||||
test-selfhost:
|
test-e2e:
|
||||||
@echo "==> running a smoke test for self-hosting"
|
@echo "==> running E2E test"
|
||||||
|
@(${currentDir}/scripts/e2e/test.sh)
|
||||||
@${currentDir}/host/smoketest/run_test.sh ${tarballPath}
|
.PHONY: test-e2e
|
||||||
.PHONY: test-selfhost
|
|
||||||
|
|
||||||
# development
|
# development
|
||||||
dev-server:
|
dev-server:
|
||||||
|
|
@ -60,11 +59,31 @@ ifndef version
|
||||||
$(error version is required. Usage: make version=0.1.0 build-server)
|
$(error version is required. Usage: make version=0.1.0 build-server)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@echo "==> building server assets"
|
||||||
|
@(cd "${currentDir}/pkg/server/assets/" && ./styles/build.sh)
|
||||||
|
@(cd "${currentDir}/pkg/server/assets/" && ./js/build.sh)
|
||||||
|
|
||||||
@echo "==> building server"
|
@echo "==> building server"
|
||||||
@${currentDir}/scripts/server/build.sh $(version)
|
@${currentDir}/scripts/server/build.sh $(version)
|
||||||
.PHONY: build-server
|
.PHONY: build-server
|
||||||
|
|
||||||
build-cli:
|
build-server-docker: build-server
|
||||||
|
ifndef version
|
||||||
|
$(error version is required. Usage: make version=0.1.0 [platform=linux/amd64] build-server-docker)
|
||||||
|
endif
|
||||||
|
|
||||||
|
@echo "==> building Docker image"
|
||||||
|
@(cd ${currentDir}/host/docker && ./build.sh $(version) $(platform))
|
||||||
|
.PHONY: build-server-docker
|
||||||
|
|
||||||
|
generate-cli-schema:
|
||||||
|
@echo "==> generating CLI database schema"
|
||||||
|
@mkdir -p pkg/cli/database
|
||||||
|
@touch pkg/cli/database/schema.sql
|
||||||
|
@go run -tags fts5 ./pkg/cli/database/schema
|
||||||
|
.PHONY: generate-cli-schema
|
||||||
|
|
||||||
|
build-cli: generate-cli-schema
|
||||||
ifeq ($(debug), true)
|
ifeq ($(debug), true)
|
||||||
@echo "==> building cli in dev mode"
|
@echo "==> building cli in dev mode"
|
||||||
@${currentDir}/scripts/cli/dev.sh
|
@${currentDir}/scripts/cli/dev.sh
|
||||||
|
|
@ -79,53 +98,6 @@ endif
|
||||||
endif
|
endif
|
||||||
.PHONY: build-cli
|
.PHONY: build-cli
|
||||||
|
|
||||||
## release
|
|
||||||
release-cli: clean build-cli
|
|
||||||
ifndef version
|
|
||||||
$(error version is required. Usage: make version=0.1.0 release-cli)
|
|
||||||
endif
|
|
||||||
ifndef GH
|
|
||||||
$(error please install github-cli)
|
|
||||||
endif
|
|
||||||
|
|
||||||
@echo "==> releasing cli"
|
|
||||||
@${currentDir}/scripts/release.sh cli $(version) ${cliOutputDir}
|
|
||||||
.PHONY: release-cli
|
|
||||||
|
|
||||||
release-cli-homebrew: clean build-cli
|
|
||||||
ifndef version
|
|
||||||
$(error version is required. Usage: make version=0.1.0 release-cli)
|
|
||||||
endif
|
|
||||||
|
|
||||||
@echo "==> releasing cli on Homebrew"
|
|
||||||
@${currentDir}/scripts/cli/release-homebrew.sh $(version) ${cliOutputDir}
|
|
||||||
.PHONY: release-cli
|
|
||||||
|
|
||||||
release-server:
|
|
||||||
ifndef version
|
|
||||||
$(error version is required. Usage: make version=0.1.0 release-server)
|
|
||||||
endif
|
|
||||||
ifndef GH
|
|
||||||
$(error please install github-cli)
|
|
||||||
endif
|
|
||||||
|
|
||||||
@echo "==> releasing server"
|
|
||||||
@${currentDir}/scripts/release.sh server $(version) ${serverOutputDir}
|
|
||||||
|
|
||||||
@echo "==> building and releasing docker image"
|
|
||||||
@(cd ${currentDir}/host/docker && ./build.sh $(version))
|
|
||||||
@(cd ${currentDir}/host/docker && ./release.sh $(version))
|
|
||||||
.PHONY: release-server
|
|
||||||
|
|
||||||
# migrations
|
|
||||||
create-migration:
|
|
||||||
ifndef filename
|
|
||||||
$(error filename is required. Usage: make filename=your-filename create-migration)
|
|
||||||
endif
|
|
||||||
|
|
||||||
@(cd ${currentDir}/pkg/server/database && ./scripts/create-migration.sh $(filename))
|
|
||||||
.PHONY: create-migration
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@git clean -f
|
@git clean -f
|
||||||
@rm -rf build
|
@rm -rf build
|
||||||
|
|
|
||||||
60
README.md
60
README.md
|
|
@ -3,38 +3,62 @@
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Dnote is a simple command line notebook for programmers.
|
Dnote is a simple command line notebook. Single binary, no dependencies. Since 2017.
|
||||||
|
|
||||||
It **keeps you focused** by providing a way of effortlessly capturing and retrieving information **without leaving your terminal**. It also offers a seamless **multi-device sync**.
|
Your notes are stored in **one SQLite file** - portable, searchable, and completely under your control. Optional sync between devices via a self-hosted server with REST API access.
|
||||||
|
|
||||||

|
```sh
|
||||||
|
# Add a note (or omit -c to launch your editor)
|
||||||
|
dnote add linux -c "Check disk usage with df -h"
|
||||||
|
|
||||||
|
# View notes in a book
|
||||||
|
dnote view linux
|
||||||
|
|
||||||
|
# Full-text search
|
||||||
|
dnote find "disk usage"
|
||||||
|
|
||||||
|
# Sync notes
|
||||||
|
dnote sync
|
||||||
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
On macOS, you can install using Homebrew:
|
```bash
|
||||||
|
# Linux, macOS, FreeBSD, Windows
|
||||||
|
curl -s https://www.getdnote.com/install | sh
|
||||||
|
|
||||||
```sh
|
# macOS with Homebrew
|
||||||
brew tap dnote/dnote
|
|
||||||
brew install dnote
|
brew install dnote
|
||||||
```
|
```
|
||||||
|
|
||||||
On Linux or macOS, you can use the installation script:
|
Or [download binary](https://github.com/dnote/dnote/releases).
|
||||||
|
|
||||||
curl -s https://www.getdnote.com/install | sh
|
## Server (Optional)
|
||||||
|
|
||||||
Otherwise, you can download the binary for your platform manually from the [releases page](https://github.com/dnote/dnote/releases).
|
Server is a binary with SQLite embedded. No database setup is required.
|
||||||
|
|
||||||
## Server
|
If using docker, create a compose.yml:
|
||||||
|
|
||||||
The quickest way to experience the Dnote server is to use [Dnote Cloud](https://app.getdnote.com).
|
```yaml
|
||||||
|
services:
|
||||||
|
dnote:
|
||||||
|
image: dnote/dnote:latest
|
||||||
|
container_name: dnote
|
||||||
|
ports:
|
||||||
|
- 3001:3001
|
||||||
|
volumes:
|
||||||
|
- ./dnote_data:/data
|
||||||
|
restart: unless-stopped
|
||||||
|
```
|
||||||
|
|
||||||
Or you can install it on your server by [using Docker](https://github.com/dnote/dnote/blob/master/host/docker/README.md), or [using a binary](https://github.com/dnote/dnote/blob/master/SELF_HOSTING.md).
|
Then run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Or see the [guide](https://www.getdnote.com/docs/server/manual) for binary installation.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Please see [Dnote wiki](https://github.com/dnote/dnote/wiki) for the documentation.
|
See the [Dnote doc](https://www.getdnote.com/docs).
|
||||||
|
|
||||||
## See Also
|
|
||||||
|
|
||||||
- [Homepage](https://www.getdnote.com)
|
|
||||||
- [I Wrote Down Everything I Learned While Programming for a Month](https://www.getdnote.com/blog/writing-everything-i-learn-coding-for-a-month/)
|
|
||||||
|
|
|
||||||
202
SELF_HOSTING.md
202
SELF_HOSTING.md
|
|
@ -1,183 +1,43 @@
|
||||||
# Installing Dnote Server
|
# Self-Hosting Dnote Server
|
||||||
|
|
||||||
This guide documents the steps for installing the Dnote server on your own machine. If you prefer Docker, please see [the Docker guide](https://github.com/dnote/dnote/blob/master/host/docker/README.md).
|
Please see the [doc](https://www.getdnote.com/docs/server) for more.
|
||||||
|
|
||||||
## Overview
|
## Docker Installation
|
||||||
|
|
||||||
Dnote server comes as a single binary file that you can simply download and run. It uses Postgres as the database.
|
1. Install [Docker](https://docs.docker.com/install/).
|
||||||
|
2. Install Docker [Compose plugin](https://docs.docker.com/compose/install/linux/).
|
||||||
|
3. Create a `compose.yml` file with the following content:
|
||||||
|
|
||||||
## Installation
|
```yaml
|
||||||
|
services:
|
||||||
|
dnote:
|
||||||
|
image: dnote/dnote:latest
|
||||||
|
container_name: dnote
|
||||||
|
ports:
|
||||||
|
- 3001:3001
|
||||||
|
volumes:
|
||||||
|
- ./dnote_data:/data
|
||||||
|
restart: unless-stopped
|
||||||
|
```
|
||||||
|
|
||||||
1. Install Postgres 11+.
|
4. Run the following to download the image and start the container
|
||||||
2. Create a `dnote` database by running `createdb dnote`
|
|
||||||
3. Download the official Dnote server release from the [release page](https://github.com/dnote/dnote/releases).
|
```
|
||||||
4. Extract the archive and move the `dnote-server` executable to `/usr/local/bin`.
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Visit http://localhost:3001 in your browser to see Dnote running.
|
||||||
|
|
||||||
|
## Manual Installation
|
||||||
|
|
||||||
|
Download from [releases](https://github.com/dnote/dnote/releases), extract, and run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
tar -xzf dnote-server-$version-$os.tar.gz
|
tar -xzf dnote-server-$version-$os.tar.gz
|
||||||
mv ./dnote-server /usr/local/bin
|
mv ./dnote-server /usr/local/bin
|
||||||
|
dnote-server start --baseUrl=https://your.server
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Run Dnote
|
You're up and running. Database: `~/.local/share/dnote/server.db` (customize with `--dbPath`). Run `dnote-server start --help` for options.
|
||||||
|
|
||||||
```bash
|
Set `apiEndpoint: https://your.server/api` in `~/.config/dnote/dnoterc` to connect your CLI to the server.
|
||||||
GO_ENV=PRODUCTION \
|
|
||||||
OnPremise=true \
|
|
||||||
DBHost=localhost \
|
|
||||||
DBPort=5432 \
|
|
||||||
DBName=dnote \
|
|
||||||
DBUser=$user \
|
|
||||||
DBPassword=$password \
|
|
||||||
WebURL=$webURL \
|
|
||||||
SmtpHost=$SmtpHost \
|
|
||||||
SmtpPort=$SmtpPort \
|
|
||||||
SmtpUsername=$SmtpUsername \
|
|
||||||
SmtpPassword=$SmtpPassword \
|
|
||||||
DisableRegistration=false
|
|
||||||
dnote-server start
|
|
||||||
```
|
|
||||||
|
|
||||||
Replace `$user`, `$password` with the credentials of the Postgres user that owns the `dnote` database.
|
|
||||||
|
|
||||||
Replace `$webURL` with the full URL to your server, without a trailing slash (e.g. `https://your.server`).
|
|
||||||
|
|
||||||
Replace `$SmtpHost`, `SmtpPort`, `$SmtpUsername`, `$SmtpPassword` with actual values, if you would like to receive spaced repetition through email.
|
|
||||||
|
|
||||||
Replace `DisableRegistration` to `true` if you would like to disable user registrations.
|
|
||||||
|
|
||||||
By default, dnote server will run on the port 3000.
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
By now, Dnote is fully functional in your machine. The API, frontend app, and the background tasks are all in the single binary. Let's take a few more steps to configure Dnote.
|
|
||||||
|
|
||||||
### Configure Nginx
|
|
||||||
|
|
||||||
To make it accessible from the Internet, you need to configure Nginx.
|
|
||||||
|
|
||||||
1. Install nginx.
|
|
||||||
2. Create a new file in `/etc/nginx/sites-enabled/dnote` with the following contents:
|
|
||||||
|
|
||||||
```
|
|
||||||
server {
|
|
||||||
server_name my-dnote-server.com;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $remote_addr;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_pass http://127.0.0.1:3000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
3. Replace `my-dnote-server.com` with the URL for your server.
|
|
||||||
4. Reload the nginx configuration by running the following:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo service nginx reload
|
|
||||||
```
|
|
||||||
|
|
||||||
### Configure Apache2
|
|
||||||
|
|
||||||
1. Install Apache2 and install/enable mod_proxy.
|
|
||||||
2. Create a new file in `/etc/apache2/sites-available/dnote.conf` with the following contents:
|
|
||||||
|
|
||||||
```
|
|
||||||
<VirtualHost *:80>
|
|
||||||
ServerName notes.example.com
|
|
||||||
|
|
||||||
ProxyRequests Off
|
|
||||||
ProxyPreserveHost On
|
|
||||||
ProxyPass / http://127.0.0.1:3000/ keepalive=On
|
|
||||||
ProxyPassReverse / http://127.0.0.1:3000/
|
|
||||||
RequestHeader set X-Forwarded-HTTPS "0"
|
|
||||||
</VirtualHost>
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Enable the dnote site and restart the Apache2 service by running the following:
|
|
||||||
|
|
||||||
```
|
|
||||||
a2ensite dnote
|
|
||||||
sudo service apache2 restart
|
|
||||||
```
|
|
||||||
|
|
||||||
Now you can access the Dnote frontend application on `/`, and the API on `/api`.
|
|
||||||
|
|
||||||
### Configure TLS by using LetsEncrypt
|
|
||||||
|
|
||||||
It is recommended to use HTTPS. Obtain a certificate using LetsEncrypt and configure TLS in Nginx.
|
|
||||||
|
|
||||||
In the future versions of the Dnote Server, HTTPS will be required at all times.
|
|
||||||
|
|
||||||
### Run Dnote As a Daemon
|
|
||||||
|
|
||||||
We can use `systemd` to run Dnote in the background as a Daemon, and automatically start it on system reboot.
|
|
||||||
|
|
||||||
1. Create a new file at `/etc/systemd/system/dnote.service` with the following content:
|
|
||||||
|
|
||||||
```
|
|
||||||
[Unit]
|
|
||||||
Description=Starts the dnote server
|
|
||||||
Requires=network.target
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=$user
|
|
||||||
Restart=always
|
|
||||||
RestartSec=3
|
|
||||||
WorkingDirectory=/home/$user
|
|
||||||
ExecStart=/usr/local/bin/dnote-server start
|
|
||||||
Environment=GO_ENV=PRODUCTION
|
|
||||||
Environment=OnPremise=true
|
|
||||||
Environment=DBHost=localhost
|
|
||||||
Environment=DBPort=5432
|
|
||||||
Environment=DBName=dnote
|
|
||||||
Environment=DBUser=$DBUser
|
|
||||||
Environment=DBPassword=$DBPassword
|
|
||||||
Environment=DBSkipSSL=true
|
|
||||||
Environment=WebURL=$WebURL
|
|
||||||
Environment=SmtpHost=
|
|
||||||
Environment=SmtpPort=
|
|
||||||
Environment=SmtpUsername=
|
|
||||||
Environment=SmtpPassword=
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
```
|
|
||||||
|
|
||||||
Replace `$user`, `$WebURL`, `$DBUser`, and `$DBPassword` with the actual values.
|
|
||||||
|
|
||||||
Optionally, if you would like to send spaced repetitions throught email, populate `SmtpHost`, `SmtpPort`, `SmtpUsername`, and `SmtpPassword`.
|
|
||||||
|
|
||||||
2. Reload the change by running `sudo systemctl daemon-reload`.
|
|
||||||
3. Enable the Daemon by running `sudo systemctl enable dnote`.`
|
|
||||||
4. Start the Daemon by running `sudo systemctl start dnote`
|
|
||||||
|
|
||||||
### Configure clients
|
|
||||||
|
|
||||||
Let's configure Dnote clients to connect to the self-hosted web API endpoint.
|
|
||||||
|
|
||||||
#### CLI
|
|
||||||
|
|
||||||
We need to modify the configuration file for the CLI. It should have been generated at `~/.config/dnote/dnoterc` upon running the CLI for the first time.
|
|
||||||
|
|
||||||
The following is an example configuration:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
editor: nvim
|
|
||||||
apiEndpoint: https://api.getdnote.com
|
|
||||||
```
|
|
||||||
|
|
||||||
Simply change the value for `apiEndpoint` to a full URL to the self-hosted instance, followed by '/api', and save the configuration file.
|
|
||||||
|
|
||||||
e.g.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
editor: nvim
|
|
||||||
apiEndpoint: my-dnote-server.com/api
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Browser extension
|
|
||||||
|
|
||||||
Navigate into the 'Settings' tab and set the values for 'API URL', and 'Web URL'.
|
|
||||||
|
|
|
||||||
20
Vagrantfile
vendored
20
Vagrantfile
vendored
|
|
@ -1,20 +0,0 @@
|
||||||
# -*- mode: ruby -*-
|
|
||||||
|
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
config.vm.box = "ubuntu/bionic64"
|
|
||||||
config.vm.synced_folder '.', '/go/src/github.com/dnote/dnote'
|
|
||||||
config.vm.network "forwarded_port", guest: 3000, host: 3000
|
|
||||||
config.vm.network "forwarded_port", guest: 8080, host: 8080
|
|
||||||
config.vm.network "forwarded_port", guest: 5432, host: 5433
|
|
||||||
|
|
||||||
config.vm.provision 'shell', path: './scripts/vagrant/install_utils.sh'
|
|
||||||
config.vm.provision 'shell', path: './scripts/vagrant/install_go.sh', privileged: false
|
|
||||||
config.vm.provision 'shell', path: './scripts/vagrant/install_node.sh', privileged: false
|
|
||||||
config.vm.provision 'shell', path: './scripts/vagrant/install_postgres.sh', privileged: false
|
|
||||||
config.vm.provision 'shell', path: './scripts/vagrant/bootstrap.sh', privileged: false
|
|
||||||
|
|
||||||
config.vm.provider "virtualbox" do |v|
|
|
||||||
v.memory = 4000
|
|
||||||
v.cpus = 2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
BIN
assets/cli.gif
BIN
assets/cli.gif
Binary file not shown.
|
Before Width: | Height: | Size: 245 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 37 KiB |
52
go.mod
52
go.mod
|
|
@ -1,47 +1,43 @@
|
||||||
module github.com/dnote/dnote
|
module github.com/dnote/dnote
|
||||||
|
|
||||||
go 1.20
|
go 1.25
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/aymerick/douceur v0.2.0
|
|
||||||
github.com/dnote/actions v0.2.0
|
github.com/dnote/actions v0.2.0
|
||||||
github.com/dnote/color v1.7.0
|
github.com/fatih/color v1.18.0
|
||||||
github.com/google/go-cmp v0.5.9
|
github.com/google/go-cmp v0.7.0
|
||||||
github.com/google/go-github v17.0.0+incompatible
|
github.com/google/go-github v17.0.0+incompatible
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/gorilla/csrf v1.7.1
|
github.com/gorilla/csrf v1.7.3
|
||||||
github.com/gorilla/mux v1.8.0
|
github.com/gorilla/mux v1.8.1
|
||||||
github.com/gorilla/schema v1.2.0
|
github.com/gorilla/schema v1.4.1
|
||||||
github.com/jinzhu/gorm v1.9.16
|
github.com/mattn/go-sqlite3 v1.14.32
|
||||||
github.com/joho/godotenv v1.5.1
|
|
||||||
github.com/lib/pq v1.10.7
|
|
||||||
github.com/mattn/go-sqlite3 v1.14.16
|
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/radovskyb/watcher v1.0.7
|
github.com/radovskyb/watcher v1.0.7
|
||||||
github.com/robfig/cron v1.2.0
|
|
||||||
github.com/rubenv/sql-migrate v1.3.1
|
|
||||||
github.com/sergi/go-diff v1.3.1
|
github.com/sergi/go-diff v1.3.1
|
||||||
github.com/spf13/cobra v1.6.1
|
github.com/spf13/cobra v1.10.1
|
||||||
golang.org/x/crypto v0.6.0
|
golang.org/x/crypto v0.45.0
|
||||||
golang.org/x/time v0.3.0
|
golang.org/x/time v0.13.0
|
||||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
|
gorm.io/driver/sqlite v1.6.0
|
||||||
|
gorm.io/gorm v1.30.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/PuerkitoBio/goquery v1.8.1 // indirect
|
|
||||||
github.com/andybalholm/cascadia v1.3.1 // indirect
|
|
||||||
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
|
|
||||||
github.com/google/go-querystring v1.1.0 // indirect
|
github.com/google/go-querystring v1.1.0 // indirect
|
||||||
github.com/gorilla/css v1.0.0 // indirect
|
github.com/gorilla/securecookie v1.1.2 // indirect
|
||||||
github.com/gorilla/securecookie v1.1.1 // indirect
|
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
github.com/kr/pretty v0.3.1 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||||
golang.org/x/net v0.7.0 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
golang.org/x/sys v0.5.0 // indirect
|
github.com/spf13/pflag v1.0.10 // indirect
|
||||||
golang.org/x/term v0.5.0 // indirect
|
github.com/stretchr/testify v1.8.1 // indirect
|
||||||
|
golang.org/x/sys v0.38.0 // indirect
|
||||||
|
golang.org/x/term v0.37.0 // indirect
|
||||||
|
golang.org/x/text v0.31.0 // indirect
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||||
)
|
)
|
||||||
|
|
|
||||||
916
go.sum
916
go.sum
|
|
@ -1,919 +1,103 @@
|
||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
|
||||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
|
||||||
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
|
||||||
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
|
||||||
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
|
||||||
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
|
||||||
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
|
|
||||||
cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
|
|
||||||
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
|
|
||||||
cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
|
|
||||||
cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
|
|
||||||
cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
|
|
||||||
cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
|
|
||||||
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
|
|
||||||
cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI=
|
|
||||||
cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk=
|
|
||||||
cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg=
|
|
||||||
cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8=
|
|
||||||
cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0=
|
|
||||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
|
||||||
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
|
|
||||||
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
|
|
||||||
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
|
|
||||||
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
|
|
||||||
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
|
|
||||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
|
||||||
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
|
|
||||||
cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
|
|
||||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
|
||||||
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
|
|
||||||
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
|
|
||||||
cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
|
|
||||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
|
||||||
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
|
|
||||||
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
|
|
||||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
|
||||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
|
||||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
|
||||||
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
|
||||||
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
|
||||||
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
|
||||||
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
|
||||||
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
|
|
||||||
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
|
|
||||||
github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk=
|
|
||||||
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
|
|
||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
|
||||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
|
||||||
github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0gta/U=
|
|
||||||
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI=
|
|
||||||
github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM=
|
|
||||||
github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ=
|
|
||||||
github.com/a8m/expect v1.0.0/go.mod h1:4IwSCMumY49ScypDnjNbYEjgVeqy1/U2cEs3Lat96eA=
|
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
|
||||||
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
|
||||||
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
|
|
||||||
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
|
|
||||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
|
||||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
|
||||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
|
||||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
|
||||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
|
||||||
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
|
||||||
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
|
||||||
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
|
||||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
|
||||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
|
||||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
|
||||||
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
|
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
|
||||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
|
||||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
|
||||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
|
||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
|
||||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
|
||||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
|
||||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
|
||||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
|
||||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
|
||||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
|
||||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
|
||||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
|
||||||
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
|
||||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
|
||||||
github.com/denisenkom/go-mssqldb v0.9.0 h1:RSohk2RsiZqLZ0zCjtfn3S4Gp4exhpBWHyQ7D0yGjAk=
|
|
||||||
github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
|
||||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
|
||||||
github.com/dnote/actions v0.2.0 h1:P1ut2/QRKwfAzIIB374vN9A4IanU94C/payEocvngYo=
|
github.com/dnote/actions v0.2.0 h1:P1ut2/QRKwfAzIIB374vN9A4IanU94C/payEocvngYo=
|
||||||
github.com/dnote/actions v0.2.0/go.mod h1:bBIassLhppVQdbC3iaE92SHBpM1HOVe+xZoAlj9ROxw=
|
github.com/dnote/actions v0.2.0/go.mod h1:bBIassLhppVQdbC3iaE92SHBpM1HOVe+xZoAlj9ROxw=
|
||||||
github.com/dnote/color v1.7.0 h1:8/QGLQKSU8/zcWQaHbMyC1hJRkKO/Uu9M89sH76ecHE=
|
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
||||||
github.com/dnote/color v1.7.0/go.mod h1:75UcP/TH7CNvjQ5pwDumkUS3vkPdGggy7/3fT8MlxHM=
|
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
|
||||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
|
||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
|
||||||
github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
|
|
||||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
|
||||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
|
||||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
|
||||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
|
||||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
|
||||||
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
|
|
||||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
|
||||||
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
|
|
||||||
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/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
|
||||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
|
||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
|
||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
|
||||||
github.com/go-gorp/gorp/v3 v3.0.2 h1:ULqJXIekoqMx29FI5ekXXFoH1dT2Vc8UhnRzBg+Emz4=
|
|
||||||
github.com/go-gorp/gorp/v3 v3.0.2/go.mod h1:BJ3q1ejpV8cVALtcXvXaXyTOlMmJhWDxTmncaR6rwBY=
|
|
||||||
github.com/go-gorp/gorp/v3 v3.0.5/go.mod h1:dLEjIyyRNiXvNZ8PSmzpt1GsWAUK8kjVhEpjH8TixEw=
|
|
||||||
github.com/go-gorp/gorp/v3 v3.1.0 h1:ItKF/Vbuj31dmV4jxA1qblpSwkl9g1typ24xoe70IGs=
|
|
||||||
github.com/go-gorp/gorp/v3 v3.1.0/go.mod h1:dLEjIyyRNiXvNZ8PSmzpt1GsWAUK8kjVhEpjH8TixEw=
|
|
||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
|
||||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
|
||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
|
||||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
|
||||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
|
||||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
|
||||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
|
||||||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
|
||||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
|
||||||
github.com/gobuffalo/logger v1.0.6 h1:nnZNpxYo0zx+Aj9RfMPBm+x9zAU2OayFh/xrAWi34HU=
|
|
||||||
github.com/gobuffalo/logger v1.0.6/go.mod h1:J31TBEHR1QLV2683OXTAItYIg8pv2JMHnF/quuAbMjs=
|
|
||||||
github.com/gobuffalo/packd v1.0.1 h1:U2wXfRr4E9DH8IdsDLlRFwTZTK7hLfq9qT/QHXGVe/0=
|
|
||||||
github.com/gobuffalo/packd v1.0.1/go.mod h1:PP2POP3p3RXGz7Jh6eYEf93S7vA2za6xM7QT85L4+VY=
|
|
||||||
github.com/gobuffalo/packr/v2 v2.8.3 h1:xE1yzvnO56cUC0sTpKR3DIbxZgB54AftTFMhB2XEWlY=
|
|
||||||
github.com/gobuffalo/packr/v2 v2.8.3/go.mod h1:0SahksCVcx4IMnigTjiFuyldmTrdTctXsOdiU5KwbKc=
|
|
||||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
|
||||||
github.com/godror/godror v0.24.2/go.mod h1:wZv/9vPiUib6tkoDl+AZ/QLf5YZgMravZ7jxH2eQWAE=
|
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
|
||||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
|
||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
|
||||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
|
||||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
|
||||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
|
||||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
|
||||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
|
||||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
|
||||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
|
||||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
|
||||||
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
|
||||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
|
||||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
|
||||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
|
||||||
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
|
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
|
||||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
|
||||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
|
||||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
|
||||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
|
||||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
|
||||||
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=
|
|
||||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
|
||||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
|
||||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
|
||||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
|
||||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
|
||||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
|
||||||
github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
|
|
||||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
|
||||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
|
||||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
|
||||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
|
||||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
|
||||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
|
||||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
|
||||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
|
||||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
|
||||||
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
|
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
|
||||||
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
||||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
github.com/gorilla/csrf v1.7.3 h1:BHWt6FTLZAb2HtWT5KDBf6qgpZzvtbp9QWDRKZMXJC0=
|
||||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
github.com/gorilla/csrf v1.7.3/go.mod h1:F1Fj3KG23WYHE6gozCmBAezKookxbIvUJT+121wTuLk=
|
||||||
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||||
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||||
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E=
|
||||||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM=
|
||||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
|
||||||
github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
|
||||||
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
|
||||||
github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
|
||||||
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
|
||||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
|
||||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
|
||||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
|
||||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
|
||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
|
||||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
|
||||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
|
||||||
github.com/gorilla/csrf v1.7.1 h1:Ir3o2c1/Uzj6FBxMlAUB6SivgVMy1ONXwYgXn+/aHPE=
|
|
||||||
github.com/gorilla/csrf v1.7.1/go.mod h1:+a/4tCmqhG6/w4oafeAZ9pEa3/NZOWYVbD9fV0FwIQA=
|
|
||||||
github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
|
|
||||||
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
|
|
||||||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
|
||||||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
|
||||||
github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc=
|
|
||||||
github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU=
|
|
||||||
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
|
|
||||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
|
||||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
|
||||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
|
||||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
|
||||||
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
|
|
||||||
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
|
||||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
|
||||||
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
|
||||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
|
||||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
|
||||||
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
|
||||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
|
||||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
|
||||||
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
|
||||||
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
|
||||||
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
|
|
||||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
|
||||||
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
|
||||||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
|
||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
|
||||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
|
||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
|
||||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
|
||||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
|
||||||
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
|
||||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
|
||||||
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
|
||||||
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
|
||||||
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
|
||||||
github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
|
||||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
|
||||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
|
||||||
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
|
||||||
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
|
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
|
||||||
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
|
|
||||||
github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
|
|
||||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
|
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
|
|
||||||
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
|
||||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
|
||||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
|
||||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
|
||||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
|
||||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
|
||||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
|
||||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
|
||||||
github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw=
|
|
||||||
github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
|
|
||||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
|
||||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
|
||||||
github.com/kortschak/utter v1.0.1/go.mod h1:vSmSjbyrlKjjsL71193LmzBOKgwePk9DH6uFaWHIInc=
|
|
||||||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
|
||||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
|
||||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||||
github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/lib/pq v1.10.5 h1:J+gdV2cUmX7ZqL2B0lFcW0m+egaHC2V3lpO8nWxyYiQ=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/lib/pq v1.10.5/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
|
||||||
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
|
github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||||
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
|
||||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
|
||||||
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
|
||||||
github.com/markbates/errx v1.1.0 h1:QDFeR+UP95dO12JgW+tgi2UVfo0V8YBHiUIOaeBPiEI=
|
|
||||||
github.com/markbates/errx v1.1.0/go.mod h1:PLa46Oex9KNbVDZhKel8v1OT7hD5JZ2eI7AHhA0wswc=
|
|
||||||
github.com/markbates/oncer v1.0.0 h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY=
|
|
||||||
github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2aSZ0mcI=
|
|
||||||
github.com/markbates/safe v1.0.1 h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI=
|
|
||||||
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
|
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
|
||||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
|
||||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
|
||||||
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
|
|
||||||
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-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
|
||||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
|
||||||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
|
||||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
|
||||||
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.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
|
||||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
|
||||||
github.com/mattn/go-oci8 v0.1.1/go.mod h1:wjDx6Xm9q7dFtHJvIlrI99JytznLw5wQ4R+9mNXJwGI=
|
|
||||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
|
||||||
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
|
||||||
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
|
||||||
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
|
||||||
github.com/mattn/go-sqlite3 v1.14.12 h1:TJ1bhYJPV44phC+IMu1u2K/i5RriLTPe+yc68XDJ1Z0=
|
|
||||||
github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
|
||||||
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
|
||||||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
|
||||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
|
||||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
|
||||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
|
||||||
github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4=
|
|
||||||
github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4=
|
|
||||||
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
|
|
||||||
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
|
|
||||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
|
||||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
|
||||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
|
||||||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
|
||||||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
|
||||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
|
||||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
|
||||||
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
|
||||||
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
|
||||||
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
|
||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
|
||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
|
||||||
github.com/nelsam/hel/v2 v2.3.2/go.mod h1:1ZTGfU2PFTOd5mx22i5O0Lc2GY933lQ2wb/ggy+rL3w=
|
|
||||||
github.com/nelsam/hel/v2 v2.3.3/go.mod h1:1ZTGfU2PFTOd5mx22i5O0Lc2GY933lQ2wb/ggy+rL3w=
|
|
||||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
|
||||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
|
||||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
|
||||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
|
||||||
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
|
||||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
|
||||||
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
|
|
||||||
github.com/poy/onpar v0.0.0-20190519213022-ee068f8ea4d1 h1:oL4IBbcqwhhNWh31bjOX8C/OCy0zs9906d/VUru+bqg=
|
|
||||||
github.com/poy/onpar v0.0.0-20190519213022-ee068f8ea4d1/go.mod h1:nSbFQvMj97ZyhFRSJYtut+msi4sOY6zJDGCdSc+/rZU=
|
|
||||||
github.com/poy/onpar v0.0.0-20200406201722-06f95a1c68e8/go.mod h1:nSbFQvMj97ZyhFRSJYtut+msi4sOY6zJDGCdSc+/rZU=
|
|
||||||
github.com/poy/onpar v1.1.2 h1:QaNrNiZx0+Nar5dLgTVp5mXkyoVFIbepjyEoGSnhbAY=
|
|
||||||
github.com/poy/onpar v1.1.2/go.mod h1:6X8FLNoxyr9kkmnlqpK6LSoiOtrO6MICtWwEuWkLjzg=
|
|
||||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
|
||||||
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
|
||||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
|
||||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
|
||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
|
||||||
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
|
||||||
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
|
||||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
|
||||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
|
||||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
|
||||||
github.com/radovskyb/watcher v1.0.7 h1:AYePLih6dpmS32vlHfhCeli8127LzkIgwJGcwwe8tUE=
|
github.com/radovskyb/watcher v1.0.7 h1:AYePLih6dpmS32vlHfhCeli8127LzkIgwJGcwwe8tUE=
|
||||||
github.com/radovskyb/watcher v1.0.7/go.mod h1:78okwvY5wPdzcb1UYnip1pvrZNIVEIh/Cm+ZuvsUYIg=
|
github.com/radovskyb/watcher v1.0.7/go.mod h1:78okwvY5wPdzcb1UYnip1pvrZNIVEIh/Cm+ZuvsUYIg=
|
||||||
github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
|
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||||
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
|
|
||||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
|
||||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
|
||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
|
||||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
|
||||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
github.com/rubenv/sql-migrate v1.1.1 h1:haR5Hn8hbW9/SpAICrXoZqXnywS7Q5WijwkQENPeNWY=
|
|
||||||
github.com/rubenv/sql-migrate v1.1.1/go.mod h1:/7TZymwxN8VWumcIxw1jjHEcR1djpdkMHQPT4FWdnbQ=
|
|
||||||
github.com/rubenv/sql-migrate v1.3.1 h1:Vx+n4Du8X8VTYuXbhNxdEUoh6wiJERA0GlWocR5FrbA=
|
|
||||||
github.com/rubenv/sql-migrate v1.3.1/go.mod h1:YzG/Vh82CwyhTFXy+Mf5ahAiiEOpAlHurg+23VEzcsk=
|
|
||||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
|
||||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
|
||||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
|
||||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
|
||||||
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
||||||
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
||||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
|
||||||
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
|
||||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
|
||||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
|
||||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
|
||||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
|
||||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
|
||||||
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
|
|
||||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
|
||||||
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
|
||||||
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
|
|
||||||
github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
|
|
||||||
github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
|
|
||||||
github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q=
|
|
||||||
github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g=
|
|
||||||
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
|
|
||||||
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
|
|
||||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
|
||||||
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
|
||||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
|
||||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
|
||||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
|
||||||
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
|
|
||||||
github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
|
||||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
||||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
|
||||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
||||||
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
golang.org/x/time v0.13.0 h1:eUlYslOIt32DgYD6utsuUeHs4d7AsEYLuIAdg7FlYgI=
|
||||||
github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
|
golang.org/x/time v0.13.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
|
||||||
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
|
|
||||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
|
||||||
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
|
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
|
||||||
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
|
|
||||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
|
||||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
|
||||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
|
||||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
|
||||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
|
||||||
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
|
||||||
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
|
|
||||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
|
||||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
|
||||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
|
||||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
|
||||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
|
||||||
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
|
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
|
||||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
|
||||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
|
||||||
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122 h1:NvGWuYG8dkDHFSKksI1P9faiVJ9rayE6l0+ouWVIDs8=
|
|
||||||
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
|
||||||
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
|
||||||
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
|
|
||||||
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
|
|
||||||
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
|
||||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
|
||||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
|
||||||
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
|
||||||
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
|
||||||
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
|
||||||
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
|
||||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
|
||||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
|
||||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
|
||||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
|
||||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
|
||||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
|
||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
|
||||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
|
||||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
|
||||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
|
||||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
|
||||||
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
|
||||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
|
||||||
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
|
||||||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
|
||||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
|
||||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
|
||||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
|
||||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
|
||||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
|
||||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
|
||||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
|
||||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/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-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
|
||||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
|
||||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
|
||||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
|
||||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
|
||||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
|
||||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
|
||||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
|
||||||
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
|
||||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
|
||||||
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
|
||||||
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
|
||||||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
|
||||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA=
|
|
||||||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
|
||||||
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.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
|
||||||
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
|
|
||||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60=
|
|
||||||
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
|
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
|
||||||
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 h1:EH1Deb8WZJ0xc0WK//leUHXcX9aLE5SymusoTmMZye8=
|
|
||||||
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
|
||||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
|
||||||
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
|
|
||||||
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
|
|
||||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
|
||||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
|
||||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
|
||||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
|
||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
|
||||||
golang.org/x/time v0.0.0-20220411224347-583f2d630306 h1:+gHMid33q6pen7kv9xvT+JRinntgeXO2AeZVd0AWD3w=
|
|
||||||
golang.org/x/time v0.0.0-20220411224347-583f2d630306/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
|
||||||
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
|
|
||||||
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
|
||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
|
||||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
|
||||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
|
||||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
|
||||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
|
||||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
|
||||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
|
||||||
golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
|
||||||
golang.org/x/tools v0.0.0-20200313205530-4303120df7d8/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
|
||||||
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
|
||||||
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
|
||||||
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
|
||||||
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
|
||||||
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
|
||||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
|
||||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
|
||||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
|
||||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
|
||||||
golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE=
|
|
||||||
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
|
||||||
golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
|
||||||
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
|
||||||
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
|
||||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
|
||||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
|
||||||
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
|
||||||
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
|
||||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
|
||||||
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
|
||||||
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
|
||||||
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
|
||||||
google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
|
||||||
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
|
||||||
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
|
||||||
google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
|
||||||
google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
|
||||||
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
|
||||||
google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
|
||||||
google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
|
||||||
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
|
||||||
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
|
|
||||||
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
|
|
||||||
google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg=
|
|
||||||
google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE=
|
|
||||||
google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8=
|
|
||||||
google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU=
|
|
||||||
google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94=
|
|
||||||
google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8=
|
|
||||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
|
||||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
|
||||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
|
||||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
|
||||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
|
||||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
|
||||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
|
||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
|
||||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
|
||||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
|
||||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
|
||||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
|
||||||
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
|
||||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
|
||||||
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
|
||||||
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
|
||||||
google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
|
||||||
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
|
||||||
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
|
||||||
google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
|
||||||
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
|
||||||
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
|
|
||||||
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
|
|
||||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
|
||||||
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
|
||||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
|
||||||
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
|
|
||||||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
|
||||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
|
||||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
|
||||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
|
||||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
|
||||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
|
||||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
|
||||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
|
||||||
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
|
||||||
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
|
||||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
|
||||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
|
||||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
|
||||||
google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
|
||||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
|
||||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
|
||||||
google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8=
|
|
||||||
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
|
||||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
|
||||||
google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
|
||||||
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
|
||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
|
||||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
|
||||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
|
||||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
|
||||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
|
||||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
|
||||||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
|
||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
|
||||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
|
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
|
||||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
|
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
|
||||||
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
|
||||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
|
||||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
|
||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
gorm.io/driver/sqlite v1.6.0 h1:WHRRrIiulaPiPFmDcod6prc4l2VGVWHz80KspNsxSfQ=
|
||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
gorm.io/driver/sqlite v1.6.0/go.mod h1:AO9V1qIQddBESngQUKWL9yoH93HIeA1X6V633rBwyT8=
|
||||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
gorm.io/gorm v1.30.0 h1:qbT5aPv1UH8gI99OsRlvDToLxW5zR7FzS9acZDOZcgs=
|
||||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
gorm.io/gorm v1.30.0/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE=
|
||||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
|
||||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
|
||||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
|
||||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
|
||||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
|
||||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,40 @@
|
||||||
FROM alpine:latest
|
FROM busybox:glibc
|
||||||
|
|
||||||
ARG tarballName
|
ARG TARGETPLATFORM
|
||||||
RUN test -n "$tarballName"
|
ARG version
|
||||||
|
|
||||||
# add dependency to execute a golang binary with dynamical linking.
|
RUN test -n "$TARGETPLATFORM" || (echo "TARGETPLATFORM is required" && exit 1)
|
||||||
RUN apk add --no-cache \
|
RUN test -n "$version" || (echo "version is required" && exit 1)
|
||||||
libc6-compat
|
|
||||||
|
|
||||||
WORKDIR dnote
|
WORKDIR /tmp/tarballs
|
||||||
|
|
||||||
COPY "$tarballName" .
|
# Copy all architecture tarballs
|
||||||
RUN tar -xvzf "$tarballName"
|
COPY dnote_server_*.tar.gz ./
|
||||||
|
|
||||||
|
# Select and extract the correct tarball based on target platform
|
||||||
|
RUN case "$TARGETPLATFORM" in \
|
||||||
|
"linux/amd64") ARCH="amd64" ;; \
|
||||||
|
"linux/arm64") ARCH="arm64" ;; \
|
||||||
|
"linux/arm/v7") ARCH="arm" ;; \
|
||||||
|
"linux/386") ARCH="386" ;; \
|
||||||
|
*) echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \
|
||||||
|
esac && \
|
||||||
|
TARBALL="dnote_server_${version}_linux_${ARCH}.tar.gz" && \
|
||||||
|
echo "Extracting $TARBALL for $TARGETPLATFORM" && \
|
||||||
|
mkdir -p /dnote && \
|
||||||
|
tar -xvzf "$TARBALL" -C /dnote
|
||||||
|
|
||||||
|
WORKDIR /dnote
|
||||||
|
|
||||||
|
# Set default database path for all processes (main server, docker exec, shells)
|
||||||
|
ENV DBPath=/data/dnote.db
|
||||||
|
|
||||||
COPY entrypoint.sh .
|
COPY entrypoint.sh .
|
||||||
ENTRYPOINT ["./entrypoint.sh"]
|
ENTRYPOINT ["./entrypoint.sh"]
|
||||||
|
|
||||||
CMD ./dnote-server start
|
CMD ./dnote-server start
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3001
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \
|
||||||
|
CMD wget --no-verbose --tries=1 -O /dev/null http://localhost:3001/health || exit 1
|
||||||
|
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
# Dnote Docker Image
|
|
||||||
|
|
||||||
The official Dnote docker image.
|
|
||||||
|
|
||||||
## Installing Dnote Server Using Docker
|
|
||||||
|
|
||||||
1. Install [Docker](https://docs.docker.com/install/).
|
|
||||||
2. Install Docker [Compose](https://docs.docker.com/compose/install/).
|
|
||||||
3. Download the [docker-compose.yml](https://raw.githubusercontent.com/dnote/dnote/master/host/docker/docker-compose.yml) file by running:
|
|
||||||
|
|
||||||
```
|
|
||||||
curl https://raw.githubusercontent.com/dnote/dnote/master/host/docker/docker-compose.yml > docker-compose.yml
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Run the following to download the images and run the containers
|
|
||||||
|
|
||||||
```
|
|
||||||
docker-compose pull
|
|
||||||
docker-compose up -d
|
|
||||||
```
|
|
||||||
|
|
||||||
Visit http://localhost:3000 in your browser to see Dnote running.
|
|
||||||
|
|
||||||
Please see [the installation guide](https://github.com/dnote/dnote/blob/master/SELF_HOSTING.md) for further configuration.
|
|
||||||
|
|
||||||
## Supported platform
|
|
||||||
|
|
||||||
Currently, the official Docker image for Dnote supports Linux running AMD64 CPU architecture.
|
|
||||||
|
|
||||||
If you run ARM64, please install Dnote server by downloading a binary distribution by following [the guide](https://github.com/dnote/dnote/blob/master/SELF_HOSTING.md).
|
|
||||||
|
|
@ -1,13 +1,85 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# Build Docker image for local testing
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# # builds for host platform (auto-detected)
|
||||||
|
# ./build.sh 1.0.0
|
||||||
|
#
|
||||||
|
# # builds arm64
|
||||||
|
# ./build.sh 1.0.0 linux/arm64
|
||||||
|
#
|
||||||
|
# # builds multiple platforms
|
||||||
|
# ./build.sh 1.0.0 "linux/amd64,linux/arm64,linux/arm/v7,linux/386"
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
version=$1
|
version=$1
|
||||||
|
|
||||||
|
# Detect host platform if not specified
|
||||||
|
if [ -z "${2:-}" ]; then
|
||||||
|
HOST_ARCH=$(uname -m)
|
||||||
|
case "$HOST_ARCH" in
|
||||||
|
x86_64) platform="linux/amd64" ;;
|
||||||
|
aarch64|arm64) platform="linux/arm64" ;;
|
||||||
|
armv7l) platform="linux/arm/v7" ;;
|
||||||
|
i386|i686) platform="linux/386" ;;
|
||||||
|
*)
|
||||||
|
echo "Warning: Unsupported architecture: $HOST_ARCH, defaulting to linux/amd64"
|
||||||
|
platform="linux/amd64"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo "Auto-detected platform: $platform"
|
||||||
|
else
|
||||||
|
platform=$2
|
||||||
|
fi
|
||||||
|
|
||||||
dir=$(dirname "${BASH_SOURCE[0]}")
|
dir=$(dirname "${BASH_SOURCE[0]}")
|
||||||
projectDir="$dir/../.."
|
projectDir="$dir/../.."
|
||||||
tarballName="dnote_server_${version}_linux_amd64.tar.gz"
|
|
||||||
|
|
||||||
# copy over the build artifact to the Docker build context
|
# Copy all Linux tarballs to Docker build context
|
||||||
cp "$projectDir/build/server/$tarballName" "$dir"
|
cp "$projectDir/build/server/dnote_server_${version}_linux_amd64.tar.gz" "$dir/"
|
||||||
|
cp "$projectDir/build/server/dnote_server_${version}_linux_arm64.tar.gz" "$dir/"
|
||||||
|
cp "$projectDir/build/server/dnote_server_${version}_linux_arm.tar.gz" "$dir/"
|
||||||
|
cp "$projectDir/build/server/dnote_server_${version}_linux_386.tar.gz" "$dir/"
|
||||||
|
|
||||||
docker build --network=host -t dnote/dnote:"$version" --build-arg tarballName="$tarballName" .
|
# Count platforms (check for comma)
|
||||||
|
if [[ "$platform" == *","* ]]; then
|
||||||
|
echo "Building for multiple platforms: $platform"
|
||||||
|
|
||||||
|
# Check if multiarch builder exists, create if not
|
||||||
|
if ! docker buildx ls | grep -q "multiarch"; then
|
||||||
|
echo "Creating multiarch builder for multi-platform builds..."
|
||||||
|
docker buildx create --name multiarch --use
|
||||||
|
docker buildx inspect --bootstrap
|
||||||
|
else
|
||||||
|
echo "Using existing multiarch builder"
|
||||||
|
docker buildx use multiarch
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
docker buildx build \
|
||||||
|
--platform "$platform" \
|
||||||
|
-t dnote/dnote:"$version" \
|
||||||
|
-t dnote/dnote:latest \
|
||||||
|
--build-arg version="$version" \
|
||||||
|
"$dir"
|
||||||
|
|
||||||
|
# Switch back to default builder
|
||||||
|
docker buildx use default
|
||||||
|
else
|
||||||
|
echo "Building for single platform: $platform"
|
||||||
|
echo "Image will be loaded to local Docker daemon"
|
||||||
|
|
||||||
|
docker buildx build \
|
||||||
|
--platform "$platform" \
|
||||||
|
-t dnote/dnote:"$version" \
|
||||||
|
-t dnote/dnote:latest \
|
||||||
|
--build-arg version="$version" \
|
||||||
|
--load \
|
||||||
|
"$dir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Build complete!"
|
||||||
|
if [[ "$platform" != *","* ]]; then
|
||||||
|
echo "Test with: docker run --rm dnote/dnote:$version ./dnote-server version"
|
||||||
|
fi
|
||||||
|
|
|
||||||
9
host/docker/compose.yml
Normal file
9
host/docker/compose.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
services:
|
||||||
|
dnote:
|
||||||
|
image: dnote/dnote:latest
|
||||||
|
container_name: dnote
|
||||||
|
ports:
|
||||||
|
- 3001:3001
|
||||||
|
volumes:
|
||||||
|
- ./dnote_data:/data
|
||||||
|
restart: unless-stopped
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
version: "3"
|
|
||||||
|
|
||||||
services:
|
|
||||||
postgres:
|
|
||||||
image: postgres:14-alpine
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: dnote
|
|
||||||
POSTGRES_PASSWORD: dnote
|
|
||||||
POSTGRES_DB: dnote
|
|
||||||
volumes:
|
|
||||||
- ./dnote_data:/var/lib/postgresql/data
|
|
||||||
restart: always
|
|
||||||
|
|
||||||
dnote:
|
|
||||||
image: dnote/dnote:latest
|
|
||||||
environment:
|
|
||||||
GO_ENV: PRODUCTION
|
|
||||||
DBSkipSSL: "true"
|
|
||||||
DBHost: postgres
|
|
||||||
DBPort: 5432
|
|
||||||
DBName: dnote
|
|
||||||
DBUser: dnote
|
|
||||||
DBPassword: dnote
|
|
||||||
WebURL: localhost:3000
|
|
||||||
OnPremise: "true"
|
|
||||||
SmtpHost:
|
|
||||||
SmtpPort:
|
|
||||||
SmtpUsername:
|
|
||||||
SmtpPassword:
|
|
||||||
DisableRegistration: "false"
|
|
||||||
ports:
|
|
||||||
- 3000:3000
|
|
||||||
depends_on:
|
|
||||||
- postgres
|
|
||||||
restart: always
|
|
||||||
|
|
@ -1,25 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
wait_for_db() {
|
# Set default DBPath to /data if not specified
|
||||||
HOST=${DBHost:-postgres}
|
export DBPath=${DBPath:-/data/dnote.db}
|
||||||
PORT=${DBPort:-5432}
|
|
||||||
echo "Waiting for the database connection..."
|
|
||||||
|
|
||||||
attempts=0
|
|
||||||
max_attempts=10
|
|
||||||
while [ $attempts -lt $max_attempts ]; do
|
|
||||||
nc -z "${HOST}" "${PORT}" 2>/dev/null && break
|
|
||||||
echo "Waiting for db at ${HOST}:${PORT}..."
|
|
||||||
sleep 5
|
|
||||||
attempts=$((attempts+1))
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ $attempts -eq $max_attempts ]; then
|
|
||||||
echo "Timed out while waiting for db at ${HOST}:${PORT}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
wait_for_db
|
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -eux
|
|
||||||
|
|
||||||
version=$1
|
|
||||||
|
|
||||||
docker login
|
|
||||||
|
|
||||||
# tag the release
|
|
||||||
docker tag dnote/dnote:"$version" dnote/dnote:latest
|
|
||||||
|
|
||||||
# publish
|
|
||||||
docker push dnote/dnote:"$version"
|
|
||||||
docker push dnote/dnote:latest
|
|
||||||
1
host/smoketest/.gitignore
vendored
1
host/smoketest/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
||||||
/volume
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
This directory contains a smoke test for running a self-hosted instance using a virtual machine.
|
|
||||||
9
host/smoketest/Vagrantfile
vendored
9
host/smoketest/Vagrantfile
vendored
|
|
@ -1,9 +0,0 @@
|
||||||
# -*- mode: ruby -*-
|
|
||||||
|
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
config.vm.box = "ubuntu/bionic64"
|
|
||||||
config.vm.synced_folder './volume', '/vagrant'
|
|
||||||
config.vm.network "forwarded_port", guest: 2300, host: 2300
|
|
||||||
|
|
||||||
config.vm.provision 'shell', path: './setup.sh', privileged: false
|
|
||||||
end
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
# run_test.sh builds a fresh server image, and mounts it on a fresh
|
|
||||||
# virtual machine and runs a smoke test. If a tarball path is not provided,
|
|
||||||
# this script builds a new version and uses it.
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
# tarballPath is an absolute path to a release tarball containing the dnote server.
|
|
||||||
tarballPath=$1
|
|
||||||
|
|
||||||
dir=$(dirname "${BASH_SOURCE[0]}")
|
|
||||||
projectDir="$dir/../.."
|
|
||||||
|
|
||||||
# build
|
|
||||||
if [ -z "$tarballPath" ]; then
|
|
||||||
pushd "$projectDir"
|
|
||||||
make version=integration_test build-server
|
|
||||||
popd
|
|
||||||
tarballPath="$projectDir/build/server/dnote_server_integration_test_linux_amd64.tar.gz"
|
|
||||||
fi
|
|
||||||
|
|
||||||
pushd "$dir"
|
|
||||||
|
|
||||||
# start a virtual machine
|
|
||||||
volume="$dir/volume"
|
|
||||||
rm -rf "$volume"
|
|
||||||
mkdir -p "$volume"
|
|
||||||
cp "$tarballPath" "$volume"
|
|
||||||
cp "$dir/testsuite.sh" "$volume"
|
|
||||||
|
|
||||||
vagrant up
|
|
||||||
|
|
||||||
# run tests
|
|
||||||
set +e
|
|
||||||
if ! vagrant ssh -c "/vagrant/testsuite.sh"; then
|
|
||||||
echo "Test failed. Please see the output."
|
|
||||||
vagrant halt
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
set -e
|
|
||||||
|
|
||||||
vagrant halt
|
|
||||||
popd
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
sudo apt-get install wget ca-certificates
|
|
||||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
|
||||||
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
|
|
||||||
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y postgresql-14
|
|
||||||
|
|
||||||
# set up database
|
|
||||||
sudo -u postgres createdb dnote
|
|
||||||
# allow connection from host and allow to connect without password
|
|
||||||
sudo sed -i "/port*/a listen_addresses = '*'" /etc/postgresql/14/main/postgresql.conf
|
|
||||||
sudo sed -i 's/host.*all.*.all.*md5/# &/' /etc/postgresql/14/main/pg_hba.conf
|
|
||||||
sudo sed -i "$ a host all all all trust" /etc/postgresql/14/main/pg_hba.conf
|
|
||||||
sudo service postgresql restart
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
# testsuite.sh runs the smoke tests for a self-hosted instance.
|
|
||||||
# It is meant to be run inside a virtual machine which has been
|
|
||||||
# set up by an entry script.
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
echo 'Running a smoke test'
|
|
||||||
|
|
||||||
sudo -u postgres dropdb dnote
|
|
||||||
sudo -u postgres createdb dnote
|
|
||||||
|
|
||||||
cd /vagrant
|
|
||||||
|
|
||||||
tar -xvf dnote_server_integration_test_linux_amd64.tar.gz
|
|
||||||
|
|
||||||
GO_ENV=PRODUCTION \
|
|
||||||
DBHost=localhost \
|
|
||||||
DBPort=5432 \
|
|
||||||
DBName=dnote \
|
|
||||||
DBUser=postgres \
|
|
||||||
DBPassword="" \
|
|
||||||
WebURL=localhost:3000 \
|
|
||||||
./dnote-server -port 2300 start & sleep 3
|
|
||||||
|
|
||||||
assert_http_status() {
|
|
||||||
url=$1
|
|
||||||
expected=$2
|
|
||||||
|
|
||||||
echo "======== [TEST CASE] asserting response status code for $url ========"
|
|
||||||
|
|
||||||
got=$(curl --write-out %"{http_code}" --silent --output /dev/null "$url")
|
|
||||||
|
|
||||||
if [ "$got" != "$expected" ]; then
|
|
||||||
echo "======== ASSERTION FAILED ========"
|
|
||||||
echo "status code for $url: expected: $expected got: $got"
|
|
||||||
echo "=================================="
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_http_status http://localhost:2300 "302"
|
|
||||||
assert_http_status http://localhost:2300/health "200"
|
|
||||||
|
|
||||||
echo "======== [SUCCESS] TEST PASSED! ========"
|
|
||||||
17
install.sh
17
install.sh
|
|
@ -68,9 +68,14 @@ uname_os() {
|
||||||
|
|
||||||
uname_arch() {
|
uname_arch() {
|
||||||
arch=$(uname -m)
|
arch=$(uname -m)
|
||||||
case $arch in
|
case $arch in
|
||||||
x86_64) arch="amd64" ;;
|
x86_64) arch="amd64" ;;
|
||||||
aarch64) arch="arm64" ;;
|
aarch64) arch="arm64" ;;
|
||||||
|
arm64) arch="arm64" ;;
|
||||||
|
armv7l) arch="arm" ;;
|
||||||
|
armv6l) arch="arm" ;;
|
||||||
|
armv5l) arch="arm" ;;
|
||||||
|
arm) arch="arm" ;;
|
||||||
x86) arch="386" ;;
|
x86) arch="386" ;;
|
||||||
i686) arch="386" ;;
|
i686) arch="386" ;;
|
||||||
i386) arch="386" ;;
|
i386) arch="386" ;;
|
||||||
|
|
@ -86,9 +91,17 @@ check_platform() {
|
||||||
|
|
||||||
found=1
|
found=1
|
||||||
case "$platform" in
|
case "$platform" in
|
||||||
darwin/amd64) found=0;;
|
# Linux
|
||||||
linux/amd64) found=0 ;;
|
linux/amd64) found=0 ;;
|
||||||
linux/arm64) found=0 ;;
|
linux/arm64) found=0 ;;
|
||||||
|
linux/arm) found=0 ;;
|
||||||
|
# macOS
|
||||||
|
darwin/amd64) found=0 ;;
|
||||||
|
darwin/arm64) found=0 ;;
|
||||||
|
# Windows
|
||||||
|
windows/amd64) found=0 ;;
|
||||||
|
# FreeBSD
|
||||||
|
freebsd/amd64) found=0 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
return $found
|
return $found
|
||||||
|
|
|
||||||
|
|
@ -1,661 +0,0 @@
|
||||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 19 November 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU Affero General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works, specifically designed to ensure
|
|
||||||
cooperation with the community in the case of network server software.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
our General Public Licenses are intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
Developers that use our General Public Licenses protect your rights
|
|
||||||
with two steps: (1) assert copyright on the software, and (2) offer
|
|
||||||
you this License which gives you legal permission to copy, distribute
|
|
||||||
and/or modify the software.
|
|
||||||
|
|
||||||
A secondary benefit of defending all users' freedom is that
|
|
||||||
improvements made in alternate versions of the program, if they
|
|
||||||
receive widespread use, become available for other developers to
|
|
||||||
incorporate. Many developers of free software are heartened and
|
|
||||||
encouraged by the resulting cooperation. However, in the case of
|
|
||||||
software used on network servers, this result may fail to come about.
|
|
||||||
The GNU General Public License permits making a modified version and
|
|
||||||
letting the public access it on a server without ever releasing its
|
|
||||||
source code to the public.
|
|
||||||
|
|
||||||
The GNU Affero General Public License is designed specifically to
|
|
||||||
ensure that, in such cases, the modified source code becomes available
|
|
||||||
to the community. It requires the operator of a network server to
|
|
||||||
provide the source code of the modified version running there to the
|
|
||||||
users of that server. Therefore, public use of a modified version, on
|
|
||||||
a publicly accessible server, gives the public access to the source
|
|
||||||
code of the modified version.
|
|
||||||
|
|
||||||
An older license, called the Affero General Public License and
|
|
||||||
published by Affero, was designed to accomplish similar goals. This is
|
|
||||||
a different license, not a version of the Affero GPL, but Affero has
|
|
||||||
released a new version of the Affero GPL which permits relicensing under
|
|
||||||
this license.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, if you modify the
|
|
||||||
Program, your modified version must prominently offer all users
|
|
||||||
interacting with it remotely through a computer network (if your version
|
|
||||||
supports such interaction) an opportunity to receive the Corresponding
|
|
||||||
Source of your version by providing access to the Corresponding Source
|
|
||||||
from a network server at no charge, through some standard or customary
|
|
||||||
means of facilitating copying of software. This Corresponding Source
|
|
||||||
shall include the Corresponding Source for any work covered by version 3
|
|
||||||
of the GNU General Public License that is incorporated pursuant to the
|
|
||||||
following paragraph.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the work with which it is combined will remain governed by version
|
|
||||||
3 of the GNU General Public License.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU Affero General Public License from time to time. Such new versions
|
|
||||||
will be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU Affero General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU Affero General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU Affero General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published
|
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If your software can interact with users remotely through a computer
|
|
||||||
network, you should also make sure that it provides a way for users to
|
|
||||||
get its source. For example, if your program is a web application, its
|
|
||||||
interface could display a "Source" link that leads users to an archive
|
|
||||||
of the code. There are many ways you could offer source, and different
|
|
||||||
solutions will be better for different programs; see section 13 for the
|
|
||||||
specific requirements.
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
|
||||||
<https://www.gnu.org/licenses/>.
|
|
||||||
|
|
@ -1,674 +0,0 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
<https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Package assert provides functions to assert a condition in tests
|
// Package assert provides functions to assert a condition in tests
|
||||||
|
|
@ -22,7 +19,7 @@ package assert
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
|
@ -138,7 +135,7 @@ func EqualJSON(t *testing.T, a, b, message string) {
|
||||||
// expected
|
// expected
|
||||||
func StatusCodeEquals(t *testing.T, res *http.Response, expected int, message string) {
|
func StatusCodeEquals(t *testing.T, res *http.Response, expected int, message string) {
|
||||||
if res.StatusCode != expected {
|
if res.StatusCode != expected {
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := io.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(errors.Wrap(err, "reading body"))
|
t.Fatal(errors.Wrap(err, "reading body"))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
84
pkg/assert/prompt.go
Normal file
84
pkg/assert/prompt.go
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
/* Copyright 2025 Dnote Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package assert
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"io"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// WaitForPrompt waits for an expected prompt to appear in stdout with a timeout.
|
||||||
|
// Returns an error if the prompt is not found within the timeout period.
|
||||||
|
// Handles prompts with or without newlines by reading character by character.
|
||||||
|
func WaitForPrompt(stdout io.Reader, expectedPrompt string, timeout time.Duration) error {
|
||||||
|
type result struct {
|
||||||
|
found bool
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
resultCh := make(chan result, 1)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
reader := bufio.NewReader(stdout)
|
||||||
|
var buffer strings.Builder
|
||||||
|
found := false
|
||||||
|
|
||||||
|
for {
|
||||||
|
b, err := reader.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
resultCh <- result{found: found, err: err}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.WriteByte(b)
|
||||||
|
if strings.Contains(buffer.String(), expectedPrompt) {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resultCh <- result{found: found, err: nil}
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case res := <-resultCh:
|
||||||
|
if res.err != nil && res.err != io.EOF {
|
||||||
|
return errors.Wrap(res.err, "reading stdout")
|
||||||
|
}
|
||||||
|
if !res.found {
|
||||||
|
return errors.Errorf("expected prompt '%s' not found in stdout", expectedPrompt)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
case <-time.After(timeout):
|
||||||
|
return errors.Errorf("timeout waiting for prompt '%s'", expectedPrompt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RespondToPrompt is a helper that waits for a prompt and sends a response.
|
||||||
|
func RespondToPrompt(stdout io.Reader, stdin io.WriteCloser, expectedPrompt, response string, timeout time.Duration) error {
|
||||||
|
if err := WaitForPrompt(stdout, expectedPrompt, timeout); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.WriteString(stdin, response); err != nil {
|
||||||
|
return errors.Wrap(err, "writing response to stdin")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
@ -94,20 +94,14 @@ dnote find "merge sort" -b algorithm
|
||||||
|
|
||||||
## dnote sync
|
## dnote sync
|
||||||
|
|
||||||
_Dnote Pro only_
|
|
||||||
|
|
||||||
_alias: s_
|
_alias: s_
|
||||||
|
|
||||||
Sync notes with Dnote server. All your data is encrypted before being sent to the server.
|
Sync notes with Dnote server.
|
||||||
|
|
||||||
## dnote login
|
## dnote login
|
||||||
|
|
||||||
_Dnote Pro only_
|
|
||||||
|
|
||||||
Start a login prompt.
|
Start a login prompt.
|
||||||
|
|
||||||
## dnote logout
|
## dnote logout
|
||||||
|
|
||||||
_Dnote Pro only_
|
|
||||||
|
|
||||||
Log out of Dnote.
|
Log out of Dnote.
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Package client provides interfaces for interacting with the Dnote server
|
// Package client provides interfaces for interacting with the Dnote server
|
||||||
|
|
@ -23,7 +20,7 @@ package client
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -33,6 +30,7 @@ import (
|
||||||
"github.com/dnote/dnote/pkg/cli/context"
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
"github.com/dnote/dnote/pkg/cli/log"
|
"github.com/dnote/dnote/pkg/cli/log"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"golang.org/x/time/rate"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrInvalidLogin is an error for invalid credentials for login
|
// ErrInvalidLogin is an error for invalid credentials for login
|
||||||
|
|
@ -41,18 +39,84 @@ var ErrInvalidLogin = errors.New("wrong credentials")
|
||||||
// ErrContentTypeMismatch is an error for invalid credentials for login
|
// ErrContentTypeMismatch is an error for invalid credentials for login
|
||||||
var ErrContentTypeMismatch = errors.New("content type mismatch")
|
var ErrContentTypeMismatch = errors.New("content type mismatch")
|
||||||
|
|
||||||
|
// HTTPError represents an HTTP error response from the server
|
||||||
|
type HTTPError struct {
|
||||||
|
StatusCode int
|
||||||
|
Message string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *HTTPError) Error() string {
|
||||||
|
return fmt.Sprintf(`response %d "%s"`, e.StatusCode, e.Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsConflict returns true if the error is a 409 Conflict error
|
||||||
|
func (e *HTTPError) IsConflict() bool {
|
||||||
|
return e.StatusCode == 409
|
||||||
|
}
|
||||||
|
|
||||||
var contentTypeApplicationJSON = "application/json"
|
var contentTypeApplicationJSON = "application/json"
|
||||||
var contentTypeNone = ""
|
var contentTypeNone = ""
|
||||||
|
|
||||||
// requestOptions contians options for requests
|
// requestOptions contains options for requests
|
||||||
type requestOptions struct {
|
type requestOptions struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
// ExpectedContentType is the Content-Type that the client is expecting from the server
|
// ExpectedContentType is the Content-Type that the client is expecting from the server
|
||||||
ExpectedContentType *string
|
ExpectedContentType *string
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultRequestOptions = requestOptions{
|
const (
|
||||||
ExpectedContentType: &contentTypeApplicationJSON,
|
// clientRateLimitPerSecond is the max requests per second the client will make
|
||||||
|
clientRateLimitPerSecond = 50
|
||||||
|
// clientRateLimitBurst is the burst capacity for rate limiting
|
||||||
|
clientRateLimitBurst = 100
|
||||||
|
)
|
||||||
|
|
||||||
|
// rateLimitedTransport wraps an http.RoundTripper with rate limiting
|
||||||
|
type rateLimitedTransport struct {
|
||||||
|
transport http.RoundTripper
|
||||||
|
limiter *rate.Limiter
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *rateLimitedTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
|
// Wait for rate limiter to allow the request
|
||||||
|
if err := t.limiter.Wait(req.Context()); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return t.transport.RoundTrip(req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRateLimitedHTTPClient creates an HTTP client with rate limiting
|
||||||
|
func NewRateLimitedHTTPClient() *http.Client {
|
||||||
|
// Calculate interval from rate: 1 second / requests per second
|
||||||
|
interval := time.Second / time.Duration(clientRateLimitPerSecond)
|
||||||
|
|
||||||
|
transport := &rateLimitedTransport{
|
||||||
|
transport: http.DefaultTransport,
|
||||||
|
limiter: rate.NewLimiter(rate.Every(interval), clientRateLimitBurst),
|
||||||
|
}
|
||||||
|
return &http.Client{
|
||||||
|
Transport: transport,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getHTTPClient(ctx context.DnoteCtx, options *requestOptions) *http.Client {
|
||||||
|
if options != nil && options.HTTPClient != nil {
|
||||||
|
return options.HTTPClient
|
||||||
|
}
|
||||||
|
|
||||||
|
if ctx.HTTPClient != nil {
|
||||||
|
return ctx.HTTPClient
|
||||||
|
}
|
||||||
|
|
||||||
|
return &http.Client{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getExpectedContentType(options *requestOptions) string {
|
||||||
|
if options != nil && options.ExpectedContentType != nil {
|
||||||
|
return *options.ExpectedContentType
|
||||||
|
}
|
||||||
|
|
||||||
|
return contentTypeApplicationJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
func getReq(ctx context.DnoteCtx, path, method, body string) (*http.Request, error) {
|
func getReq(ctx context.DnoteCtx, path, method, body string) (*http.Request, error) {
|
||||||
|
|
@ -72,22 +136,6 @@ func getReq(ctx context.DnoteCtx, path, method, body string) (*http.Request, err
|
||||||
return req, nil
|
return req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getHTTPClient(options *requestOptions) http.Client {
|
|
||||||
if options != nil && options.HTTPClient != nil {
|
|
||||||
return *options.HTTPClient
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.Client{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getExpectedContentType(options *requestOptions) string {
|
|
||||||
if options != nil && options.ExpectedContentType != nil {
|
|
||||||
return *options.ExpectedContentType
|
|
||||||
}
|
|
||||||
|
|
||||||
return contentTypeApplicationJSON
|
|
||||||
}
|
|
||||||
|
|
||||||
// checkRespErr checks if the given http response indicates an error. It returns a boolean indicating
|
// checkRespErr checks if the given http response indicates an error. It returns a boolean indicating
|
||||||
// if the response is an error, and a decoded error message.
|
// if the response is an error, and a decoded error message.
|
||||||
func checkRespErr(res *http.Response) error {
|
func checkRespErr(res *http.Response) error {
|
||||||
|
|
@ -95,13 +143,16 @@ func checkRespErr(res *http.Response) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := io.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "server responded with %d but client could not read the response body", res.StatusCode)
|
return errors.Wrapf(err, "server responded with %d but client could not read the response body", res.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyStr := string(body)
|
bodyStr := string(body)
|
||||||
return errors.Errorf(`response %d "%s"`, res.StatusCode, strings.TrimRight(bodyStr, "\n"))
|
return &HTTPError{
|
||||||
|
StatusCode: res.StatusCode,
|
||||||
|
Message: strings.TrimRight(bodyStr, "\n"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkContentType(res *http.Response, options *requestOptions) error {
|
func checkContentType(res *http.Response, options *requestOptions) error {
|
||||||
|
|
@ -122,15 +173,15 @@ func doReq(ctx context.DnoteCtx, method, path, body string, options *requestOpti
|
||||||
return nil, errors.Wrap(err, "getting request")
|
return nil, errors.Wrap(err, "getting request")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("HTTP request: %+v\n", req)
|
log.Debug("HTTP %s %s\n", method, path)
|
||||||
|
|
||||||
hc := getHTTPClient(options)
|
hc := getHTTPClient(ctx, options)
|
||||||
res, err := hc.Do(req)
|
res, err := hc.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, errors.Wrap(err, "making http request")
|
return res, errors.Wrap(err, "making http request")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("HTTP response: %+v\n", res)
|
log.Debug("HTTP %d %s\n", res.StatusCode, res.Status)
|
||||||
|
|
||||||
if err = checkRespErr(res); err != nil {
|
if err = checkRespErr(res); err != nil {
|
||||||
return res, errors.Wrap(err, "server responded with an error")
|
return res, errors.Wrap(err, "server responded with an error")
|
||||||
|
|
@ -169,7 +220,7 @@ func GetSyncState(ctx context.DnoteCtx) (GetSyncStateResp, error) {
|
||||||
return ret, errors.Wrap(err, "constructing http request")
|
return ret, errors.Wrap(err, "constructing http request")
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := io.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ret, errors.Wrap(err, "reading the response body")
|
return ret, errors.Wrap(err, "reading the response body")
|
||||||
}
|
}
|
||||||
|
|
@ -192,7 +243,6 @@ type SyncFragNote struct {
|
||||||
AddedOn int64 `json:"added_on"`
|
AddedOn int64 `json:"added_on"`
|
||||||
EditedOn int64 `json:"edited_on"`
|
EditedOn int64 `json:"edited_on"`
|
||||||
Body string `json:"content"`
|
Body string `json:"content"`
|
||||||
Public bool `json:"public"`
|
|
||||||
Deleted bool `json:"deleted"`
|
Deleted bool `json:"deleted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -232,8 +282,11 @@ func GetSyncFragment(ctx context.DnoteCtx, afterUSN int) (GetSyncFragmentResp, e
|
||||||
|
|
||||||
path := fmt.Sprintf("/v3/sync/fragment?%s", queryStr)
|
path := fmt.Sprintf("/v3/sync/fragment?%s", queryStr)
|
||||||
res, err := doAuthorizedReq(ctx, "GET", path, "", nil)
|
res, err := doAuthorizedReq(ctx, "GET", path, "", nil)
|
||||||
|
if err != nil {
|
||||||
|
return GetSyncFragmentResp{}, errors.Wrap(err, "making the request")
|
||||||
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := io.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return GetSyncFragmentResp{}, errors.Wrap(err, "reading the response body")
|
return GetSyncFragmentResp{}, errors.Wrap(err, "reading the response body")
|
||||||
}
|
}
|
||||||
|
|
@ -404,7 +457,6 @@ func CreateNote(ctx context.DnoteCtx, bookUUID, content string) (CreateNoteResp,
|
||||||
type updateNotePayload struct {
|
type updateNotePayload struct {
|
||||||
BookUUID *string `json:"book_uuid"`
|
BookUUID *string `json:"book_uuid"`
|
||||||
Body *string `json:"content"`
|
Body *string `json:"content"`
|
||||||
Public *bool `json:"public"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateNoteResp is the response from create book api
|
// UpdateNoteResp is the response from create book api
|
||||||
|
|
@ -414,11 +466,10 @@ type UpdateNoteResp struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateNote updates a note in the server
|
// UpdateNote updates a note in the server
|
||||||
func UpdateNote(ctx context.DnoteCtx, uuid, bookUUID, content string, public bool) (UpdateNoteResp, error) {
|
func UpdateNote(ctx context.DnoteCtx, uuid, bookUUID, content string) (UpdateNoteResp, error) {
|
||||||
payload := updateNotePayload{
|
payload := updateNotePayload{
|
||||||
BookUUID: &bookUUID,
|
BookUUID: &bookUUID,
|
||||||
Body: &content,
|
Body: &content,
|
||||||
Public: &public,
|
|
||||||
}
|
}
|
||||||
b, err := json.Marshal(payload)
|
b, err := json.Marshal(payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -525,10 +576,12 @@ func Signin(ctx context.DnoteCtx, email, password string) (SigninResponse, error
|
||||||
return SigninResponse{}, errors.Wrap(err, "marshaling payload")
|
return SigninResponse{}, errors.Wrap(err, "marshaling payload")
|
||||||
}
|
}
|
||||||
res, err := doReq(ctx, "POST", "/v3/signin", string(b), nil)
|
res, err := doReq(ctx, "POST", "/v3/signin", string(b), nil)
|
||||||
|
if err != nil {
|
||||||
if res.StatusCode == http.StatusUnauthorized {
|
// Check if this is a 401 Unauthorized error
|
||||||
return SigninResponse{}, ErrInvalidLogin
|
var httpErr *HTTPError
|
||||||
} else if err != nil {
|
if errors.As(err, &httpErr) && httpErr.StatusCode == http.StatusUnauthorized {
|
||||||
|
return SigninResponse{}, ErrInvalidLogin
|
||||||
|
}
|
||||||
return SigninResponse{}, errors.Wrap(err, "making http request")
|
return SigninResponse{}, errors.Wrap(err, "making http request")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -542,15 +595,27 @@ func Signin(ctx context.DnoteCtx, email, password string) (SigninResponse, error
|
||||||
|
|
||||||
// Signout deletes a user session on the server side
|
// Signout deletes a user session on the server side
|
||||||
func Signout(ctx context.DnoteCtx, sessionKey string) error {
|
func Signout(ctx context.DnoteCtx, sessionKey string) error {
|
||||||
hc := http.Client{
|
// Create a client that shares the transport (and thus rate limiter) from ctx.HTTPClient
|
||||||
// No need to follow redirect
|
// but doesn't follow redirects
|
||||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
var hc *http.Client
|
||||||
return http.ErrUseLastResponse
|
if ctx.HTTPClient != nil {
|
||||||
},
|
hc = &http.Client{
|
||||||
|
Transport: ctx.HTTPClient.Transport,
|
||||||
|
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||||
|
return http.ErrUseLastResponse
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Warnf("No HTTP client configured for signout - falling back\n")
|
||||||
|
hc = &http.Client{
|
||||||
|
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||||
|
return http.ErrUseLastResponse
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := requestOptions{
|
opts := requestOptions{
|
||||||
HTTPClient: &hc,
|
HTTPClient: hc,
|
||||||
ExpectedContentType: &contentTypeNone,
|
ExpectedContentType: &contentTypeNone,
|
||||||
}
|
}
|
||||||
_, err := doAuthorizedReq(ctx, "POST", "/v3/signout", "", &opts)
|
_, err := doAuthorizedReq(ctx, "POST", "/v3/signout", "", &opts)
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package client
|
package client
|
||||||
|
|
@ -23,12 +20,15 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/assert"
|
"github.com/dnote/dnote/pkg/assert"
|
||||||
"github.com/dnote/dnote/pkg/cli/context"
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
"github.com/dnote/dnote/pkg/cli/testutils"
|
"github.com/dnote/dnote/pkg/cli/testutils"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"golang.org/x/time/rate"
|
||||||
)
|
)
|
||||||
|
|
||||||
// startCommonTestServer starts a test HTTP server that simulates a common set of senarios
|
// startCommonTestServer starts a test HTTP server that simulates a common set of senarios
|
||||||
|
|
@ -57,7 +57,7 @@ func TestSignIn(t *testing.T) {
|
||||||
|
|
||||||
err := json.NewDecoder(r.Body).Decode(&payload)
|
err := json.NewDecoder(r.Body).Decode(&payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, "decoding payload in the test server").Error())
|
t.Fatal(errors.Wrap(err, "decoding payload in the test server").Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,9 +82,10 @@ func TestSignIn(t *testing.T) {
|
||||||
defer commonTs.Close()
|
defer commonTs.Close()
|
||||||
|
|
||||||
correctEndpoint := fmt.Sprintf("%s/api", ts.URL)
|
correctEndpoint := fmt.Sprintf("%s/api", ts.URL)
|
||||||
|
testClient := NewRateLimitedHTTPClient()
|
||||||
|
|
||||||
t.Run("success", func(t *testing.T) {
|
t.Run("success", func(t *testing.T) {
|
||||||
result, err := Signin(context.DnoteCtx{APIEndpoint: correctEndpoint}, "alice@example.com", "pass1234")
|
result, err := Signin(context.DnoteCtx{APIEndpoint: correctEndpoint, HTTPClient: testClient}, "alice@example.com", "pass1234")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("got signin request error: %+v", err.Error())
|
t.Errorf("got signin request error: %+v", err.Error())
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +95,7 @@ func TestSignIn(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("failure", func(t *testing.T) {
|
t.Run("failure", func(t *testing.T) {
|
||||||
result, err := Signin(context.DnoteCtx{APIEndpoint: correctEndpoint}, "alice@example.com", "incorrectpassword")
|
result, err := Signin(context.DnoteCtx{APIEndpoint: correctEndpoint, HTTPClient: testClient}, "alice@example.com", "incorrectpassword")
|
||||||
|
|
||||||
assert.Equal(t, err, ErrInvalidLogin, "err mismatch")
|
assert.Equal(t, err, ErrInvalidLogin, "err mismatch")
|
||||||
assert.Equal(t, result.Key, "", "Key mismatch")
|
assert.Equal(t, result.Key, "", "Key mismatch")
|
||||||
|
|
@ -103,7 +104,7 @@ func TestSignIn(t *testing.T) {
|
||||||
|
|
||||||
t.Run("server error", func(t *testing.T) {
|
t.Run("server error", func(t *testing.T) {
|
||||||
endpoint := fmt.Sprintf("%s/bad-api", ts.URL)
|
endpoint := fmt.Sprintf("%s/bad-api", ts.URL)
|
||||||
result, err := Signin(context.DnoteCtx{APIEndpoint: endpoint}, "alice@example.com", "pass1234")
|
result, err := Signin(context.DnoteCtx{APIEndpoint: endpoint, HTTPClient: testClient}, "alice@example.com", "pass1234")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("error should have been returned")
|
t.Error("error should have been returned")
|
||||||
}
|
}
|
||||||
|
|
@ -114,12 +115,24 @@ func TestSignIn(t *testing.T) {
|
||||||
|
|
||||||
t.Run("accidentally pointing to a catch-all handler", func(t *testing.T) {
|
t.Run("accidentally pointing to a catch-all handler", func(t *testing.T) {
|
||||||
endpoint := fmt.Sprintf("%s", ts.URL)
|
endpoint := fmt.Sprintf("%s", ts.URL)
|
||||||
result, err := Signin(context.DnoteCtx{APIEndpoint: endpoint}, "alice@example.com", "pass1234")
|
result, err := Signin(context.DnoteCtx{APIEndpoint: endpoint, HTTPClient: testClient}, "alice@example.com", "pass1234")
|
||||||
|
|
||||||
assert.Equal(t, errors.Cause(err), ErrContentTypeMismatch, "error cause mismatch")
|
assert.Equal(t, errors.Cause(err), ErrContentTypeMismatch, "error cause mismatch")
|
||||||
assert.Equal(t, result.Key, "", "Key mismatch")
|
assert.Equal(t, result.Key, "", "Key mismatch")
|
||||||
assert.Equal(t, result.ExpiresAt, int64(0), "ExpiresAt mismatch")
|
assert.Equal(t, result.ExpiresAt, int64(0), "ExpiresAt mismatch")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("network error", func(t *testing.T) {
|
||||||
|
// Use an invalid endpoint that will fail to connect
|
||||||
|
endpoint := "http://localhost:99999/api"
|
||||||
|
result, err := Signin(context.DnoteCtx{APIEndpoint: endpoint, HTTPClient: testClient}, "alice@example.com", "pass1234")
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
t.Error("error should have been returned for network failure")
|
||||||
|
}
|
||||||
|
assert.Equal(t, result.Key, "", "Key mismatch")
|
||||||
|
assert.Equal(t, result.ExpiresAt, int64(0), "ExpiresAt mismatch")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSignOut(t *testing.T) {
|
func TestSignOut(t *testing.T) {
|
||||||
|
|
@ -134,17 +147,18 @@ func TestSignOut(t *testing.T) {
|
||||||
defer commonTs.Close()
|
defer commonTs.Close()
|
||||||
|
|
||||||
correctEndpoint := fmt.Sprintf("%s/api", ts.URL)
|
correctEndpoint := fmt.Sprintf("%s/api", ts.URL)
|
||||||
|
testClient := NewRateLimitedHTTPClient()
|
||||||
|
|
||||||
t.Run("success", func(t *testing.T) {
|
t.Run("success", func(t *testing.T) {
|
||||||
err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: correctEndpoint}, "alice@example.com")
|
err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: correctEndpoint, HTTPClient: testClient}, "alice@example.com")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("got signin request error: %+v", err.Error())
|
t.Errorf("got signout request error: %+v", err.Error())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("server error", func(t *testing.T) {
|
t.Run("server error", func(t *testing.T) {
|
||||||
endpoint := fmt.Sprintf("%s/bad-api", commonTs.URL)
|
endpoint := fmt.Sprintf("%s/bad-api", commonTs.URL)
|
||||||
err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: endpoint}, "alice@example.com")
|
err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: endpoint, HTTPClient: testClient}, "alice@example.com")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("error should have been returned")
|
t.Error("error should have been returned")
|
||||||
}
|
}
|
||||||
|
|
@ -152,8 +166,69 @@ func TestSignOut(t *testing.T) {
|
||||||
|
|
||||||
t.Run("accidentally pointing to a catch-all handler", func(t *testing.T) {
|
t.Run("accidentally pointing to a catch-all handler", func(t *testing.T) {
|
||||||
endpoint := fmt.Sprintf("%s", commonTs.URL)
|
endpoint := fmt.Sprintf("%s", commonTs.URL)
|
||||||
err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: endpoint}, "alice@example.com")
|
err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: endpoint, HTTPClient: testClient}, "alice@example.com")
|
||||||
|
|
||||||
assert.Equal(t, errors.Cause(err), ErrContentTypeMismatch, "error cause mismatch")
|
assert.Equal(t, errors.Cause(err), ErrContentTypeMismatch, "error cause mismatch")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Gracefully handle a case where http client was not initialized in the context.
|
||||||
|
t.Run("nil HTTPClient", func(t *testing.T) {
|
||||||
|
err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: correctEndpoint}, "alice@example.com")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("got signout request error: %+v", err.Error())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRateLimitedTransport(t *testing.T) {
|
||||||
|
var requestCount atomic.Int32
|
||||||
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
requestCount.Add(1)
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
}))
|
||||||
|
defer ts.Close()
|
||||||
|
|
||||||
|
transport := &rateLimitedTransport{
|
||||||
|
transport: http.DefaultTransport,
|
||||||
|
limiter: rate.NewLimiter(10, 5),
|
||||||
|
}
|
||||||
|
client := &http.Client{Transport: transport}
|
||||||
|
|
||||||
|
// Make 10 requests
|
||||||
|
start := time.Now()
|
||||||
|
numRequests := 10
|
||||||
|
for i := range numRequests {
|
||||||
|
req, _ := http.NewRequest("GET", ts.URL, nil)
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Request %d failed: %v", i, err)
|
||||||
|
}
|
||||||
|
resp.Body.Close()
|
||||||
|
}
|
||||||
|
elapsed := time.Since(start)
|
||||||
|
|
||||||
|
// Burst of 5, then 5 more at 10 req/s = 500ms minimum
|
||||||
|
if elapsed < 500*time.Millisecond {
|
||||||
|
t.Errorf("Rate limit not enforced: 10 requests took %v, expected >= 500ms", elapsed)
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, int(requestCount.Load()), 10, "request count mismatch")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHTTPError(t *testing.T) {
|
||||||
|
t.Run("IsConflict returns true for 409", func(t *testing.T) {
|
||||||
|
conflictErr := &HTTPError{
|
||||||
|
StatusCode: 409,
|
||||||
|
Message: "Conflict",
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, conflictErr.IsConflict(), true, "IsConflict() should return true for 409")
|
||||||
|
|
||||||
|
notFoundErr := &HTTPError{
|
||||||
|
StatusCode: 404,
|
||||||
|
Message: "Not Found",
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, notFoundErr.IsConflict(), false, "IsConflict() should return false for 404")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package add
|
package add
|
||||||
|
|
@ -134,7 +131,7 @@ func newRun(ctx context.DnoteCtx) infra.RunEFunc {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
output.NoteInfo(info)
|
output.NoteInfo(os.Stdout, info)
|
||||||
|
|
||||||
if err := upgrade.Check(ctx); err != nil {
|
if err := upgrade.Check(ctx); err != nil {
|
||||||
log.Error(errors.Wrap(err, "automatically checking updates").Error())
|
log.Error(errors.Wrap(err, "automatically checking updates").Error())
|
||||||
|
|
@ -173,7 +170,7 @@ func writeNote(ctx context.DnoteCtx, bookLabel string, content string, ts int64)
|
||||||
return 0, errors.Wrap(err, "generating uuid")
|
return 0, errors.Wrap(err, "generating uuid")
|
||||||
}
|
}
|
||||||
|
|
||||||
n := database.NewNote(noteUUID, bookUUID, content, ts, 0, 0, false, false, true)
|
n := database.NewNote(noteUUID, bookUUID, content, ts, 0, 0, false, true)
|
||||||
|
|
||||||
err = n.Insert(tx)
|
err = n.Insert(tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -1,98 +0,0 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
|
||||||
*
|
|
||||||
* This file is part of Dnote.
|
|
||||||
*
|
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package cat
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/cli/context"
|
|
||||||
"github.com/dnote/dnote/pkg/cli/database"
|
|
||||||
"github.com/dnote/dnote/pkg/cli/infra"
|
|
||||||
"github.com/dnote/dnote/pkg/cli/log"
|
|
||||||
"github.com/dnote/dnote/pkg/cli/output"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
var example = `
|
|
||||||
* See the notes with index 2 from a book 'javascript'
|
|
||||||
dnote cat javascript 2
|
|
||||||
`
|
|
||||||
|
|
||||||
var deprecationWarning = `and "view" will replace it in the future version.
|
|
||||||
|
|
||||||
Run "dnote view --help" for more information.
|
|
||||||
`
|
|
||||||
|
|
||||||
func preRun(cmd *cobra.Command, args []string) error {
|
|
||||||
if len(args) != 2 {
|
|
||||||
return errors.New("Incorrect number of arguments")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewCmd returns a new cat command
|
|
||||||
func NewCmd(ctx context.DnoteCtx) *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "cat <book name> <note index>",
|
|
||||||
Aliases: []string{"c"},
|
|
||||||
Short: "See a note",
|
|
||||||
Example: example,
|
|
||||||
RunE: NewRun(ctx, false),
|
|
||||||
PreRunE: preRun,
|
|
||||||
Deprecated: deprecationWarning,
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewRun returns a new run function
|
|
||||||
func NewRun(ctx context.DnoteCtx, contentOnly bool) infra.RunEFunc {
|
|
||||||
return func(cmd *cobra.Command, args []string) error {
|
|
||||||
var noteRowIDArg string
|
|
||||||
|
|
||||||
if len(args) == 2 {
|
|
||||||
log.Plain(log.ColorYellow.Sprintf("DEPRECATED: you no longer need to pass book name to the view command. e.g. `dnote view 123`.\n\n"))
|
|
||||||
|
|
||||||
noteRowIDArg = args[1]
|
|
||||||
} else {
|
|
||||||
noteRowIDArg = args[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
noteRowID, err := strconv.Atoi(noteRowIDArg)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Wrap(err, "invalid rowid")
|
|
||||||
}
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
info, err := database.GetNoteInfo(db, noteRowID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if contentOnly {
|
|
||||||
output.NoteContent(info)
|
|
||||||
} else {
|
|
||||||
output.NoteInfo(info)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package edit
|
package edit
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package edit
|
package edit
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,23 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package edit
|
package edit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/cli/context"
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
|
|
@ -45,7 +42,7 @@ func waitEditorNoteContent(ctx context.DnoteCtx, note database.Note) (string, er
|
||||||
return "", errors.Wrap(err, "getting temporarily content file path")
|
return "", errors.Wrap(err, "getting temporarily content file path")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ioutil.WriteFile(fpath, []byte(note.Body), 0644); err != nil {
|
if err := os.WriteFile(fpath, []byte(note.Body), 0644); err != nil {
|
||||||
return "", errors.Wrap(err, "preparing tmp content file")
|
return "", errors.Wrap(err, "preparing tmp content file")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -169,7 +166,7 @@ func runNote(ctx context.DnoteCtx, rowIDArg string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Success("edited the note\n")
|
log.Success("edited the note\n")
|
||||||
output.NoteInfo(noteInfo)
|
output.NoteInfo(os.Stdout, noteInfo)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package find
|
package find
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package find
|
package find
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package find
|
package find
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package login
|
package login
|
||||||
|
|
@ -37,7 +34,7 @@ import (
|
||||||
var example = `
|
var example = `
|
||||||
dnote login`
|
dnote login`
|
||||||
|
|
||||||
var usernameFlag, passwordFlag string
|
var usernameFlag, passwordFlag, apiEndpointFlag string
|
||||||
|
|
||||||
// NewCmd returns a new login command
|
// NewCmd returns a new login command
|
||||||
func NewCmd(ctx context.DnoteCtx) *cobra.Command {
|
func NewCmd(ctx context.DnoteCtx) *cobra.Command {
|
||||||
|
|
@ -51,6 +48,7 @@ func NewCmd(ctx context.DnoteCtx) *cobra.Command {
|
||||||
f := cmd.Flags()
|
f := cmd.Flags()
|
||||||
f.StringVarP(&usernameFlag, "username", "u", "", "email address for authentication")
|
f.StringVarP(&usernameFlag, "username", "u", "", "email address for authentication")
|
||||||
f.StringVarP(&passwordFlag, "password", "p", "", "password for authentication")
|
f.StringVarP(&passwordFlag, "password", "p", "", "password for authentication")
|
||||||
|
f.StringVar(&apiEndpointFlag, "apiEndpoint", "", "API endpoint to connect to (defaults to value in config)")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
@ -126,10 +124,6 @@ func getBaseURL(rawURL string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getServerDisplayURL(ctx context.DnoteCtx) string {
|
func getServerDisplayURL(ctx context.DnoteCtx) string {
|
||||||
if ctx.APIEndpoint == "https://api.getdnote.com" {
|
|
||||||
return "https://www.getdnote.com"
|
|
||||||
}
|
|
||||||
|
|
||||||
baseURL, err := getBaseURL(ctx.APIEndpoint)
|
baseURL, err := getBaseURL(ctx.APIEndpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
|
|
@ -139,7 +133,7 @@ func getServerDisplayURL(ctx context.DnoteCtx) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGreeting(ctx context.DnoteCtx) string {
|
func getGreeting(ctx context.DnoteCtx) string {
|
||||||
base := "Welcome to Dnote Pro"
|
base := "Welcome to Dnote"
|
||||||
|
|
||||||
serverURL := getServerDisplayURL(ctx)
|
serverURL := getServerDisplayURL(ctx)
|
||||||
if serverURL == "" {
|
if serverURL == "" {
|
||||||
|
|
@ -151,6 +145,11 @@ func getGreeting(ctx context.DnoteCtx) string {
|
||||||
|
|
||||||
func newRun(ctx context.DnoteCtx) infra.RunEFunc {
|
func newRun(ctx context.DnoteCtx) infra.RunEFunc {
|
||||||
return func(cmd *cobra.Command, args []string) error {
|
return func(cmd *cobra.Command, args []string) error {
|
||||||
|
// Override APIEndpoint if flag was provided
|
||||||
|
if apiEndpointFlag != "" {
|
||||||
|
ctx.APIEndpoint = apiEndpointFlag
|
||||||
|
}
|
||||||
|
|
||||||
greeting := getGreeting(ctx)
|
greeting := getGreeting(ctx)
|
||||||
log.Plain(greeting)
|
log.Plain(greeting)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package login
|
package login
|
||||||
|
|
@ -31,10 +28,6 @@ func TestGetServerDisplayURL(t *testing.T) {
|
||||||
apiEndpoint string
|
apiEndpoint string
|
||||||
expected string
|
expected string
|
||||||
}{
|
}{
|
||||||
{
|
|
||||||
apiEndpoint: "https://api.getdnote.com",
|
|
||||||
expected: "https://www.getdnote.com",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
apiEndpoint: "https://dnote.mydomain.com/api",
|
apiEndpoint: "https://dnote.mydomain.com/api",
|
||||||
expected: "https://dnote.mydomain.com",
|
expected: "https://dnote.mydomain.com",
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package logout
|
package logout
|
||||||
|
|
@ -37,6 +34,8 @@ var ErrNotLoggedIn = errors.New("not logged in")
|
||||||
var example = `
|
var example = `
|
||||||
dnote logout`
|
dnote logout`
|
||||||
|
|
||||||
|
var apiEndpointFlag string
|
||||||
|
|
||||||
// NewCmd returns a new logout command
|
// NewCmd returns a new logout command
|
||||||
func NewCmd(ctx context.DnoteCtx) *cobra.Command {
|
func NewCmd(ctx context.DnoteCtx) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -46,6 +45,9 @@ func NewCmd(ctx context.DnoteCtx) *cobra.Command {
|
||||||
RunE: newRun(ctx),
|
RunE: newRun(ctx),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f := cmd.Flags()
|
||||||
|
f.StringVar(&apiEndpointFlag, "apiEndpoint", "", "API endpoint to connect to (defaults to value in config)")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,6 +86,11 @@ func Do(ctx context.DnoteCtx) error {
|
||||||
|
|
||||||
func newRun(ctx context.DnoteCtx) infra.RunEFunc {
|
func newRun(ctx context.DnoteCtx) infra.RunEFunc {
|
||||||
return func(cmd *cobra.Command, args []string) error {
|
return func(cmd *cobra.Command, args []string) error {
|
||||||
|
// Override APIEndpoint if flag was provided
|
||||||
|
if apiEndpointFlag != "" {
|
||||||
|
ctx.APIEndpoint = apiEndpointFlag
|
||||||
|
}
|
||||||
|
|
||||||
err := Do(ctx)
|
err := Do(ctx)
|
||||||
if err == ErrNotLoggedIn {
|
if err == ErrNotLoggedIn {
|
||||||
log.Error("not logged in\n")
|
log.Error("not logged in\n")
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,23 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package remove
|
package remove
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/cli/context"
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
|
|
@ -132,7 +130,7 @@ func runNote(ctx context.DnoteCtx, rowIDArg string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
output.NoteInfo(noteInfo)
|
output.NoteInfo(os.Stdout, noteInfo)
|
||||||
|
|
||||||
ok, err := maybeConfirm("remove this note?", false)
|
ok, err := maybeConfirm("remove this note?", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package root
|
package root
|
||||||
|
|
@ -22,11 +19,30 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var dbPathFlag string
|
||||||
|
|
||||||
var root = &cobra.Command{
|
var root = &cobra.Command{
|
||||||
Use: "dnote",
|
Use: "dnote",
|
||||||
Short: "Dnote - a simple command line notebook",
|
Short: "Dnote - a simple command line notebook",
|
||||||
SilenceErrors: true,
|
SilenceErrors: true,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
|
CompletionOptions: cobra.CompletionOptions{
|
||||||
|
DisableDefaultCmd: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
root.PersistentFlags().StringVar(&dbPathFlag, "dbPath", "", "the path to the database file (defaults to standard location)")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRoot returns the root command
|
||||||
|
func GetRoot() *cobra.Command {
|
||||||
|
return root
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDBPathFlag returns the value of the --dbPath flag
|
||||||
|
func GetDBPathFlag() string {
|
||||||
|
return dbPathFlag
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register adds a new command
|
// Register adds a new command
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
|
||||||
*
|
|
||||||
* This file is part of Dnote.
|
|
||||||
*
|
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package sync
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/dnote/dnote/pkg/cli/context"
|
|
||||||
"path/filepath"
|
|
||||||
)
|
|
||||||
|
|
||||||
var testDir = "../../tmp"
|
|
||||||
|
|
||||||
var paths context.Paths = context.Paths{
|
|
||||||
Home: testDir,
|
|
||||||
Cache: testDir,
|
|
||||||
Config: testDir,
|
|
||||||
Data: testDir,
|
|
||||||
}
|
|
||||||
|
|
||||||
var dbPath = filepath.Join(testDir, "test.db")
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sync
|
package sync
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sync
|
package sync
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sync
|
package sync
|
||||||
|
|
@ -29,6 +26,7 @@ import (
|
||||||
"github.com/dnote/dnote/pkg/cli/infra"
|
"github.com/dnote/dnote/pkg/cli/infra"
|
||||||
"github.com/dnote/dnote/pkg/cli/log"
|
"github.com/dnote/dnote/pkg/cli/log"
|
||||||
"github.com/dnote/dnote/pkg/cli/migrate"
|
"github.com/dnote/dnote/pkg/cli/migrate"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/ui"
|
||||||
"github.com/dnote/dnote/pkg/cli/upgrade"
|
"github.com/dnote/dnote/pkg/cli/upgrade"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
@ -43,6 +41,7 @@ var example = `
|
||||||
dnote sync`
|
dnote sync`
|
||||||
|
|
||||||
var isFullSync bool
|
var isFullSync bool
|
||||||
|
var apiEndpointFlag string
|
||||||
|
|
||||||
// NewCmd returns a new sync command
|
// NewCmd returns a new sync command
|
||||||
func NewCmd(ctx context.DnoteCtx) *cobra.Command {
|
func NewCmd(ctx context.DnoteCtx) *cobra.Command {
|
||||||
|
|
@ -56,6 +55,7 @@ func NewCmd(ctx context.DnoteCtx) *cobra.Command {
|
||||||
|
|
||||||
f := cmd.Flags()
|
f := cmd.Flags()
|
||||||
f.BoolVarP(&isFullSync, "full", "f", false, "perform a full sync instead of incrementally syncing only the changed data.")
|
f.BoolVarP(&isFullSync, "full", "f", false, "perform a full sync instead of incrementally syncing only the changed data.")
|
||||||
|
f.StringVar(&apiEndpointFlag, "apiEndpoint", "", "API endpoint to connect to (defaults to value in config)")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
@ -87,6 +87,7 @@ type syncList struct {
|
||||||
ExpungedNotes map[string]bool
|
ExpungedNotes map[string]bool
|
||||||
ExpungedBooks map[string]bool
|
ExpungedBooks map[string]bool
|
||||||
MaxUSN int
|
MaxUSN int
|
||||||
|
UserMaxUSN int // Server's actual max USN (for distinguishing empty fragment vs empty server)
|
||||||
MaxCurrentTime int64
|
MaxCurrentTime int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,14 +95,14 @@ func (l syncList) getLength() int {
|
||||||
return len(l.Notes) + len(l.Books) + len(l.ExpungedNotes) + len(l.ExpungedBooks)
|
return len(l.Notes) + len(l.Books) + len(l.ExpungedNotes) + len(l.ExpungedBooks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// processFragments categorizes items in sync fragments into a sync list. It also decrypts any
|
// processFragments categorizes items in sync fragments into a sync list.
|
||||||
// encrypted data in sync fragments.
|
|
||||||
func processFragments(fragments []client.SyncFragment) (syncList, error) {
|
func processFragments(fragments []client.SyncFragment) (syncList, error) {
|
||||||
notes := map[string]client.SyncFragNote{}
|
notes := map[string]client.SyncFragNote{}
|
||||||
books := map[string]client.SyncFragBook{}
|
books := map[string]client.SyncFragBook{}
|
||||||
expungedNotes := map[string]bool{}
|
expungedNotes := map[string]bool{}
|
||||||
expungedBooks := map[string]bool{}
|
expungedBooks := map[string]bool{}
|
||||||
var maxUSN int
|
var maxUSN int
|
||||||
|
var userMaxUSN int
|
||||||
var maxCurrentTime int64
|
var maxCurrentTime int64
|
||||||
|
|
||||||
for _, fragment := range fragments {
|
for _, fragment := range fragments {
|
||||||
|
|
@ -121,6 +122,9 @@ func processFragments(fragments []client.SyncFragment) (syncList, error) {
|
||||||
if fragment.FragMaxUSN > maxUSN {
|
if fragment.FragMaxUSN > maxUSN {
|
||||||
maxUSN = fragment.FragMaxUSN
|
maxUSN = fragment.FragMaxUSN
|
||||||
}
|
}
|
||||||
|
if fragment.UserMaxUSN > userMaxUSN {
|
||||||
|
userMaxUSN = fragment.UserMaxUSN
|
||||||
|
}
|
||||||
if fragment.CurrentTime > maxCurrentTime {
|
if fragment.CurrentTime > maxCurrentTime {
|
||||||
maxCurrentTime = fragment.CurrentTime
|
maxCurrentTime = fragment.CurrentTime
|
||||||
}
|
}
|
||||||
|
|
@ -132,6 +136,7 @@ func processFragments(fragments []client.SyncFragment) (syncList, error) {
|
||||||
ExpungedNotes: expungedNotes,
|
ExpungedNotes: expungedNotes,
|
||||||
ExpungedBooks: expungedBooks,
|
ExpungedBooks: expungedBooks,
|
||||||
MaxUSN: maxUSN,
|
MaxUSN: maxUSN,
|
||||||
|
UserMaxUSN: userMaxUSN,
|
||||||
MaxCurrentTime: maxCurrentTime,
|
MaxCurrentTime: maxCurrentTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -178,11 +183,68 @@ func getSyncFragments(ctx context.DnoteCtx, afterUSN int) ([]client.SyncFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("received sync fragments: %+v\n", buf)
|
log.Debug("received sync fragments: %+v\n", redactSyncFragments(buf))
|
||||||
|
|
||||||
return buf, nil
|
return buf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// redactSyncFragments returns a deep copy of sync fragments with sensitive fields (note body, book label) removed for safe logging
|
||||||
|
func redactSyncFragments(fragments []client.SyncFragment) []client.SyncFragment {
|
||||||
|
redacted := make([]client.SyncFragment, len(fragments))
|
||||||
|
for i, frag := range fragments {
|
||||||
|
// Create new notes with redacted bodies
|
||||||
|
notes := make([]client.SyncFragNote, len(frag.Notes))
|
||||||
|
for j, note := range frag.Notes {
|
||||||
|
notes[j] = client.SyncFragNote{
|
||||||
|
UUID: note.UUID,
|
||||||
|
BookUUID: note.BookUUID,
|
||||||
|
USN: note.USN,
|
||||||
|
CreatedAt: note.CreatedAt,
|
||||||
|
UpdatedAt: note.UpdatedAt,
|
||||||
|
AddedOn: note.AddedOn,
|
||||||
|
EditedOn: note.EditedOn,
|
||||||
|
Body: func() string {
|
||||||
|
if note.Body != "" {
|
||||||
|
return "<redacted>"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}(),
|
||||||
|
Deleted: note.Deleted,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new books with redacted labels
|
||||||
|
books := make([]client.SyncFragBook, len(frag.Books))
|
||||||
|
for j, book := range frag.Books {
|
||||||
|
books[j] = client.SyncFragBook{
|
||||||
|
UUID: book.UUID,
|
||||||
|
USN: book.USN,
|
||||||
|
CreatedAt: book.CreatedAt,
|
||||||
|
UpdatedAt: book.UpdatedAt,
|
||||||
|
AddedOn: book.AddedOn,
|
||||||
|
Label: func() string {
|
||||||
|
if book.Label != "" {
|
||||||
|
return "<redacted>"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}(),
|
||||||
|
Deleted: book.Deleted,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
redacted[i] = client.SyncFragment{
|
||||||
|
FragMaxUSN: frag.FragMaxUSN,
|
||||||
|
UserMaxUSN: frag.UserMaxUSN,
|
||||||
|
CurrentTime: frag.CurrentTime,
|
||||||
|
Notes: notes,
|
||||||
|
Books: books,
|
||||||
|
ExpungedNotes: frag.ExpungedNotes,
|
||||||
|
ExpungedBooks: frag.ExpungedBooks,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return redacted
|
||||||
|
}
|
||||||
|
|
||||||
// resolveLabel resolves a book label conflict by repeatedly appending an increasing integer
|
// resolveLabel resolves a book label conflict by repeatedly appending an increasing integer
|
||||||
// to the label until it finds a unique label. It returns the first non-conflicting label.
|
// to the label until it finds a unique label. It returns the first non-conflicting label.
|
||||||
func resolveLabel(tx *database.DB, label string) (string, error) {
|
func resolveLabel(tx *database.DB, label string) (string, error) {
|
||||||
|
|
@ -219,7 +281,7 @@ func mergeBook(tx *database.DB, b client.SyncFragBook, mode int) error {
|
||||||
return errors.Wrap(err, "getting a new book label for conflict resolution")
|
return errors.Wrap(err, "getting a new book label for conflict resolution")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := tx.Exec("UPDATE books SET label = ?, dirty = ? WHERE label = ?", newLabel, true, b.Label); err != nil {
|
if _, err := tx.Exec("UPDATE books SET label = ?, dirty = ? WHERE label = ? AND uuid != ?", newLabel, true, b.Label, b.UUID); err != nil {
|
||||||
return errors.Wrap(err, "resolving duplicate book label")
|
return errors.Wrap(err, "resolving duplicate book label")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -278,8 +340,8 @@ func mergeNote(tx *database.DB, serverNote client.SyncFragNote, localNote databa
|
||||||
|
|
||||||
// if the local copy is deleted, and it was edited on the server, override with server values and mark it not dirty.
|
// if the local copy is deleted, and it was edited on the server, override with server values and mark it not dirty.
|
||||||
if localNote.Deleted {
|
if localNote.Deleted {
|
||||||
if _, err := tx.Exec("UPDATE notes SET usn = ?, book_uuid = ?, body = ?, edited_on = ?, deleted = ?, public = ?, dirty = ? WHERE uuid = ?",
|
if _, err := tx.Exec("UPDATE notes SET usn = ?, book_uuid = ?, body = ?, edited_on = ?, deleted = ?, dirty = ? WHERE uuid = ?",
|
||||||
serverNote.USN, serverNote.BookUUID, serverNote.Body, serverNote.EditedOn, serverNote.Deleted, serverNote.Public, false, serverNote.UUID); err != nil {
|
serverNote.USN, serverNote.BookUUID, serverNote.Body, serverNote.EditedOn, serverNote.Deleted, false, serverNote.UUID); err != nil {
|
||||||
return errors.Wrapf(err, "updating local note %s", serverNote.UUID)
|
return errors.Wrapf(err, "updating local note %s", serverNote.UUID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,7 +371,7 @@ func stepSyncNote(tx *database.DB, n client.SyncFragNote) error {
|
||||||
|
|
||||||
// if note exists in the server and does not exist in the client, insert the note.
|
// if note exists in the server and does not exist in the client, insert the note.
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
note := database.NewNote(n.UUID, n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Public, n.Deleted, false)
|
note := database.NewNote(n.UUID, n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Deleted, false)
|
||||||
|
|
||||||
if err := note.Insert(tx); err != nil {
|
if err := note.Insert(tx); err != nil {
|
||||||
return errors.Wrapf(err, "inserting note with uuid %s", n.UUID)
|
return errors.Wrapf(err, "inserting note with uuid %s", n.UUID)
|
||||||
|
|
@ -333,7 +395,7 @@ func fullSyncNote(tx *database.DB, n client.SyncFragNote) error {
|
||||||
|
|
||||||
// if note exists in the server and does not exist in the client, insert the note.
|
// if note exists in the server and does not exist in the client, insert the note.
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
note := database.NewNote(n.UUID, n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Public, n.Deleted, false)
|
note := database.NewNote(n.UUID, n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Deleted, false)
|
||||||
|
|
||||||
if err := note.Insert(tx); err != nil {
|
if err := note.Insert(tx); err != nil {
|
||||||
return errors.Wrapf(err, "inserting note with uuid %s", n.UUID)
|
return errors.Wrapf(err, "inserting note with uuid %s", n.UUID)
|
||||||
|
|
@ -538,6 +600,8 @@ func fullSync(ctx context.DnoteCtx, tx *database.DB) error {
|
||||||
log.Debug("performing a full sync\n")
|
log.Debug("performing a full sync\n")
|
||||||
log.Info("resolving delta.")
|
log.Info("resolving delta.")
|
||||||
|
|
||||||
|
log.DebugNewline()
|
||||||
|
|
||||||
list, err := getSyncList(ctx, 0)
|
list, err := getSyncList(ctx, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "getting sync list")
|
return errors.Wrap(err, "getting sync list")
|
||||||
|
|
@ -545,6 +609,8 @@ func fullSync(ctx context.DnoteCtx, tx *database.DB) error {
|
||||||
|
|
||||||
fmt.Printf(" (total %d).", list.getLength())
|
fmt.Printf(" (total %d).", list.getLength())
|
||||||
|
|
||||||
|
log.DebugNewline()
|
||||||
|
|
||||||
// clean resources that are in erroneous states
|
// clean resources that are in erroneous states
|
||||||
if err := cleanLocalNotes(tx, &list); err != nil {
|
if err := cleanLocalNotes(tx, &list); err != nil {
|
||||||
return errors.Wrap(err, "cleaning up local notes")
|
return errors.Wrap(err, "cleaning up local notes")
|
||||||
|
|
@ -575,7 +641,7 @@ func fullSync(ctx context.DnoteCtx, tx *database.DB) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = saveSyncState(tx, list.MaxCurrentTime, list.MaxUSN)
|
err = saveSyncState(tx, list.MaxCurrentTime, list.MaxUSN, list.UserMaxUSN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "saving sync state")
|
return errors.Wrap(err, "saving sync state")
|
||||||
}
|
}
|
||||||
|
|
@ -590,6 +656,8 @@ func stepSync(ctx context.DnoteCtx, tx *database.DB, afterUSN int) error {
|
||||||
|
|
||||||
log.Info("resolving delta.")
|
log.Info("resolving delta.")
|
||||||
|
|
||||||
|
log.DebugNewline()
|
||||||
|
|
||||||
list, err := getSyncList(ctx, afterUSN)
|
list, err := getSyncList(ctx, afterUSN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "getting sync list")
|
return errors.Wrap(err, "getting sync list")
|
||||||
|
|
@ -619,7 +687,7 @@ func stepSync(ctx context.DnoteCtx, tx *database.DB, afterUSN int) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = saveSyncState(tx, list.MaxCurrentTime, list.MaxUSN)
|
err = saveSyncState(tx, list.MaxCurrentTime, list.MaxUSN, list.UserMaxUSN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "saving sync state")
|
return errors.Wrap(err, "saving sync state")
|
||||||
}
|
}
|
||||||
|
|
@ -629,6 +697,20 @@ func stepSync(ctx context.DnoteCtx, tx *database.DB, afterUSN int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isConflictError checks if an error is a 409 Conflict error from the server
|
||||||
|
func isConflictError(err error) bool {
|
||||||
|
if err == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var httpErr *client.HTTPError
|
||||||
|
if errors.As(err, &httpErr) {
|
||||||
|
return httpErr.IsConflict()
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func sendBooks(ctx context.DnoteCtx, tx *database.DB) (bool, error) {
|
func sendBooks(ctx context.DnoteCtx, tx *database.DB) (bool, error) {
|
||||||
isBehind := false
|
isBehind := false
|
||||||
|
|
||||||
|
|
@ -661,7 +743,9 @@ func sendBooks(ctx context.DnoteCtx, tx *database.DB) (bool, error) {
|
||||||
} else {
|
} else {
|
||||||
resp, err := client.CreateBook(ctx, book.Label)
|
resp, err := client.CreateBook(ctx, book.Label)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return isBehind, errors.Wrap(err, "creating a book")
|
log.Debug("error creating book (will retry after stepSync): %v\n", err)
|
||||||
|
isBehind = true
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = tx.Exec("UPDATE notes SET book_uuid = ? WHERE book_uuid = ?", resp.Book.UUID, book.UUID)
|
_, err = tx.Exec("UPDATE notes SET book_uuid = ? WHERE book_uuid = ?", resp.Book.UUID, book.UUID)
|
||||||
|
|
@ -733,10 +817,92 @@ func sendBooks(ctx context.DnoteCtx, tx *database.DB) (bool, error) {
|
||||||
return isBehind, nil
|
return isBehind, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// findOrphanedNotes returns a list of all orphaned notes
|
||||||
|
func findOrphanedNotes(db *database.DB) (int, []struct{ noteUUID, bookUUID string }, error) {
|
||||||
|
var orphanCount int
|
||||||
|
err := db.QueryRow(`
|
||||||
|
SELECT COUNT(*) FROM notes n
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1 FROM books b
|
||||||
|
WHERE b.uuid = n.book_uuid
|
||||||
|
AND NOT b.deleted
|
||||||
|
)
|
||||||
|
`).Scan(&orphanCount)
|
||||||
|
if err != nil {
|
||||||
|
return 0, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if orphanCount == 0 {
|
||||||
|
return 0, nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
rows, err := db.Query(`
|
||||||
|
SELECT n.uuid, n.book_uuid
|
||||||
|
FROM notes n
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1 FROM books b
|
||||||
|
WHERE b.uuid = n.book_uuid
|
||||||
|
AND NOT b.deleted
|
||||||
|
)
|
||||||
|
`)
|
||||||
|
if err != nil {
|
||||||
|
return orphanCount, nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
var orphans []struct{ noteUUID, bookUUID string }
|
||||||
|
for rows.Next() {
|
||||||
|
var noteUUID, bookUUID string
|
||||||
|
if err := rows.Scan(¬eUUID, &bookUUID); err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
orphans = append(orphans, struct{ noteUUID, bookUUID string }{noteUUID, bookUUID})
|
||||||
|
}
|
||||||
|
|
||||||
|
return orphanCount, orphans, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func warnOrphanedNotes(tx *database.DB) {
|
||||||
|
count, orphans, err := findOrphanedNotes(tx)
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("error checking orphaned notes: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if count == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debug("Found %d orphaned notes (book doesn't exist locally):\n", count)
|
||||||
|
for _, o := range orphans {
|
||||||
|
log.Debug("note %s (book %s)\n", o.noteUUID, o.bookUUID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// checkPostSyncIntegrity checks for data integrity issues after sync and warns the user
|
||||||
|
func checkPostSyncIntegrity(db *database.DB) {
|
||||||
|
count, orphans, err := findOrphanedNotes(db)
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("error checking orphaned notes: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if count == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Warnf("Found %d orphaned notes (referencing non-existent or deleted books):\n", count)
|
||||||
|
for _, o := range orphans {
|
||||||
|
log.Plainf(" - note %s (missing book: %s)\n", o.noteUUID, o.bookUUID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func sendNotes(ctx context.DnoteCtx, tx *database.DB) (bool, error) {
|
func sendNotes(ctx context.DnoteCtx, tx *database.DB) (bool, error) {
|
||||||
isBehind := false
|
isBehind := false
|
||||||
|
|
||||||
rows, err := tx.Query("SELECT uuid, book_uuid, body, public, deleted, usn, added_on FROM notes WHERE dirty")
|
warnOrphanedNotes(tx)
|
||||||
|
|
||||||
|
rows, err := tx.Query("SELECT uuid, book_uuid, body, deleted, usn, added_on FROM notes WHERE dirty")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return isBehind, errors.Wrap(err, "getting syncable notes")
|
return isBehind, errors.Wrap(err, "getting syncable notes")
|
||||||
}
|
}
|
||||||
|
|
@ -745,11 +911,11 @@ func sendNotes(ctx context.DnoteCtx, tx *database.DB) (bool, error) {
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var note database.Note
|
var note database.Note
|
||||||
|
|
||||||
if err = rows.Scan(¬e.UUID, ¬e.BookUUID, ¬e.Body, ¬e.Public, ¬e.Deleted, ¬e.USN, ¬e.AddedOn); err != nil {
|
if err = rows.Scan(¬e.UUID, ¬e.BookUUID, ¬e.Body, ¬e.Deleted, ¬e.USN, ¬e.AddedOn); err != nil {
|
||||||
return isBehind, errors.Wrap(err, "scanning a syncable note")
|
return isBehind, errors.Wrap(err, "scanning a syncable note")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("sending note %s\n", note.UUID)
|
log.Debug("sending note %s (book: %s)\n", note.UUID, note.BookUUID)
|
||||||
|
|
||||||
var respUSN int
|
var respUSN int
|
||||||
|
|
||||||
|
|
@ -766,7 +932,9 @@ func sendNotes(ctx context.DnoteCtx, tx *database.DB) (bool, error) {
|
||||||
} else {
|
} else {
|
||||||
resp, err := client.CreateNote(ctx, note.BookUUID, note.Body)
|
resp, err := client.CreateNote(ctx, note.BookUUID, note.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return isBehind, errors.Wrap(err, "creating a note")
|
log.Debug("failed to create note %s (book: %s): %v\n", note.UUID, note.BookUUID, err)
|
||||||
|
isBehind = true
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
note.Dirty = false
|
note.Dirty = false
|
||||||
|
|
@ -797,7 +965,7 @@ func sendNotes(ctx context.DnoteCtx, tx *database.DB) (bool, error) {
|
||||||
|
|
||||||
respUSN = resp.Result.USN
|
respUSN = resp.Result.USN
|
||||||
} else {
|
} else {
|
||||||
resp, err := client.UpdateNote(ctx, note.UUID, note.BookUUID, note.Body, note.Public)
|
resp, err := client.UpdateNote(ctx, note.UUID, note.BookUUID, note.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return isBehind, errors.Wrap(err, "updating a note")
|
return isBehind, errors.Wrap(err, "updating a note")
|
||||||
}
|
}
|
||||||
|
|
@ -841,6 +1009,8 @@ func sendChanges(ctx context.DnoteCtx, tx *database.DB) (bool, error) {
|
||||||
|
|
||||||
fmt.Printf(" (total %d).", delta)
|
fmt.Printf(" (total %d).", delta)
|
||||||
|
|
||||||
|
log.DebugNewline()
|
||||||
|
|
||||||
behind1, err := sendBooks(ctx, tx)
|
behind1, err := sendBooks(ctx, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return behind1, errors.Wrap(err, "sending books")
|
return behind1, errors.Wrap(err, "sending books")
|
||||||
|
|
@ -874,10 +1044,24 @@ func updateLastSyncAt(tx *database.DB, val int64) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveSyncState(tx *database.DB, serverTime int64, serverMaxUSN int) error {
|
func saveSyncState(tx *database.DB, serverTime int64, serverMaxUSN int, userMaxUSN int) error {
|
||||||
if err := updateLastMaxUSN(tx, serverMaxUSN); err != nil {
|
// Handle last_max_usn update based on server state:
|
||||||
return errors.Wrap(err, "updating last max usn")
|
// - If serverMaxUSN > 0: we got data, update to serverMaxUSN
|
||||||
|
// - If serverMaxUSN == 0 && userMaxUSN > 0: empty fragment (caught up), preserve existing
|
||||||
|
// - If serverMaxUSN == 0 && userMaxUSN == 0: empty server, reset to 0
|
||||||
|
if serverMaxUSN > 0 {
|
||||||
|
if err := updateLastMaxUSN(tx, serverMaxUSN); err != nil {
|
||||||
|
return errors.Wrap(err, "updating last max usn")
|
||||||
|
}
|
||||||
|
} else if userMaxUSN == 0 {
|
||||||
|
// Server is empty, reset to 0
|
||||||
|
if err := updateLastMaxUSN(tx, 0); err != nil {
|
||||||
|
return errors.Wrap(err, "updating last max usn")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// else: empty fragment but server has data, preserve existing last_max_usn
|
||||||
|
|
||||||
|
// Always update last_sync_at (we did communicate with server)
|
||||||
if err := updateLastSyncAt(tx, serverTime); err != nil {
|
if err := updateLastSyncAt(tx, serverTime); err != nil {
|
||||||
return errors.Wrap(err, "updating last sync at")
|
return errors.Wrap(err, "updating last sync at")
|
||||||
}
|
}
|
||||||
|
|
@ -885,8 +1069,33 @@ func saveSyncState(tx *database.DB, serverTime int64, serverMaxUSN int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prepareEmptyServerSync marks all local books and notes as dirty when syncing to an empty server.
|
||||||
|
// This is typically used when switching to a new empty server but wanting to upload existing local data.
|
||||||
|
// Returns true if preparation was done, false otherwise.
|
||||||
|
func prepareEmptyServerSync(tx *database.DB) error {
|
||||||
|
// Mark all books and notes as dirty and reset USN to 0
|
||||||
|
if _, err := tx.Exec("UPDATE books SET usn = 0, dirty = 1 WHERE deleted = 0"); err != nil {
|
||||||
|
return errors.Wrap(err, "marking books as dirty")
|
||||||
|
}
|
||||||
|
if _, err := tx.Exec("UPDATE notes SET usn = 0, dirty = 1 WHERE deleted = 0"); err != nil {
|
||||||
|
return errors.Wrap(err, "marking notes as dirty")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset lastMaxUSN to 0 to match the server
|
||||||
|
if err := updateLastMaxUSN(tx, 0); err != nil {
|
||||||
|
return errors.Wrap(err, "resetting last max usn")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func newRun(ctx context.DnoteCtx) infra.RunEFunc {
|
func newRun(ctx context.DnoteCtx) infra.RunEFunc {
|
||||||
return func(cmd *cobra.Command, args []string) error {
|
return func(cmd *cobra.Command, args []string) error {
|
||||||
|
// Override APIEndpoint if flag was provided
|
||||||
|
if apiEndpointFlag != "" {
|
||||||
|
ctx.APIEndpoint = apiEndpointFlag
|
||||||
|
}
|
||||||
|
|
||||||
if ctx.SessionKey == "" {
|
if ctx.SessionKey == "" {
|
||||||
return errors.New("not logged in")
|
return errors.New("not logged in")
|
||||||
}
|
}
|
||||||
|
|
@ -915,6 +1124,74 @@ func newRun(ctx context.DnoteCtx) infra.RunEFunc {
|
||||||
|
|
||||||
log.Debug("lastSyncAt: %d, lastMaxUSN: %d, syncState: %+v\n", lastSyncAt, lastMaxUSN, syncState)
|
log.Debug("lastSyncAt: %d, lastMaxUSN: %d, syncState: %+v\n", lastSyncAt, lastMaxUSN, syncState)
|
||||||
|
|
||||||
|
// Handle a case where server has MaxUSN=0 but local has data (server switch)
|
||||||
|
var bookCount, noteCount int
|
||||||
|
if err := tx.QueryRow("SELECT count(*) FROM books WHERE deleted = 0").Scan(&bookCount); err != nil {
|
||||||
|
return errors.Wrap(err, "counting local books")
|
||||||
|
}
|
||||||
|
if err := tx.QueryRow("SELECT count(*) FROM notes WHERE deleted = 0").Scan(¬eCount); err != nil {
|
||||||
|
return errors.Wrap(err, "counting local notes")
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a client has previously synced (lastMaxUSN > 0) but the server was never synced to (MaxUSN = 0),
|
||||||
|
// and the client has undeleted books or notes, allow to upload all data to the server.
|
||||||
|
// The client might have switched servers or the server might need to be restored for any reasons.
|
||||||
|
if syncState.MaxUSN == 0 && lastMaxUSN > 0 && (bookCount > 0 || noteCount > 0) {
|
||||||
|
log.Debug("empty server detected: server.MaxUSN=%d, local.MaxUSN=%d, books=%d, notes=%d\n",
|
||||||
|
syncState.MaxUSN, lastMaxUSN, bookCount, noteCount)
|
||||||
|
|
||||||
|
log.Warnf("The server is empty but you have local data. Maybe you switched servers?\n")
|
||||||
|
log.Debug("server state: MaxUSN = 0 (empty)\n")
|
||||||
|
log.Debug("local state: %d books, %d notes (MaxUSN = %d)\n", bookCount, noteCount, lastMaxUSN)
|
||||||
|
|
||||||
|
confirmed, err := ui.Confirm(fmt.Sprintf("Upload %d books and %d notes to the server?", bookCount, noteCount), false)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return errors.Wrap(err, "getting user confirmation")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !confirmed {
|
||||||
|
tx.Rollback()
|
||||||
|
return errors.New("sync cancelled by user")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println() // Add newline after confirmation.
|
||||||
|
|
||||||
|
if err := prepareEmptyServerSync(tx); err != nil {
|
||||||
|
return errors.Wrap(err, "preparing for empty server sync")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Re-fetch lastMaxUSN after prepareEmptyServerSync
|
||||||
|
lastMaxUSN, err = getLastMaxUSN(tx)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "getting the last max_usn after prepare")
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debug("prepared empty server sync: marked %d books and %d notes as dirty\n", bookCount, noteCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If full sync will be triggered by FullSyncBefore (not manual --full flag),
|
||||||
|
// and client has more data than server, prepare local data for upload to avoid orphaning notes.
|
||||||
|
// The lastMaxUSN > syncState.MaxUSN check prevents duplicate uploads when switching
|
||||||
|
// back to a server that already has our data.
|
||||||
|
if !isFullSync && lastSyncAt < syncState.FullSyncBefore && lastMaxUSN > syncState.MaxUSN {
|
||||||
|
log.Debug("full sync triggered by FullSyncBefore: preparing local data for upload\n")
|
||||||
|
log.Debug("server.FullSyncBefore=%d, local.lastSyncAt=%d, local.MaxUSN=%d, server.MaxUSN=%d, books=%d, notes=%d\n",
|
||||||
|
syncState.FullSyncBefore, lastSyncAt, lastMaxUSN, syncState.MaxUSN, bookCount, noteCount)
|
||||||
|
|
||||||
|
if err := prepareEmptyServerSync(tx); err != nil {
|
||||||
|
return errors.Wrap(err, "preparing local data for full sync")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Re-fetch lastMaxUSN after prepareEmptyServerSync
|
||||||
|
lastMaxUSN, err = getLastMaxUSN(tx)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "getting the last max_usn after prepare")
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debug("prepared for full sync: marked %d books and %d notes as dirty\n", bookCount, noteCount)
|
||||||
|
}
|
||||||
|
|
||||||
var syncErr error
|
var syncErr error
|
||||||
if isFullSync || lastSyncAt < syncState.FullSyncBefore {
|
if isFullSync || lastSyncAt < syncState.FullSyncBefore {
|
||||||
syncErr = fullSync(ctx, tx)
|
syncErr = fullSync(ctx, tx)
|
||||||
|
|
@ -953,12 +1230,24 @@ func newRun(ctx context.DnoteCtx) infra.RunEFunc {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return errors.Wrap(err, "performing the follow-up step sync")
|
return errors.Wrap(err, "performing the follow-up step sync")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// After syncing server changes (which resolves conflicts), send local changes again
|
||||||
|
// This uploads books/notes that were skipped due to 409 conflicts
|
||||||
|
_, err = sendChanges(ctx, tx)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return errors.Wrap(err, "sending changes after conflict resolution")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
if err := tx.Commit(); err != nil {
|
||||||
|
return errors.Wrap(err, "committing transaction")
|
||||||
|
}
|
||||||
|
|
||||||
log.Success("success\n")
|
log.Success("success\n")
|
||||||
|
|
||||||
|
checkPostSyncIntegrity(ctx.DB)
|
||||||
|
|
||||||
if err := upgrade.Check(ctx); err != nil {
|
if err := upgrade.Check(ctx); err != nil {
|
||||||
log.Error(errors.Wrap(err, "automatically checking updates").Error())
|
log.Error(errors.Wrap(err, "automatically checking updates").Error())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
|
||||||
|
|
@ -1,91 +1,31 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package ls
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/cli/context"
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
"github.com/dnote/dnote/pkg/cli/infra"
|
|
||||||
"github.com/dnote/dnote/pkg/cli/log"
|
"github.com/dnote/dnote/pkg/cli/log"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var example = `
|
|
||||||
* List all books
|
|
||||||
dnote ls
|
|
||||||
|
|
||||||
* List notes in a book
|
|
||||||
dnote ls javascript
|
|
||||||
`
|
|
||||||
|
|
||||||
var deprecationWarning = `and "view" will replace it in the future version.
|
|
||||||
|
|
||||||
Run "dnote view --help" for more information.
|
|
||||||
`
|
|
||||||
|
|
||||||
func preRun(cmd *cobra.Command, args []string) error {
|
|
||||||
if len(args) > 1 {
|
|
||||||
return errors.New("Incorrect number of argument")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewCmd returns a new ls command
|
|
||||||
func NewCmd(ctx context.DnoteCtx) *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "ls <book name?>",
|
|
||||||
Aliases: []string{"l", "notes"},
|
|
||||||
Short: "List all notes",
|
|
||||||
Example: example,
|
|
||||||
RunE: NewRun(ctx, false),
|
|
||||||
PreRunE: preRun,
|
|
||||||
Deprecated: deprecationWarning,
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewRun returns a new run function for ls
|
|
||||||
func NewRun(ctx context.DnoteCtx, nameOnly bool) infra.RunEFunc {
|
|
||||||
return func(cmd *cobra.Command, args []string) error {
|
|
||||||
if len(args) == 0 {
|
|
||||||
if err := printBooks(ctx, nameOnly); err != nil {
|
|
||||||
return errors.Wrap(err, "viewing books")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
bookName := args[0]
|
|
||||||
if err := printNotes(ctx, bookName); err != nil {
|
|
||||||
return errors.Wrapf(err, "viewing book '%s'", bookName)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// bookInfo is an information about the book to be printed on screen
|
// bookInfo is an information about the book to be printed on screen
|
||||||
type bookInfo struct {
|
type bookInfo struct {
|
||||||
BookLabel string
|
BookLabel string
|
||||||
|
|
@ -100,15 +40,13 @@ type noteInfo struct {
|
||||||
|
|
||||||
// getNewlineIdx returns the index of newline character in a string
|
// getNewlineIdx returns the index of newline character in a string
|
||||||
func getNewlineIdx(str string) int {
|
func getNewlineIdx(str string) int {
|
||||||
var ret int
|
// Check for \r\n first
|
||||||
|
if idx := strings.Index(str, "\r\n"); idx != -1 {
|
||||||
ret = strings.Index(str, "\n")
|
return idx
|
||||||
|
|
||||||
if ret == -1 {
|
|
||||||
ret = strings.Index(str, "\r\n")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
// Then check for \n
|
||||||
|
return strings.Index(str, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
// formatBody returns an excerpt of the given raw note content and a boolean
|
// formatBody returns an excerpt of the given raw note content and a boolean
|
||||||
|
|
@ -126,15 +64,15 @@ func formatBody(noteBody string) (string, bool) {
|
||||||
return strings.Trim(trimmed, " "), false
|
return strings.Trim(trimmed, " "), false
|
||||||
}
|
}
|
||||||
|
|
||||||
func printBookLine(info bookInfo, nameOnly bool) {
|
func printBookLine(w io.Writer, info bookInfo, nameOnly bool) {
|
||||||
if nameOnly {
|
if nameOnly {
|
||||||
fmt.Println(info.BookLabel)
|
fmt.Fprintln(w, info.BookLabel)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("%s %s\n", info.BookLabel, log.ColorYellow.Sprintf("(%d)", info.NoteCount))
|
fmt.Fprintf(w, "%s %s\n", info.BookLabel, log.ColorYellow.Sprintf("(%d)", info.NoteCount))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func printBooks(ctx context.DnoteCtx, nameOnly bool) error {
|
func listBooks(ctx context.DnoteCtx, w io.Writer, nameOnly bool) error {
|
||||||
db := ctx.DB
|
db := ctx.DB
|
||||||
|
|
||||||
rows, err := db.Query(`SELECT books.label, count(notes.uuid) note_count
|
rows, err := db.Query(`SELECT books.label, count(notes.uuid) note_count
|
||||||
|
|
@ -160,13 +98,13 @@ func printBooks(ctx context.DnoteCtx, nameOnly bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, info := range infos {
|
for _, info := range infos {
|
||||||
printBookLine(info, nameOnly)
|
printBookLine(w, info, nameOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func printNotes(ctx context.DnoteCtx, bookName string) error {
|
func listNotes(ctx context.DnoteCtx, w io.Writer, bookName string) error {
|
||||||
db := ctx.DB
|
db := ctx.DB
|
||||||
|
|
||||||
var bookUUID string
|
var bookUUID string
|
||||||
|
|
@ -194,7 +132,7 @@ func printNotes(ctx context.DnoteCtx, bookName string) error {
|
||||||
infos = append(infos, info)
|
infos = append(infos, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("on book %s\n", bookName)
|
fmt.Fprintf(w, "on book %s\n", bookName)
|
||||||
|
|
||||||
for _, info := range infos {
|
for _, info := range infos {
|
||||||
body, isExcerpt := formatBody(info.Body)
|
body, isExcerpt := formatBody(info.Body)
|
||||||
|
|
@ -204,7 +142,7 @@ func printNotes(ctx context.DnoteCtx, bookName string) error {
|
||||||
body = fmt.Sprintf("%s %s", body, log.ColorYellow.Sprintf("[---More---]"))
|
body = fmt.Sprintf("%s %s", body, log.ColorYellow.Sprintf("[---More---]"))
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Plainf("%s %s\n", rowid, body)
|
fmt.Fprintf(w, "%s %s\n", rowid, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
184
pkg/cli/cmd/view/book_test.go
Normal file
184
pkg/cli/cmd/view/book_test.go
Normal file
|
|
@ -0,0 +1,184 @@
|
||||||
|
/* Copyright 2025 Dnote Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package view
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/dnote/dnote/pkg/assert"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/database"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetNewlineIdx(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
input string
|
||||||
|
expected int
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
input: "hello\nworld",
|
||||||
|
expected: 5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "hello\r\nworld",
|
||||||
|
expected: 5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "no newline here",
|
||||||
|
expected: -1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "",
|
||||||
|
expected: -1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "\n",
|
||||||
|
expected: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "\r\n",
|
||||||
|
expected: 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(fmt.Sprintf("input: %q", tc.input), func(t *testing.T) {
|
||||||
|
got := getNewlineIdx(tc.input)
|
||||||
|
assert.Equal(t, got, tc.expected, "newline index mismatch")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFormatBody(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
input string
|
||||||
|
expectedBody string
|
||||||
|
expectedExcerpt bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
input: "single line",
|
||||||
|
expectedBody: "single line",
|
||||||
|
expectedExcerpt: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "first line\nsecond line",
|
||||||
|
expectedBody: "first line",
|
||||||
|
expectedExcerpt: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "first line\r\nsecond line",
|
||||||
|
expectedBody: "first line",
|
||||||
|
expectedExcerpt: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: " spaced line ",
|
||||||
|
expectedBody: "spaced line",
|
||||||
|
expectedExcerpt: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: " first line \nsecond line",
|
||||||
|
expectedBody: "first line",
|
||||||
|
expectedExcerpt: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "",
|
||||||
|
expectedBody: "",
|
||||||
|
expectedExcerpt: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "line with trailing newline\n",
|
||||||
|
expectedBody: "line with trailing newline",
|
||||||
|
expectedExcerpt: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "line with trailing newlines\n\n",
|
||||||
|
expectedBody: "line with trailing newlines",
|
||||||
|
expectedExcerpt: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(fmt.Sprintf("input: %q", tc.input), func(t *testing.T) {
|
||||||
|
gotBody, gotExcerpt := formatBody(tc.input)
|
||||||
|
assert.Equal(t, gotBody, tc.expectedBody, "formatted body mismatch")
|
||||||
|
assert.Equal(t, gotExcerpt, tc.expectedExcerpt, "excerpt flag mismatch")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestListNotes(t *testing.T) {
|
||||||
|
// Setup
|
||||||
|
db := database.InitTestMemoryDB(t)
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
bookUUID := "js-book-uuid"
|
||||||
|
database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", bookUUID, "javascript")
|
||||||
|
database.MustExec(t, "inserting note 1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)", "note-1", bookUUID, "first note", 1515199943)
|
||||||
|
database.MustExec(t, "inserting note 2", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)", "note-2", bookUUID, "multiline note\nwith second line", 1515199945)
|
||||||
|
|
||||||
|
ctx := context.DnoteCtx{DB: db}
|
||||||
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
err := listNotes(ctx, &buf, "javascript")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
got := buf.String()
|
||||||
|
|
||||||
|
// Verify output
|
||||||
|
assert.Equal(t, strings.Contains(got, "on book javascript"), true, "should show book name")
|
||||||
|
assert.Equal(t, strings.Contains(got, "first note"), true, "should contain first note")
|
||||||
|
assert.Equal(t, strings.Contains(got, "multiline note"), true, "should show first line of multiline note")
|
||||||
|
assert.Equal(t, strings.Contains(got, "[---More---]"), true, "should show more indicator for multiline note")
|
||||||
|
assert.Equal(t, strings.Contains(got, "with second line"), false, "should not show second line of multiline note")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestListBooks(t *testing.T) {
|
||||||
|
// Setup
|
||||||
|
db := database.InitTestMemoryDB(t)
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
b1UUID := "js-book-uuid"
|
||||||
|
b2UUID := "linux-book-uuid"
|
||||||
|
|
||||||
|
database.MustExec(t, "inserting book 1", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "javascript")
|
||||||
|
database.MustExec(t, "inserting book 2", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b2UUID, "linux")
|
||||||
|
|
||||||
|
// Add notes to test count
|
||||||
|
database.MustExec(t, "inserting note 1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)", "note-1", b1UUID, "note body 1", 1515199943)
|
||||||
|
database.MustExec(t, "inserting note 2", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)", "note-2", b1UUID, "note body 2", 1515199944)
|
||||||
|
|
||||||
|
ctx := context.DnoteCtx{DB: db}
|
||||||
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
err := listBooks(ctx, &buf, false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
got := buf.String()
|
||||||
|
|
||||||
|
// Verify output
|
||||||
|
assert.Equal(t, strings.Contains(got, "javascript"), true, "should contain javascript book")
|
||||||
|
assert.Equal(t, strings.Contains(got, "linux"), true, "should contain linux book")
|
||||||
|
assert.Equal(t, strings.Contains(got, "(2)"), true, "should show 2 notes for javascript")
|
||||||
|
}
|
||||||
47
pkg/cli/cmd/view/note.go
Normal file
47
pkg/cli/cmd/view/note.go
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
/* Copyright 2025 Dnote Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package view
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/database"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/output"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
func viewNote(ctx context.DnoteCtx, w io.Writer, noteRowIDArg string, contentOnly bool) error {
|
||||||
|
noteRowID, err := strconv.Atoi(noteRowIDArg)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "invalid rowid")
|
||||||
|
}
|
||||||
|
|
||||||
|
db := ctx.DB
|
||||||
|
info, err := database.GetNoteInfo(db, noteRowID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if contentOnly {
|
||||||
|
output.NoteContent(w, info)
|
||||||
|
} else {
|
||||||
|
output.NoteInfo(w, info)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
90
pkg/cli/cmd/view/note_test.go
Normal file
90
pkg/cli/cmd/view/note_test.go
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
/* Copyright 2025 Dnote Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package view
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/dnote/dnote/pkg/assert"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/database"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestViewNote(t *testing.T) {
|
||||||
|
db := database.InitTestMemoryDB(t)
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
bookUUID := "test-book-uuid"
|
||||||
|
database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", bookUUID, "golang")
|
||||||
|
database.MustExec(t, "inserting note", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)",
|
||||||
|
"note-uuid", bookUUID, "test note content", 1515199943000000000)
|
||||||
|
|
||||||
|
ctx := context.DnoteCtx{DB: db}
|
||||||
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
err := viewNote(ctx, &buf, "1", false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
got := buf.String()
|
||||||
|
assert.Equal(t, strings.Contains(got, "test note content"), true, "should contain note content")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestViewNoteContentOnly(t *testing.T) {
|
||||||
|
db := database.InitTestMemoryDB(t)
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
bookUUID := "test-book-uuid"
|
||||||
|
database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", bookUUID, "golang")
|
||||||
|
database.MustExec(t, "inserting note", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)",
|
||||||
|
"note-uuid", bookUUID, "test note content", 1515199943000000000)
|
||||||
|
|
||||||
|
ctx := context.DnoteCtx{DB: db}
|
||||||
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
err := viewNote(ctx, &buf, "1", true)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
got := buf.String()
|
||||||
|
assert.Equal(t, got, "test note content", "should contain only note content")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestViewNoteInvalidRowID(t *testing.T) {
|
||||||
|
db := database.InitTestMemoryDB(t)
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
ctx := context.DnoteCtx{DB: db}
|
||||||
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
err := viewNote(ctx, &buf, "not-a-number", false)
|
||||||
|
assert.NotEqual(t, err, nil, "should return error for invalid rowid")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestViewNoteNotFound(t *testing.T) {
|
||||||
|
db := database.InitTestMemoryDB(t)
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
ctx := context.DnoteCtx{DB: db}
|
||||||
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
err := viewNote(ctx, &buf, "999", false)
|
||||||
|
assert.NotEqual(t, err, nil, "should return error for non-existent note")
|
||||||
|
}
|
||||||
|
|
@ -1,32 +1,28 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/cli/context"
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
"github.com/dnote/dnote/pkg/cli/infra"
|
"github.com/dnote/dnote/pkg/cli/infra"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/utils"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/cli/cmd/cat"
|
|
||||||
"github.com/dnote/dnote/pkg/cli/cmd/ls"
|
|
||||||
"github.com/dnote/dnote/pkg/cli/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var example = `
|
var example = `
|
||||||
|
|
@ -71,27 +67,26 @@ func NewCmd(ctx context.DnoteCtx) *cobra.Command {
|
||||||
|
|
||||||
func newRun(ctx context.DnoteCtx) infra.RunEFunc {
|
func newRun(ctx context.DnoteCtx) infra.RunEFunc {
|
||||||
return func(cmd *cobra.Command, args []string) error {
|
return func(cmd *cobra.Command, args []string) error {
|
||||||
var run infra.RunEFunc
|
|
||||||
|
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
run = ls.NewRun(ctx, nameOnly)
|
// List all books
|
||||||
|
return listBooks(ctx, os.Stdout, nameOnly)
|
||||||
} else if len(args) == 1 {
|
} else if len(args) == 1 {
|
||||||
if nameOnly {
|
if nameOnly {
|
||||||
return errors.New("--name-only flag is only valid when viewing books")
|
return errors.New("--name-only flag is only valid when viewing books")
|
||||||
}
|
}
|
||||||
|
|
||||||
if utils.IsNumber(args[0]) {
|
if utils.IsNumber(args[0]) {
|
||||||
run = cat.NewRun(ctx, contentOnly)
|
// View a note by index
|
||||||
|
return viewNote(ctx, os.Stdout, args[0], contentOnly)
|
||||||
} else {
|
} else {
|
||||||
run = ls.NewRun(ctx, false)
|
// List notes in a book
|
||||||
|
return listNotes(ctx, os.Stdout, args[0])
|
||||||
}
|
}
|
||||||
} else if len(args) == 2 {
|
} else if len(args) == 2 {
|
||||||
// DEPRECATED: passing book name to view command is deprecated
|
// View a note in a book (book name + note index)
|
||||||
run = cat.NewRun(ctx, false)
|
return viewNote(ctx, os.Stdout, args[1], contentOnly)
|
||||||
} else {
|
|
||||||
return errors.New("Incorrect number of arguments")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return run(cmd, args)
|
return errors.New("Incorrect number of arguments")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,23 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/cli/consts"
|
"github.com/dnote/dnote/pkg/cli/consts"
|
||||||
"github.com/dnote/dnote/pkg/cli/context"
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
|
|
@ -32,8 +29,9 @@ import (
|
||||||
|
|
||||||
// Config holds dnote configuration
|
// Config holds dnote configuration
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Editor string `yaml:"editor"`
|
Editor string `yaml:"editor"`
|
||||||
APIEndpoint string `yaml:"apiEndpoint"`
|
APIEndpoint string `yaml:"apiEndpoint"`
|
||||||
|
EnableUpgradeCheck bool `yaml:"enableUpgradeCheck"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkLegacyPath(ctx context.DnoteCtx) (string, bool) {
|
func checkLegacyPath(ctx context.DnoteCtx) (string, bool) {
|
||||||
|
|
@ -41,7 +39,7 @@ func checkLegacyPath(ctx context.DnoteCtx) (string, bool) {
|
||||||
|
|
||||||
ok, err := utils.FileExists(legacyPath)
|
ok, err := utils.FileExists(legacyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf(errors.Wrapf(err, "checking legacy dnote directory at %s", legacyPath).Error())
|
log.Error(errors.Wrapf(err, "checking legacy dnote directory at %s", legacyPath).Error())
|
||||||
}
|
}
|
||||||
if ok {
|
if ok {
|
||||||
return legacyPath, true
|
return legacyPath, true
|
||||||
|
|
@ -65,7 +63,7 @@ func Read(ctx context.DnoteCtx) (Config, error) {
|
||||||
var ret Config
|
var ret Config
|
||||||
|
|
||||||
configPath := GetPath(ctx)
|
configPath := GetPath(ctx)
|
||||||
b, err := ioutil.ReadFile(configPath)
|
b, err := os.ReadFile(configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ret, errors.Wrap(err, "reading config file")
|
return ret, errors.Wrap(err, "reading config file")
|
||||||
}
|
}
|
||||||
|
|
@ -87,7 +85,7 @@ func Write(ctx context.DnoteCtx, cf Config) error {
|
||||||
return errors.Wrap(err, "marshalling config into YAML")
|
return errors.Wrap(err, "marshalling config into YAML")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(path, b, 0644)
|
err = os.WriteFile(path, b, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "writing the config file")
|
return errors.Wrap(err, "writing the config file")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Package consts provides definitions of constants
|
// Package consts provides definitions of constants
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,24 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Package context defines dnote context
|
// Package context defines dnote context
|
||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/cli/database"
|
"github.com/dnote/dnote/pkg/cli/database"
|
||||||
"github.com/dnote/dnote/pkg/clock"
|
"github.com/dnote/dnote/pkg/clock"
|
||||||
)
|
)
|
||||||
|
|
@ -35,14 +34,16 @@ type Paths struct {
|
||||||
|
|
||||||
// DnoteCtx is a context holding the information of the current runtime
|
// DnoteCtx is a context holding the information of the current runtime
|
||||||
type DnoteCtx struct {
|
type DnoteCtx struct {
|
||||||
Paths Paths
|
Paths Paths
|
||||||
APIEndpoint string
|
APIEndpoint string
|
||||||
Version string
|
Version string
|
||||||
DB *database.DB
|
DB *database.DB
|
||||||
SessionKey string
|
SessionKey string
|
||||||
SessionKeyExpiry int64
|
SessionKeyExpiry int64
|
||||||
Editor string
|
Editor string
|
||||||
Clock clock.Clock
|
Clock clock.Clock
|
||||||
|
EnableUpgradeCheck bool
|
||||||
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redact replaces private information from the context with a set of
|
// Redact replaces private information from the context with a set of
|
||||||
|
|
|
||||||
48
pkg/cli/context/files.go
Normal file
48
pkg/cli/context/files.go
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
/* Copyright 2025 Dnote Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package context
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/dnote/dnote/pkg/cli/consts"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/utils"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// InitDnoteDirs creates the dnote directories if they don't already exist.
|
||||||
|
func InitDnoteDirs(paths Paths) error {
|
||||||
|
if paths.Config != "" {
|
||||||
|
configDir := filepath.Join(paths.Config, consts.DnoteDirName)
|
||||||
|
if err := utils.EnsureDir(configDir); err != nil {
|
||||||
|
return errors.Wrap(err, "initializing config dir")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if paths.Data != "" {
|
||||||
|
dataDir := filepath.Join(paths.Data, consts.DnoteDirName)
|
||||||
|
if err := utils.EnsureDir(dataDir); err != nil {
|
||||||
|
return errors.Wrap(err, "initializing data dir")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if paths.Cache != "" {
|
||||||
|
cacheDir := filepath.Join(paths.Cache, consts.DnoteDirName)
|
||||||
|
if err := utils.EnsureDir(cacheDir); err != nil {
|
||||||
|
return errors.Wrap(err, "initializing cache dir")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
62
pkg/cli/context/files_test.go
Normal file
62
pkg/cli/context/files_test.go
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
/* Copyright 2025 Dnote Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package context
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/dnote/dnote/pkg/assert"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/consts"
|
||||||
|
)
|
||||||
|
|
||||||
|
func assertDirsExist(t *testing.T, paths Paths) {
|
||||||
|
configDir := filepath.Join(paths.Config, consts.DnoteDirName)
|
||||||
|
info, err := os.Stat(configDir)
|
||||||
|
assert.Equal(t, err, nil, "config dir should exist")
|
||||||
|
assert.Equal(t, info.IsDir(), true, "config should be a directory")
|
||||||
|
|
||||||
|
dataDir := filepath.Join(paths.Data, consts.DnoteDirName)
|
||||||
|
info, err = os.Stat(dataDir)
|
||||||
|
assert.Equal(t, err, nil, "data dir should exist")
|
||||||
|
assert.Equal(t, info.IsDir(), true, "data should be a directory")
|
||||||
|
|
||||||
|
cacheDir := filepath.Join(paths.Cache, consts.DnoteDirName)
|
||||||
|
info, err = os.Stat(cacheDir)
|
||||||
|
assert.Equal(t, err, nil, "cache dir should exist")
|
||||||
|
assert.Equal(t, info.IsDir(), true, "cache should be a directory")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInitDnoteDirs(t *testing.T) {
|
||||||
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
|
paths := Paths{
|
||||||
|
Config: filepath.Join(tmpDir, "config"),
|
||||||
|
Data: filepath.Join(tmpDir, "data"),
|
||||||
|
Cache: filepath.Join(tmpDir, "cache"),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize directories
|
||||||
|
err := InitDnoteDirs(paths)
|
||||||
|
assert.Equal(t, err, nil, "InitDnoteDirs should succeed")
|
||||||
|
assertDirsExist(t, paths)
|
||||||
|
|
||||||
|
// Call again - should be idempotent
|
||||||
|
err = InitDnoteDirs(paths)
|
||||||
|
assert.Equal(t, err, nil, "InitDnoteDirs should succeed when dirs already exist")
|
||||||
|
assertDirsExist(t, paths)
|
||||||
|
}
|
||||||
|
|
@ -1,26 +1,22 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"path/filepath"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/cli/consts"
|
"github.com/dnote/dnote/pkg/cli/consts"
|
||||||
|
|
@ -29,11 +25,27 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InitTestCtx initializes a test context
|
// getDefaultTestPaths creates default test paths with all paths pointing to a temp directory
|
||||||
func InitTestCtx(t *testing.T, paths Paths, dbOpts *database.TestDBOptions) DnoteCtx {
|
func getDefaultTestPaths(t *testing.T) Paths {
|
||||||
dbPath := fmt.Sprintf("%s/%s/%s", paths.Data, consts.DnoteDirName, consts.DnoteDBFileName)
|
tmpDir := t.TempDir()
|
||||||
|
return Paths{
|
||||||
|
Home: tmpDir,
|
||||||
|
Cache: tmpDir,
|
||||||
|
Config: tmpDir,
|
||||||
|
Data: tmpDir,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
db := database.InitTestDB(t, dbPath, dbOpts)
|
|
||||||
|
// InitTestCtx initializes a test context with an in-memory database
|
||||||
|
// and a temporary directory for all paths
|
||||||
|
func InitTestCtx(t *testing.T) DnoteCtx {
|
||||||
|
paths := getDefaultTestPaths(t)
|
||||||
|
db := database.InitTestMemoryDB(t)
|
||||||
|
|
||||||
|
if err := InitDnoteDirs(paths); err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "creating test directories"))
|
||||||
|
}
|
||||||
|
|
||||||
return DnoteCtx{
|
return DnoteCtx{
|
||||||
DB: db,
|
DB: db,
|
||||||
|
|
@ -42,17 +54,47 @@ func InitTestCtx(t *testing.T, paths Paths, dbOpts *database.TestDBOptions) Dnot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TeardownTestCtx cleans up the test context
|
// InitTestCtxWithDB initializes a test context with the provided database
|
||||||
func TeardownTestCtx(t *testing.T, ctx DnoteCtx) {
|
// and a temporary directory for all paths.
|
||||||
database.TeardownTestDB(t, ctx.DB)
|
// Used when you need full control over database initialization (e.g. migration tests).
|
||||||
|
func InitTestCtxWithDB(t *testing.T, db *database.DB) DnoteCtx {
|
||||||
|
paths := getDefaultTestPaths(t)
|
||||||
|
|
||||||
if err := os.RemoveAll(ctx.Paths.Data); err != nil {
|
if err := InitDnoteDirs(paths); err != nil {
|
||||||
t.Fatal(errors.Wrap(err, "removing test data directory"))
|
t.Fatal(errors.Wrap(err, "creating test directories"))
|
||||||
}
|
}
|
||||||
if err := os.RemoveAll(ctx.Paths.Config); err != nil {
|
|
||||||
t.Fatal(errors.Wrap(err, "removing test config directory"))
|
return DnoteCtx{
|
||||||
}
|
DB: db,
|
||||||
if err := os.RemoveAll(ctx.Paths.Cache); err != nil {
|
Paths: paths,
|
||||||
t.Fatal(errors.Wrap(err, "removing test cache directory"))
|
Clock: clock.NewMock(), // Use a mock clock to test times
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InitTestCtxWithFileDB initializes a test context with a file-based database
|
||||||
|
// at the expected path.
|
||||||
|
func InitTestCtxWithFileDB(t *testing.T) DnoteCtx {
|
||||||
|
paths := getDefaultTestPaths(t)
|
||||||
|
|
||||||
|
if err := InitDnoteDirs(paths); err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "creating test directories"))
|
||||||
|
}
|
||||||
|
|
||||||
|
dbPath := filepath.Join(paths.Data, consts.DnoteDirName, consts.DnoteDBFileName)
|
||||||
|
db, err := database.Open(dbPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "opening database"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := db.Exec(database.GetDefaultSchemaSQL()); err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "running schema sql"))
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Cleanup(func() { db.Close() })
|
||||||
|
|
||||||
|
return DnoteCtx{
|
||||||
|
DB: db,
|
||||||
|
Paths: paths,
|
||||||
|
Clock: clock.NewMock(), // Use a mock clock to test times
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,123 +0,0 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
|
||||||
*
|
|
||||||
* This file is part of Dnote.
|
|
||||||
*
|
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Package crypt provides cryptographic funcitonalities
|
|
||||||
package crypt
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/aes"
|
|
||||||
"crypto/cipher"
|
|
||||||
"crypto/rand"
|
|
||||||
"crypto/sha256"
|
|
||||||
"encoding/base64"
|
|
||||||
"io"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"golang.org/x/crypto/hkdf"
|
|
||||||
"golang.org/x/crypto/pbkdf2"
|
|
||||||
)
|
|
||||||
|
|
||||||
var aesGcmNonceSize = 12
|
|
||||||
|
|
||||||
func runHkdf(secret, salt, info []byte) ([]byte, error) {
|
|
||||||
r := hkdf.New(sha256.New, secret, salt, info)
|
|
||||||
|
|
||||||
ret := make([]byte, 32)
|
|
||||||
_, err := io.ReadFull(r, ret)
|
|
||||||
if err != nil {
|
|
||||||
return []byte{}, errors.Wrap(err, "reading key bytes")
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MakeKeys derives, from the given credential, a key set comprising of an encryption key
|
|
||||||
// and an authentication key
|
|
||||||
func MakeKeys(password, email []byte, iteration int) ([]byte, []byte, error) {
|
|
||||||
masterKey := pbkdf2.Key([]byte(password), []byte(email), iteration, 32, sha256.New)
|
|
||||||
|
|
||||||
authKey, err := runHkdf(masterKey, email, []byte("auth"))
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, errors.Wrap(err, "deriving auth key")
|
|
||||||
}
|
|
||||||
|
|
||||||
return masterKey, authKey, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// AesGcmEncrypt encrypts the plaintext using AES in a GCM mode. It returns
|
|
||||||
// a ciphertext prepended by a 12 byte pseudo-random nonce, encoded in base64.
|
|
||||||
func AesGcmEncrypt(key, plaintext []byte) (string, error) {
|
|
||||||
if key == nil {
|
|
||||||
return "", errors.New("no key provided")
|
|
||||||
}
|
|
||||||
|
|
||||||
block, err := aes.NewCipher(key)
|
|
||||||
if err != nil {
|
|
||||||
return "", errors.Wrap(err, "initializing aes")
|
|
||||||
}
|
|
||||||
|
|
||||||
aesgcm, err := cipher.NewGCM(block)
|
|
||||||
if err != nil {
|
|
||||||
return "", errors.Wrap(err, "initializing gcm")
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce := make([]byte, aesGcmNonceSize)
|
|
||||||
if _, err := io.ReadFull(rand.Reader, nonce); err != nil {
|
|
||||||
return "", errors.Wrap(err, "generating nonce")
|
|
||||||
}
|
|
||||||
|
|
||||||
ciphertext := aesgcm.Seal(nonce, nonce, []byte(plaintext), nil)
|
|
||||||
cipherKeyB64 := base64.StdEncoding.EncodeToString(ciphertext)
|
|
||||||
|
|
||||||
return cipherKeyB64, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// AesGcmDecrypt decrypts the encrypted data using AES in a GCM mode. The data should be
|
|
||||||
// a base64 encoded string in the format of 12 byte nonce followed by a ciphertext.
|
|
||||||
func AesGcmDecrypt(key []byte, dataB64 string) ([]byte, error) {
|
|
||||||
if key == nil {
|
|
||||||
return nil, errors.New("no key provided")
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := base64.StdEncoding.DecodeString(dataB64)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "decoding base64 data")
|
|
||||||
}
|
|
||||||
|
|
||||||
block, err := aes.NewCipher(key)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "initializing aes")
|
|
||||||
}
|
|
||||||
|
|
||||||
aesgcm, err := cipher.NewGCM(block)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "initializing gcm")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(data) < aesGcmNonceSize {
|
|
||||||
return nil, errors.Wrap(err, "malformed data")
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, ciphertext := data[:aesGcmNonceSize], data[aesGcmNonceSize:]
|
|
||||||
plaintext, err := aesgcm.Open(nil, nonce, ciphertext, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "decrypting")
|
|
||||||
}
|
|
||||||
|
|
||||||
return plaintext, nil
|
|
||||||
}
|
|
||||||
|
|
@ -1,118 +0,0 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
|
||||||
*
|
|
||||||
* This file is part of Dnote.
|
|
||||||
*
|
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package crypt
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/aes"
|
|
||||||
"crypto/cipher"
|
|
||||||
"encoding/base64"
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/assert"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestAesGcmEncrypt(t *testing.T) {
|
|
||||||
testCases := []struct {
|
|
||||||
key []byte
|
|
||||||
plaintext []byte
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
key: []byte("AES256Key-32Characters1234567890"),
|
|
||||||
plaintext: []byte("foo bar baz quz"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: []byte("AES256Key-32Charactersabcdefghij"),
|
|
||||||
plaintext: []byte("1234 foo 5678 bar 7890 baz"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tc := range testCases {
|
|
||||||
t.Run(fmt.Sprintf("key %s plaintext %s", tc.key, tc.plaintext), func(t *testing.T) {
|
|
||||||
// encrypt
|
|
||||||
dataB64, err := AesGcmEncrypt(tc.key, tc.plaintext)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(errors.Wrap(err, "performing encryption"))
|
|
||||||
}
|
|
||||||
|
|
||||||
// test that data can be decrypted
|
|
||||||
data, err := base64.StdEncoding.DecodeString(dataB64)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(errors.Wrap(err, "decoding data from base64"))
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, ciphertext := data[:12], data[12:]
|
|
||||||
|
|
||||||
fmt.Println(string(data))
|
|
||||||
|
|
||||||
block, err := aes.NewCipher([]byte(tc.key))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(errors.Wrap(err, "initializing aes"))
|
|
||||||
}
|
|
||||||
|
|
||||||
aesgcm, err := cipher.NewGCM(block)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(errors.Wrap(err, "initializing gcm"))
|
|
||||||
}
|
|
||||||
|
|
||||||
plaintext, err := aesgcm.Open(nil, nonce, ciphertext, nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(errors.Wrap(err, "decode"))
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.DeepEqual(t, plaintext, tc.plaintext, "plaintext mismatch")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAesGcmDecrypt(t *testing.T) {
|
|
||||||
testCases := []struct {
|
|
||||||
key []byte
|
|
||||||
ciphertextB64 string
|
|
||||||
expectedPlaintext string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
key: []byte("AES256Key-32Characters1234567890"),
|
|
||||||
ciphertextB64: "M2ov9hWMQ52v1S/zigwX3bJt4cVCV02uiRm/grKqN/rZxNkJrD7vK4Ii0g==",
|
|
||||||
expectedPlaintext: "foo bar baz quz",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: []byte("AES256Key-32Characters1234567890"),
|
|
||||||
ciphertextB64: "M4csFKUIUbD1FBEzLgHjscoKgN0lhMGJ0n2nKWiCkE/qSKlRP7kS",
|
|
||||||
expectedPlaintext: "foo\n1\nbar\n2",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: []byte("AES256Key-32Characters1234567890"),
|
|
||||||
ciphertextB64: "pe/fnw73MR1clmVIlRSJ5gDwBdnPly/DF7DsR5dJVz4dHZlv0b10WzvJEGOCHZEr+Q==",
|
|
||||||
expectedPlaintext: "föo\nbār\nbåz & qūz",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tc := range testCases {
|
|
||||||
t.Run(fmt.Sprintf("key %s ciphertext %s", tc.key, tc.ciphertextB64), func(t *testing.T) {
|
|
||||||
plaintext, err := AesGcmDecrypt(tc.key, tc.ciphertextB64)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(errors.Wrap(err, "performing decryption"))
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.DeepEqual(t, plaintext, []byte(tc.expectedPlaintext), "plaintext mismatch")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package database
|
package database
|
||||||
|
|
@ -41,13 +38,12 @@ type Note struct {
|
||||||
AddedOn int64 `json:"added_on"`
|
AddedOn int64 `json:"added_on"`
|
||||||
EditedOn int64 `json:"edited_on"`
|
EditedOn int64 `json:"edited_on"`
|
||||||
USN int `json:"usn"`
|
USN int `json:"usn"`
|
||||||
Public bool `json:"public"`
|
|
||||||
Deleted bool `json:"deleted"`
|
Deleted bool `json:"deleted"`
|
||||||
Dirty bool `json:"dirty"`
|
Dirty bool `json:"dirty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNote constructs a note with the given data
|
// NewNote constructs a note with the given data
|
||||||
func NewNote(uuid, bookUUID, body string, addedOn, editedOn int64, usn int, public, deleted, dirty bool) Note {
|
func NewNote(uuid, bookUUID, body string, addedOn, editedOn int64, usn int, deleted, dirty bool) Note {
|
||||||
return Note{
|
return Note{
|
||||||
UUID: uuid,
|
UUID: uuid,
|
||||||
BookUUID: bookUUID,
|
BookUUID: bookUUID,
|
||||||
|
|
@ -55,7 +51,6 @@ func NewNote(uuid, bookUUID, body string, addedOn, editedOn int64, usn int, publ
|
||||||
AddedOn: addedOn,
|
AddedOn: addedOn,
|
||||||
EditedOn: editedOn,
|
EditedOn: editedOn,
|
||||||
USN: usn,
|
USN: usn,
|
||||||
Public: public,
|
|
||||||
Deleted: deleted,
|
Deleted: deleted,
|
||||||
Dirty: dirty,
|
Dirty: dirty,
|
||||||
}
|
}
|
||||||
|
|
@ -63,8 +58,8 @@ func NewNote(uuid, bookUUID, body string, addedOn, editedOn int64, usn int, publ
|
||||||
|
|
||||||
// Insert inserts a new note
|
// Insert inserts a new note
|
||||||
func (n Note) Insert(db *DB) error {
|
func (n Note) Insert(db *DB) error {
|
||||||
_, err := db.Exec("INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
_, err := db.Exec("INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
n.UUID, n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Public, n.Deleted, n.Dirty)
|
n.UUID, n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Deleted, n.Dirty)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "inserting note with uuid %s", n.UUID)
|
return errors.Wrapf(err, "inserting note with uuid %s", n.UUID)
|
||||||
|
|
@ -75,8 +70,8 @@ func (n Note) Insert(db *DB) error {
|
||||||
|
|
||||||
// Update updates the note with the given data
|
// Update updates the note with the given data
|
||||||
func (n Note) Update(db *DB) error {
|
func (n Note) Update(db *DB) error {
|
||||||
_, err := db.Exec("UPDATE notes SET book_uuid = ?, body = ?, added_on = ?, edited_on = ?, usn = ?, public = ?, deleted = ?, dirty = ? WHERE uuid = ?",
|
_, err := db.Exec("UPDATE notes SET book_uuid = ?, body = ?, added_on = ?, edited_on = ?, usn = ?, deleted = ?, dirty = ? WHERE uuid = ?",
|
||||||
n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Public, n.Deleted, n.Dirty, n.UUID)
|
n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Deleted, n.Dirty, n.UUID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "updating the note with uuid %s", n.UUID)
|
return errors.Wrapf(err, "updating the note with uuid %s", n.UUID)
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package database
|
package database
|
||||||
|
|
@ -34,7 +31,6 @@ func TestNewNote(t *testing.T) {
|
||||||
addedOn int64
|
addedOn int64
|
||||||
editedOn int64
|
editedOn int64
|
||||||
usn int
|
usn int
|
||||||
public bool
|
|
||||||
deleted bool
|
deleted bool
|
||||||
dirty bool
|
dirty bool
|
||||||
}{
|
}{
|
||||||
|
|
@ -45,7 +41,6 @@ func TestNewNote(t *testing.T) {
|
||||||
addedOn: 1542058875,
|
addedOn: 1542058875,
|
||||||
editedOn: 0,
|
editedOn: 0,
|
||||||
usn: 0,
|
usn: 0,
|
||||||
public: false,
|
|
||||||
deleted: false,
|
deleted: false,
|
||||||
dirty: false,
|
dirty: false,
|
||||||
},
|
},
|
||||||
|
|
@ -56,14 +51,13 @@ func TestNewNote(t *testing.T) {
|
||||||
addedOn: 1542058875,
|
addedOn: 1542058875,
|
||||||
editedOn: 1542058876,
|
editedOn: 1542058876,
|
||||||
usn: 1008,
|
usn: 1008,
|
||||||
public: true,
|
|
||||||
deleted: true,
|
deleted: true,
|
||||||
dirty: true,
|
dirty: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for idx, tc := range testCases {
|
for idx, tc := range testCases {
|
||||||
got := NewNote(tc.uuid, tc.bookUUID, tc.body, tc.addedOn, tc.editedOn, tc.usn, tc.public, tc.deleted, tc.dirty)
|
got := NewNote(tc.uuid, tc.bookUUID, tc.body, tc.addedOn, tc.editedOn, tc.usn, tc.deleted, tc.dirty)
|
||||||
|
|
||||||
assert.Equal(t, got.UUID, tc.uuid, fmt.Sprintf("UUID mismatch for test case %d", idx))
|
assert.Equal(t, got.UUID, tc.uuid, fmt.Sprintf("UUID mismatch for test case %d", idx))
|
||||||
assert.Equal(t, got.BookUUID, tc.bookUUID, fmt.Sprintf("BookUUID mismatch for test case %d", idx))
|
assert.Equal(t, got.BookUUID, tc.bookUUID, fmt.Sprintf("BookUUID mismatch for test case %d", idx))
|
||||||
|
|
@ -71,7 +65,6 @@ func TestNewNote(t *testing.T) {
|
||||||
assert.Equal(t, got.AddedOn, tc.addedOn, fmt.Sprintf("AddedOn mismatch for test case %d", idx))
|
assert.Equal(t, got.AddedOn, tc.addedOn, fmt.Sprintf("AddedOn mismatch for test case %d", idx))
|
||||||
assert.Equal(t, got.EditedOn, tc.editedOn, fmt.Sprintf("EditedOn mismatch for test case %d", idx))
|
assert.Equal(t, got.EditedOn, tc.editedOn, fmt.Sprintf("EditedOn mismatch for test case %d", idx))
|
||||||
assert.Equal(t, got.USN, tc.usn, fmt.Sprintf("USN mismatch for test case %d", idx))
|
assert.Equal(t, got.USN, tc.usn, fmt.Sprintf("USN mismatch for test case %d", idx))
|
||||||
assert.Equal(t, got.Public, tc.public, fmt.Sprintf("Public mismatch for test case %d", idx))
|
|
||||||
assert.Equal(t, got.Deleted, tc.deleted, fmt.Sprintf("Deleted mismatch for test case %d", idx))
|
assert.Equal(t, got.Deleted, tc.deleted, fmt.Sprintf("Deleted mismatch for test case %d", idx))
|
||||||
assert.Equal(t, got.Dirty, tc.dirty, fmt.Sprintf("Dirty mismatch for test case %d", idx))
|
assert.Equal(t, got.Dirty, tc.dirty, fmt.Sprintf("Dirty mismatch for test case %d", idx))
|
||||||
}
|
}
|
||||||
|
|
@ -85,7 +78,6 @@ func TestNoteInsert(t *testing.T) {
|
||||||
addedOn int64
|
addedOn int64
|
||||||
editedOn int64
|
editedOn int64
|
||||||
usn int
|
usn int
|
||||||
public bool
|
|
||||||
deleted bool
|
deleted bool
|
||||||
dirty bool
|
dirty bool
|
||||||
}{
|
}{
|
||||||
|
|
@ -96,7 +88,6 @@ func TestNoteInsert(t *testing.T) {
|
||||||
addedOn: 1542058875,
|
addedOn: 1542058875,
|
||||||
editedOn: 0,
|
editedOn: 0,
|
||||||
usn: 0,
|
usn: 0,
|
||||||
public: false,
|
|
||||||
deleted: false,
|
deleted: false,
|
||||||
dirty: false,
|
dirty: false,
|
||||||
},
|
},
|
||||||
|
|
@ -107,7 +98,6 @@ func TestNoteInsert(t *testing.T) {
|
||||||
addedOn: 1542058875,
|
addedOn: 1542058875,
|
||||||
editedOn: 1542058876,
|
editedOn: 1542058876,
|
||||||
usn: 1008,
|
usn: 1008,
|
||||||
public: true,
|
|
||||||
deleted: true,
|
deleted: true,
|
||||||
dirty: true,
|
dirty: true,
|
||||||
},
|
},
|
||||||
|
|
@ -116,8 +106,7 @@ func TestNoteInsert(t *testing.T) {
|
||||||
for idx, tc := range testCases {
|
for idx, tc := range testCases {
|
||||||
func() {
|
func() {
|
||||||
// Setup
|
// Setup
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
n := Note{
|
n := Note{
|
||||||
UUID: tc.uuid,
|
UUID: tc.uuid,
|
||||||
|
|
@ -126,7 +115,6 @@ func TestNoteInsert(t *testing.T) {
|
||||||
AddedOn: tc.addedOn,
|
AddedOn: tc.addedOn,
|
||||||
EditedOn: tc.editedOn,
|
EditedOn: tc.editedOn,
|
||||||
USN: tc.usn,
|
USN: tc.usn,
|
||||||
Public: tc.public,
|
|
||||||
Deleted: tc.deleted,
|
Deleted: tc.deleted,
|
||||||
Dirty: tc.dirty,
|
Dirty: tc.dirty,
|
||||||
}
|
}
|
||||||
|
|
@ -134,12 +122,12 @@ func TestNoteInsert(t *testing.T) {
|
||||||
// execute
|
// execute
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := n.Insert(tx); err != nil {
|
if err := n.Insert(tx); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
@ -148,10 +136,10 @@ func TestNoteInsert(t *testing.T) {
|
||||||
var uuid, bookUUID, body string
|
var uuid, bookUUID, body string
|
||||||
var addedOn, editedOn int64
|
var addedOn, editedOn int64
|
||||||
var usn int
|
var usn int
|
||||||
var public, deleted, dirty bool
|
var deleted, dirty bool
|
||||||
MustScan(t, "getting n1",
|
MustScan(t, "getting n1",
|
||||||
db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty FROM notes WHERE uuid = ?", tc.uuid),
|
db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty FROM notes WHERE uuid = ?", tc.uuid),
|
||||||
&uuid, &bookUUID, &body, &addedOn, &editedOn, &usn, &public, &deleted, &dirty)
|
&uuid, &bookUUID, &body, &addedOn, &editedOn, &usn, &deleted, &dirty)
|
||||||
|
|
||||||
assert.Equal(t, uuid, tc.uuid, fmt.Sprintf("uuid mismatch for test case %d", idx))
|
assert.Equal(t, uuid, tc.uuid, fmt.Sprintf("uuid mismatch for test case %d", idx))
|
||||||
assert.Equal(t, bookUUID, tc.bookUUID, fmt.Sprintf("bookUUID mismatch for test case %d", idx))
|
assert.Equal(t, bookUUID, tc.bookUUID, fmt.Sprintf("bookUUID mismatch for test case %d", idx))
|
||||||
|
|
@ -159,7 +147,6 @@ func TestNoteInsert(t *testing.T) {
|
||||||
assert.Equal(t, addedOn, tc.addedOn, fmt.Sprintf("addedOn mismatch for test case %d", idx))
|
assert.Equal(t, addedOn, tc.addedOn, fmt.Sprintf("addedOn mismatch for test case %d", idx))
|
||||||
assert.Equal(t, editedOn, tc.editedOn, fmt.Sprintf("editedOn mismatch for test case %d", idx))
|
assert.Equal(t, editedOn, tc.editedOn, fmt.Sprintf("editedOn mismatch for test case %d", idx))
|
||||||
assert.Equal(t, usn, tc.usn, fmt.Sprintf("usn mismatch for test case %d", idx))
|
assert.Equal(t, usn, tc.usn, fmt.Sprintf("usn mismatch for test case %d", idx))
|
||||||
assert.Equal(t, public, tc.public, fmt.Sprintf("public mismatch for test case %d", idx))
|
|
||||||
assert.Equal(t, deleted, tc.deleted, fmt.Sprintf("deleted mismatch for test case %d", idx))
|
assert.Equal(t, deleted, tc.deleted, fmt.Sprintf("deleted mismatch for test case %d", idx))
|
||||||
assert.Equal(t, dirty, tc.dirty, fmt.Sprintf("dirty mismatch for test case %d", idx))
|
assert.Equal(t, dirty, tc.dirty, fmt.Sprintf("dirty mismatch for test case %d", idx))
|
||||||
}()
|
}()
|
||||||
|
|
@ -174,14 +161,12 @@ func TestNoteUpdate(t *testing.T) {
|
||||||
addedOn int64
|
addedOn int64
|
||||||
editedOn int64
|
editedOn int64
|
||||||
usn int
|
usn int
|
||||||
public bool
|
|
||||||
deleted bool
|
deleted bool
|
||||||
dirty bool
|
dirty bool
|
||||||
newBookUUID string
|
newBookUUID string
|
||||||
newBody string
|
newBody string
|
||||||
newEditedOn int64
|
newEditedOn int64
|
||||||
newUSN int
|
newUSN int
|
||||||
newPublic bool
|
|
||||||
newDeleted bool
|
newDeleted bool
|
||||||
newDirty bool
|
newDirty bool
|
||||||
}{
|
}{
|
||||||
|
|
@ -192,14 +177,12 @@ func TestNoteUpdate(t *testing.T) {
|
||||||
addedOn: 1542058875,
|
addedOn: 1542058875,
|
||||||
editedOn: 0,
|
editedOn: 0,
|
||||||
usn: 0,
|
usn: 0,
|
||||||
public: false,
|
|
||||||
deleted: false,
|
deleted: false,
|
||||||
dirty: false,
|
dirty: false,
|
||||||
newBookUUID: "b1-uuid",
|
newBookUUID: "b1-uuid",
|
||||||
newBody: "n1-body edited",
|
newBody: "n1-body edited",
|
||||||
newEditedOn: 1542058879,
|
newEditedOn: 1542058879,
|
||||||
newUSN: 0,
|
newUSN: 0,
|
||||||
newPublic: false,
|
|
||||||
newDeleted: false,
|
newDeleted: false,
|
||||||
newDirty: false,
|
newDirty: false,
|
||||||
},
|
},
|
||||||
|
|
@ -210,14 +193,12 @@ func TestNoteUpdate(t *testing.T) {
|
||||||
addedOn: 1542058875,
|
addedOn: 1542058875,
|
||||||
editedOn: 0,
|
editedOn: 0,
|
||||||
usn: 0,
|
usn: 0,
|
||||||
public: false,
|
|
||||||
deleted: false,
|
deleted: false,
|
||||||
dirty: true,
|
dirty: true,
|
||||||
newBookUUID: "b2-uuid",
|
newBookUUID: "b2-uuid",
|
||||||
newBody: "n1-body",
|
newBody: "n1-body",
|
||||||
newEditedOn: 1542058879,
|
newEditedOn: 1542058879,
|
||||||
newUSN: 0,
|
newUSN: 0,
|
||||||
newPublic: true,
|
|
||||||
newDeleted: false,
|
newDeleted: false,
|
||||||
newDirty: false,
|
newDirty: false,
|
||||||
},
|
},
|
||||||
|
|
@ -228,14 +209,12 @@ func TestNoteUpdate(t *testing.T) {
|
||||||
addedOn: 1542058875,
|
addedOn: 1542058875,
|
||||||
editedOn: 0,
|
editedOn: 0,
|
||||||
usn: 10,
|
usn: 10,
|
||||||
public: false,
|
|
||||||
deleted: false,
|
deleted: false,
|
||||||
dirty: false,
|
dirty: false,
|
||||||
newBookUUID: "",
|
newBookUUID: "",
|
||||||
newBody: "",
|
newBody: "",
|
||||||
newEditedOn: 1542058879,
|
newEditedOn: 1542058879,
|
||||||
newUSN: 151,
|
newUSN: 151,
|
||||||
newPublic: false,
|
|
||||||
newDeleted: true,
|
newDeleted: true,
|
||||||
newDirty: false,
|
newDirty: false,
|
||||||
},
|
},
|
||||||
|
|
@ -246,14 +225,12 @@ func TestNoteUpdate(t *testing.T) {
|
||||||
addedOn: 1542058875,
|
addedOn: 1542058875,
|
||||||
editedOn: 0,
|
editedOn: 0,
|
||||||
usn: 0,
|
usn: 0,
|
||||||
public: false,
|
|
||||||
deleted: false,
|
deleted: false,
|
||||||
dirty: false,
|
dirty: false,
|
||||||
newBookUUID: "",
|
newBookUUID: "",
|
||||||
newBody: "",
|
newBody: "",
|
||||||
newEditedOn: 1542058879,
|
newEditedOn: 1542058879,
|
||||||
newUSN: 15,
|
newUSN: 15,
|
||||||
newPublic: false,
|
|
||||||
newDeleted: true,
|
newDeleted: true,
|
||||||
newDirty: false,
|
newDirty: false,
|
||||||
},
|
},
|
||||||
|
|
@ -262,8 +239,7 @@ func TestNoteUpdate(t *testing.T) {
|
||||||
for idx, tc := range testCases {
|
for idx, tc := range testCases {
|
||||||
func() {
|
func() {
|
||||||
// Setup
|
// Setup
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
n1 := Note{
|
n1 := Note{
|
||||||
UUID: tc.uuid,
|
UUID: tc.uuid,
|
||||||
|
|
@ -272,7 +248,6 @@ func TestNoteUpdate(t *testing.T) {
|
||||||
AddedOn: tc.addedOn,
|
AddedOn: tc.addedOn,
|
||||||
EditedOn: tc.editedOn,
|
EditedOn: tc.editedOn,
|
||||||
USN: tc.usn,
|
USN: tc.usn,
|
||||||
Public: tc.public,
|
|
||||||
Deleted: tc.deleted,
|
Deleted: tc.deleted,
|
||||||
Dirty: tc.dirty,
|
Dirty: tc.dirty,
|
||||||
}
|
}
|
||||||
|
|
@ -283,31 +258,29 @@ func TestNoteUpdate(t *testing.T) {
|
||||||
AddedOn: 1542058875,
|
AddedOn: 1542058875,
|
||||||
EditedOn: 0,
|
EditedOn: 0,
|
||||||
USN: 39,
|
USN: 39,
|
||||||
Public: false,
|
|
||||||
Deleted: false,
|
Deleted: false,
|
||||||
Dirty: false,
|
Dirty: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
MustExec(t, fmt.Sprintf("inserting n1 for test case %d", idx), db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n1.UUID, n1.BookUUID, n1.USN, n1.AddedOn, n1.EditedOn, n1.Body, n1.Public, n1.Deleted, n1.Dirty)
|
MustExec(t, fmt.Sprintf("inserting n1 for test case %d", idx), db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n1.UUID, n1.BookUUID, n1.USN, n1.AddedOn, n1.EditedOn, n1.Body, n1.Deleted, n1.Dirty)
|
||||||
MustExec(t, fmt.Sprintf("inserting n2 for test case %d", idx), db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n2.UUID, n2.BookUUID, n2.USN, n2.AddedOn, n2.EditedOn, n2.Body, n2.Public, n2.Deleted, n2.Dirty)
|
MustExec(t, fmt.Sprintf("inserting n2 for test case %d", idx), db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n2.UUID, n2.BookUUID, n2.USN, n2.AddedOn, n2.EditedOn, n2.Body, n2.Deleted, n2.Dirty)
|
||||||
|
|
||||||
// execute
|
// execute
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
n1.BookUUID = tc.newBookUUID
|
n1.BookUUID = tc.newBookUUID
|
||||||
n1.Body = tc.newBody
|
n1.Body = tc.newBody
|
||||||
n1.EditedOn = tc.newEditedOn
|
n1.EditedOn = tc.newEditedOn
|
||||||
n1.USN = tc.newUSN
|
n1.USN = tc.newUSN
|
||||||
n1.Public = tc.newPublic
|
|
||||||
n1.Deleted = tc.newDeleted
|
n1.Deleted = tc.newDeleted
|
||||||
n1.Dirty = tc.newDirty
|
n1.Dirty = tc.newDirty
|
||||||
|
|
||||||
if err := n1.Update(tx); err != nil {
|
if err := n1.Update(tx); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
@ -315,11 +288,11 @@ func TestNoteUpdate(t *testing.T) {
|
||||||
// test
|
// test
|
||||||
var n1Record, n2Record Note
|
var n1Record, n2Record Note
|
||||||
MustScan(t, "getting n1",
|
MustScan(t, "getting n1",
|
||||||
db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty FROM notes WHERE uuid = ?", tc.uuid),
|
db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty FROM notes WHERE uuid = ?", tc.uuid),
|
||||||
&n1Record.UUID, &n1Record.BookUUID, &n1Record.Body, &n1Record.AddedOn, &n1Record.EditedOn, &n1Record.USN, &n1Record.Public, &n1Record.Deleted, &n1Record.Dirty)
|
&n1Record.UUID, &n1Record.BookUUID, &n1Record.Body, &n1Record.AddedOn, &n1Record.EditedOn, &n1Record.USN, &n1Record.Deleted, &n1Record.Dirty)
|
||||||
MustScan(t, "getting n2",
|
MustScan(t, "getting n2",
|
||||||
db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty FROM notes WHERE uuid = ?", n2.UUID),
|
db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty FROM notes WHERE uuid = ?", n2.UUID),
|
||||||
&n2Record.UUID, &n2Record.BookUUID, &n2Record.Body, &n2Record.AddedOn, &n2Record.EditedOn, &n2Record.USN, &n2Record.Public, &n2Record.Deleted, &n2Record.Dirty)
|
&n2Record.UUID, &n2Record.BookUUID, &n2Record.Body, &n2Record.AddedOn, &n2Record.EditedOn, &n2Record.USN, &n2Record.Deleted, &n2Record.Dirty)
|
||||||
|
|
||||||
assert.Equal(t, n1Record.UUID, n1.UUID, fmt.Sprintf("n1 uuid mismatch for test case %d", idx))
|
assert.Equal(t, n1Record.UUID, n1.UUID, fmt.Sprintf("n1 uuid mismatch for test case %d", idx))
|
||||||
assert.Equal(t, n1Record.BookUUID, tc.newBookUUID, fmt.Sprintf("n1 bookUUID mismatch for test case %d", idx))
|
assert.Equal(t, n1Record.BookUUID, tc.newBookUUID, fmt.Sprintf("n1 bookUUID mismatch for test case %d", idx))
|
||||||
|
|
@ -327,7 +300,6 @@ func TestNoteUpdate(t *testing.T) {
|
||||||
assert.Equal(t, n1Record.AddedOn, n1.AddedOn, fmt.Sprintf("n1 addedOn mismatch for test case %d", idx))
|
assert.Equal(t, n1Record.AddedOn, n1.AddedOn, fmt.Sprintf("n1 addedOn mismatch for test case %d", idx))
|
||||||
assert.Equal(t, n1Record.EditedOn, tc.newEditedOn, fmt.Sprintf("n1 editedOn mismatch for test case %d", idx))
|
assert.Equal(t, n1Record.EditedOn, tc.newEditedOn, fmt.Sprintf("n1 editedOn mismatch for test case %d", idx))
|
||||||
assert.Equal(t, n1Record.USN, tc.newUSN, fmt.Sprintf("n1 usn mismatch for test case %d", idx))
|
assert.Equal(t, n1Record.USN, tc.newUSN, fmt.Sprintf("n1 usn mismatch for test case %d", idx))
|
||||||
assert.Equal(t, n1Record.Public, tc.newPublic, fmt.Sprintf("n1 public mismatch for test case %d", idx))
|
|
||||||
assert.Equal(t, n1Record.Deleted, tc.newDeleted, fmt.Sprintf("n1 deleted mismatch for test case %d", idx))
|
assert.Equal(t, n1Record.Deleted, tc.newDeleted, fmt.Sprintf("n1 deleted mismatch for test case %d", idx))
|
||||||
assert.Equal(t, n1Record.Dirty, tc.newDirty, fmt.Sprintf("n1 dirty mismatch for test case %d", idx))
|
assert.Equal(t, n1Record.Dirty, tc.newDirty, fmt.Sprintf("n1 dirty mismatch for test case %d", idx))
|
||||||
|
|
||||||
|
|
@ -337,7 +309,6 @@ func TestNoteUpdate(t *testing.T) {
|
||||||
assert.Equal(t, n2Record.AddedOn, n2.AddedOn, fmt.Sprintf("n2 addedOn mismatch for test case %d", idx))
|
assert.Equal(t, n2Record.AddedOn, n2.AddedOn, fmt.Sprintf("n2 addedOn mismatch for test case %d", idx))
|
||||||
assert.Equal(t, n2Record.EditedOn, n2.EditedOn, fmt.Sprintf("n2 editedOn mismatch for test case %d", idx))
|
assert.Equal(t, n2Record.EditedOn, n2.EditedOn, fmt.Sprintf("n2 editedOn mismatch for test case %d", idx))
|
||||||
assert.Equal(t, n2Record.USN, n2.USN, fmt.Sprintf("n2 usn mismatch for test case %d", idx))
|
assert.Equal(t, n2Record.USN, n2.USN, fmt.Sprintf("n2 usn mismatch for test case %d", idx))
|
||||||
assert.Equal(t, n2Record.Public, n2.Public, fmt.Sprintf("n2 public mismatch for test case %d", idx))
|
|
||||||
assert.Equal(t, n2Record.Deleted, n2.Deleted, fmt.Sprintf("n2 deleted mismatch for test case %d", idx))
|
assert.Equal(t, n2Record.Deleted, n2.Deleted, fmt.Sprintf("n2 deleted mismatch for test case %d", idx))
|
||||||
assert.Equal(t, n2Record.Dirty, n2.Dirty, fmt.Sprintf("n2 dirty mismatch for test case %d", idx))
|
assert.Equal(t, n2Record.Dirty, n2.Dirty, fmt.Sprintf("n2 dirty mismatch for test case %d", idx))
|
||||||
}()
|
}()
|
||||||
|
|
@ -359,8 +330,7 @@ func TestNoteUpdateUUID(t *testing.T) {
|
||||||
for idx, tc := range testCases {
|
for idx, tc := range testCases {
|
||||||
t.Run(fmt.Sprintf("testCase%d", idx), func(t *testing.T) {
|
t.Run(fmt.Sprintf("testCase%d", idx), func(t *testing.T) {
|
||||||
// Setup
|
// Setup
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
n1 := Note{
|
n1 := Note{
|
||||||
UUID: "n1-uuid",
|
UUID: "n1-uuid",
|
||||||
|
|
@ -387,11 +357,11 @@ func TestNoteUpdateUUID(t *testing.T) {
|
||||||
// execute
|
// execute
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||||
}
|
}
|
||||||
if err := n1.UpdateUUID(tx, tc.newUUID); err != nil {
|
if err := n1.UpdateUUID(tx, tc.newUUID); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
@ -414,8 +384,7 @@ func TestNoteUpdateUUID(t *testing.T) {
|
||||||
|
|
||||||
func TestNoteExpunge(t *testing.T) {
|
func TestNoteExpunge(t *testing.T) {
|
||||||
// Setup
|
// Setup
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
n1 := Note{
|
n1 := Note{
|
||||||
UUID: "n1-uuid",
|
UUID: "n1-uuid",
|
||||||
|
|
@ -424,7 +393,6 @@ func TestNoteExpunge(t *testing.T) {
|
||||||
AddedOn: 1542058874,
|
AddedOn: 1542058874,
|
||||||
EditedOn: 0,
|
EditedOn: 0,
|
||||||
USN: 22,
|
USN: 22,
|
||||||
Public: false,
|
|
||||||
Deleted: false,
|
Deleted: false,
|
||||||
Dirty: false,
|
Dirty: false,
|
||||||
}
|
}
|
||||||
|
|
@ -435,23 +403,22 @@ func TestNoteExpunge(t *testing.T) {
|
||||||
AddedOn: 1542058875,
|
AddedOn: 1542058875,
|
||||||
EditedOn: 0,
|
EditedOn: 0,
|
||||||
USN: 39,
|
USN: 39,
|
||||||
Public: false,
|
|
||||||
Deleted: false,
|
Deleted: false,
|
||||||
Dirty: false,
|
Dirty: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n1.UUID, n1.BookUUID, n1.USN, n1.AddedOn, n1.EditedOn, n1.Body, n1.Public, n1.Deleted, n1.Dirty)
|
MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n1.UUID, n1.BookUUID, n1.USN, n1.AddedOn, n1.EditedOn, n1.Body, n1.Deleted, n1.Dirty)
|
||||||
MustExec(t, "inserting n2", db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n2.UUID, n2.BookUUID, n2.USN, n2.AddedOn, n2.EditedOn, n2.Body, n2.Public, n2.Deleted, n2.Dirty)
|
MustExec(t, "inserting n2", db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n2.UUID, n2.BookUUID, n2.USN, n2.AddedOn, n2.EditedOn, n2.Body, n2.Deleted, n2.Dirty)
|
||||||
|
|
||||||
// execute
|
// execute
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := n1.Expunge(tx); err != nil {
|
if err := n1.Expunge(tx); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
@ -464,8 +431,8 @@ func TestNoteExpunge(t *testing.T) {
|
||||||
|
|
||||||
var n2Record Note
|
var n2Record Note
|
||||||
MustScan(t, "getting n2",
|
MustScan(t, "getting n2",
|
||||||
db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty FROM notes WHERE uuid = ?", n2.UUID),
|
db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty FROM notes WHERE uuid = ?", n2.UUID),
|
||||||
&n2Record.UUID, &n2Record.BookUUID, &n2Record.Body, &n2Record.AddedOn, &n2Record.EditedOn, &n2Record.USN, &n2Record.Public, &n2Record.Deleted, &n2Record.Dirty)
|
&n2Record.UUID, &n2Record.BookUUID, &n2Record.Body, &n2Record.AddedOn, &n2Record.EditedOn, &n2Record.USN, &n2Record.Deleted, &n2Record.Dirty)
|
||||||
|
|
||||||
assert.Equal(t, n2Record.UUID, n2.UUID, "n2 uuid mismatch")
|
assert.Equal(t, n2Record.UUID, n2.UUID, "n2 uuid mismatch")
|
||||||
assert.Equal(t, n2Record.BookUUID, n2.BookUUID, "n2 bookUUID mismatch")
|
assert.Equal(t, n2Record.BookUUID, n2.BookUUID, "n2 bookUUID mismatch")
|
||||||
|
|
@ -473,7 +440,6 @@ func TestNoteExpunge(t *testing.T) {
|
||||||
assert.Equal(t, n2Record.AddedOn, n2.AddedOn, "n2 addedOn mismatch")
|
assert.Equal(t, n2Record.AddedOn, n2.AddedOn, "n2 addedOn mismatch")
|
||||||
assert.Equal(t, n2Record.EditedOn, n2.EditedOn, "n2 editedOn mismatch")
|
assert.Equal(t, n2Record.EditedOn, n2.EditedOn, "n2 editedOn mismatch")
|
||||||
assert.Equal(t, n2Record.USN, n2.USN, "n2 usn mismatch")
|
assert.Equal(t, n2Record.USN, n2.USN, "n2 usn mismatch")
|
||||||
assert.Equal(t, n2Record.Public, n2.Public, "n2 public mismatch")
|
|
||||||
assert.Equal(t, n2Record.Deleted, n2.Deleted, "n2 deleted mismatch")
|
assert.Equal(t, n2Record.Deleted, n2.Deleted, "n2 deleted mismatch")
|
||||||
assert.Equal(t, n2Record.Dirty, n2.Dirty, "n2 dirty mismatch")
|
assert.Equal(t, n2Record.Dirty, n2.Dirty, "n2 dirty mismatch")
|
||||||
}
|
}
|
||||||
|
|
@ -540,8 +506,7 @@ func TestBookInsert(t *testing.T) {
|
||||||
for idx, tc := range testCases {
|
for idx, tc := range testCases {
|
||||||
func() {
|
func() {
|
||||||
// Setup
|
// Setup
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
b := Book{
|
b := Book{
|
||||||
UUID: tc.uuid,
|
UUID: tc.uuid,
|
||||||
|
|
@ -555,12 +520,12 @@ func TestBookInsert(t *testing.T) {
|
||||||
|
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := b.Insert(tx); err != nil {
|
if err := b.Insert(tx); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
@ -621,8 +586,7 @@ func TestBookUpdate(t *testing.T) {
|
||||||
for idx, tc := range testCases {
|
for idx, tc := range testCases {
|
||||||
func() {
|
func() {
|
||||||
// Setup
|
// Setup
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
b1 := Book{
|
b1 := Book{
|
||||||
UUID: "b1-uuid",
|
UUID: "b1-uuid",
|
||||||
|
|
@ -645,7 +609,7 @@ func TestBookUpdate(t *testing.T) {
|
||||||
// execute
|
// execute
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
b1.Label = tc.newLabel
|
b1.Label = tc.newLabel
|
||||||
|
|
@ -655,7 +619,7 @@ func TestBookUpdate(t *testing.T) {
|
||||||
|
|
||||||
if err := b1.Update(tx); err != nil {
|
if err := b1.Update(tx); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
@ -700,8 +664,7 @@ func TestBookUpdateUUID(t *testing.T) {
|
||||||
t.Run(fmt.Sprintf("testCase%d", idx), func(t *testing.T) {
|
t.Run(fmt.Sprintf("testCase%d", idx), func(t *testing.T) {
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
b1 := Book{
|
b1 := Book{
|
||||||
UUID: "b1-uuid",
|
UUID: "b1-uuid",
|
||||||
|
|
@ -724,11 +687,11 @@ func TestBookUpdateUUID(t *testing.T) {
|
||||||
// execute
|
// execute
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||||
}
|
}
|
||||||
if err := b1.UpdateUUID(tx, tc.newUUID); err != nil {
|
if err := b1.UpdateUUID(tx, tc.newUUID); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
@ -751,8 +714,7 @@ func TestBookUpdateUUID(t *testing.T) {
|
||||||
|
|
||||||
func TestBookExpunge(t *testing.T) {
|
func TestBookExpunge(t *testing.T) {
|
||||||
// Setup
|
// Setup
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
b1 := Book{
|
b1 := Book{
|
||||||
UUID: "b1-uuid",
|
UUID: "b1-uuid",
|
||||||
|
|
@ -775,12 +737,12 @@ func TestBookExpunge(t *testing.T) {
|
||||||
// execute
|
// execute
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := b1.Expunge(tx); err != nil {
|
if err := b1.Expunge(tx); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
@ -806,8 +768,7 @@ func TestBookExpunge(t *testing.T) {
|
||||||
// TestNoteFTS tests that note full text search indices stay in sync with the notes after insert, update and delete
|
// TestNoteFTS tests that note full text search indices stay in sync with the notes after insert, update and delete
|
||||||
func TestNoteFTS(t *testing.T) {
|
func TestNoteFTS(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
// execute - insert
|
// execute - insert
|
||||||
n := Note{
|
n := Note{
|
||||||
|
|
@ -817,19 +778,18 @@ func TestNoteFTS(t *testing.T) {
|
||||||
AddedOn: 1542058875,
|
AddedOn: 1542058875,
|
||||||
EditedOn: 0,
|
EditedOn: 0,
|
||||||
USN: 0,
|
USN: 0,
|
||||||
Public: false,
|
|
||||||
Deleted: false,
|
Deleted: false,
|
||||||
Dirty: false,
|
Dirty: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := n.Insert(tx); err != nil {
|
if err := n.Insert(tx); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, "inserting").Error())
|
t.Fatal(errors.Wrap(err, "inserting").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
@ -847,13 +807,13 @@ func TestNoteFTS(t *testing.T) {
|
||||||
// execute - update
|
// execute - update
|
||||||
tx, err = db.Begin()
|
tx, err = db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
n.Body = "baz quz"
|
n.Body = "baz quz"
|
||||||
if err := n.Update(tx); err != nil {
|
if err := n.Update(tx); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, "updating").Error())
|
t.Fatal(errors.Wrap(err, "updating").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
@ -872,12 +832,12 @@ func TestNoteFTS(t *testing.T) {
|
||||||
// execute - delete
|
// execute - delete
|
||||||
tx, err = db.Begin()
|
tx, err = db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := n.Expunge(tx); err != nil {
|
if err := n.Expunge(tx); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, "expunging").Error())
|
t.Fatal(errors.Wrap(err, "expunging").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package database
|
package database
|
||||||
|
|
@ -170,7 +167,6 @@ func GetActiveNote(db *DB, rowid int) (Note, error) {
|
||||||
added_on,
|
added_on,
|
||||||
edited_on,
|
edited_on,
|
||||||
usn,
|
usn,
|
||||||
public,
|
|
||||||
deleted,
|
deleted,
|
||||||
dirty
|
dirty
|
||||||
FROM notes WHERE rowid = ? AND deleted = false;`, rowid).Scan(
|
FROM notes WHERE rowid = ? AND deleted = false;`, rowid).Scan(
|
||||||
|
|
@ -181,7 +177,6 @@ func GetActiveNote(db *DB, rowid int) (Note, error) {
|
||||||
&ret.AddedOn,
|
&ret.AddedOn,
|
||||||
&ret.EditedOn,
|
&ret.EditedOn,
|
||||||
&ret.USN,
|
&ret.USN,
|
||||||
&ret.Public,
|
|
||||||
&ret.Deleted,
|
&ret.Deleted,
|
||||||
&ret.Dirty,
|
&ret.Dirty,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package database
|
package database
|
||||||
|
|
@ -47,18 +44,17 @@ func TestInsertSystem(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(fmt.Sprintf("insert %s %s", tc.key, tc.val), func(t *testing.T) {
|
t.Run(fmt.Sprintf("insert %s %s", tc.key, tc.val), func(t *testing.T) {
|
||||||
// Setup
|
// Setup
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
// execute
|
// execute
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := InsertSystem(tx, tc.key, tc.val); err != nil {
|
if err := InsertSystem(tx, tc.key, tc.val); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, "executing for test case").Error())
|
t.Fatal(errors.Wrap(err, "executing for test case").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
@ -95,8 +91,7 @@ func TestUpsertSystem(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(fmt.Sprintf("insert %s %s", tc.key, tc.val), func(t *testing.T) {
|
t.Run(fmt.Sprintf("insert %s %s", tc.key, tc.val), func(t *testing.T) {
|
||||||
// Setup
|
// Setup
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "baz", "quz")
|
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "baz", "quz")
|
||||||
|
|
||||||
|
|
@ -106,12 +101,12 @@ func TestUpsertSystem(t *testing.T) {
|
||||||
// execute
|
// execute
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := UpsertSystem(tx, tc.key, tc.val); err != nil {
|
if err := UpsertSystem(tx, tc.key, tc.val); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, "executing for test case").Error())
|
t.Fatal(errors.Wrap(err, "executing for test case").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
@ -134,20 +129,19 @@ func TestUpsertSystem(t *testing.T) {
|
||||||
func TestGetSystem(t *testing.T) {
|
func TestGetSystem(t *testing.T) {
|
||||||
t.Run(fmt.Sprintf("get string value"), func(t *testing.T) {
|
t.Run(fmt.Sprintf("get string value"), func(t *testing.T) {
|
||||||
// Setup
|
// Setup
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
// execute
|
// execute
|
||||||
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "foo", "bar")
|
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "foo", "bar")
|
||||||
|
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||||
}
|
}
|
||||||
var dest string
|
var dest string
|
||||||
if err := GetSystem(tx, "foo", &dest); err != nil {
|
if err := GetSystem(tx, "foo", &dest); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, "executing for test case").Error())
|
t.Fatal(errors.Wrap(err, "executing for test case").Error())
|
||||||
}
|
}
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
||||||
|
|
@ -157,20 +151,19 @@ func TestGetSystem(t *testing.T) {
|
||||||
|
|
||||||
t.Run(fmt.Sprintf("get int64 value"), func(t *testing.T) {
|
t.Run(fmt.Sprintf("get int64 value"), func(t *testing.T) {
|
||||||
// Setup
|
// Setup
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
// execute
|
// execute
|
||||||
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "foo", 1234)
|
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "foo", 1234)
|
||||||
|
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||||
}
|
}
|
||||||
var dest int64
|
var dest int64
|
||||||
if err := GetSystem(tx, "foo", &dest); err != nil {
|
if err := GetSystem(tx, "foo", &dest); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, "executing for test case").Error())
|
t.Fatal(errors.Wrap(err, "executing for test case").Error())
|
||||||
}
|
}
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
||||||
|
|
@ -198,8 +191,7 @@ func TestUpdateSystem(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(fmt.Sprintf("update %s %s", tc.key, tc.val), func(t *testing.T) {
|
t.Run(fmt.Sprintf("update %s %s", tc.key, tc.val), func(t *testing.T) {
|
||||||
// Setup
|
// Setup
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "foo", "fuz")
|
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "foo", "fuz")
|
||||||
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "baz", "quz")
|
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "baz", "quz")
|
||||||
|
|
@ -210,12 +202,12 @@ func TestUpdateSystem(t *testing.T) {
|
||||||
// execute
|
// execute
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := UpdateSystem(tx, tc.key, tc.val); err != nil {
|
if err := UpdateSystem(tx, tc.key, tc.val); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
t.Fatalf(errors.Wrap(err, "executing for test case").Error())
|
t.Fatal(errors.Wrap(err, "executing for test case").Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
@ -238,11 +230,10 @@ func TestUpdateSystem(t *testing.T) {
|
||||||
func TestGetActiveNote(t *testing.T) {
|
func TestGetActiveNote(t *testing.T) {
|
||||||
t.Run("not deleted", func(t *testing.T) {
|
t.Run("not deleted", func(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
n1UUID := "n1-uuid"
|
n1UUID := "n1-uuid"
|
||||||
MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n1UUID, "b1-uuid", "n1 content", 1542058875, 1542058876, 1, true, false, true)
|
MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n1UUID, "b1-uuid", "n1 content", 1542058875, 1542058876, 1, false, true)
|
||||||
|
|
||||||
var n1RowID int
|
var n1RowID int
|
||||||
MustScan(t, "getting rowid", db.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", n1UUID), &n1RowID)
|
MustScan(t, "getting rowid", db.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", n1UUID), &n1RowID)
|
||||||
|
|
@ -261,18 +252,16 @@ func TestGetActiveNote(t *testing.T) {
|
||||||
assert.Equal(t, got.AddedOn, int64(1542058875), "AddedOn mismatch")
|
assert.Equal(t, got.AddedOn, int64(1542058875), "AddedOn mismatch")
|
||||||
assert.Equal(t, got.EditedOn, int64(1542058876), "EditedOn mismatch")
|
assert.Equal(t, got.EditedOn, int64(1542058876), "EditedOn mismatch")
|
||||||
assert.Equal(t, got.USN, 1, "USN mismatch")
|
assert.Equal(t, got.USN, 1, "USN mismatch")
|
||||||
assert.Equal(t, got.Public, true, "Public mismatch")
|
|
||||||
assert.Equal(t, got.Deleted, false, "Deleted mismatch")
|
assert.Equal(t, got.Deleted, false, "Deleted mismatch")
|
||||||
assert.Equal(t, got.Dirty, true, "Dirty mismatch")
|
assert.Equal(t, got.Dirty, true, "Dirty mismatch")
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("deleted", func(t *testing.T) {
|
t.Run("deleted", func(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
n1UUID := "n1-uuid"
|
n1UUID := "n1-uuid"
|
||||||
MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n1UUID, "b1-uuid", "n1 content", 1542058875, 1542058876, 1, true, true, true)
|
MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n1UUID, "b1-uuid", "n1 content", 1542058875, 1542058876, 1, true, true)
|
||||||
|
|
||||||
var n1RowID int
|
var n1RowID int
|
||||||
MustScan(t, "getting rowid", db.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", n1UUID), &n1RowID)
|
MustScan(t, "getting rowid", db.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", n1UUID), &n1RowID)
|
||||||
|
|
@ -292,11 +281,10 @@ func TestGetActiveNote(t *testing.T) {
|
||||||
|
|
||||||
func TestUpdateNoteContent(t *testing.T) {
|
func TestUpdateNoteContent(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
uuid := "n1-uuid"
|
uuid := "n1-uuid"
|
||||||
MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", uuid, "b1-uuid", "n1 content", 1542058875, 0, 1, false, false, false)
|
MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", uuid, "b1-uuid", "n1 content", 1542058875, 0, 1, false, false)
|
||||||
|
|
||||||
var rowid int
|
var rowid int
|
||||||
MustScan(t, "getting rowid", db.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", uuid), &rowid)
|
MustScan(t, "getting rowid", db.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", uuid), &rowid)
|
||||||
|
|
@ -324,8 +312,7 @@ func TestUpdateNoteContent(t *testing.T) {
|
||||||
|
|
||||||
func TestUpdateNoteBook(t *testing.T) {
|
func TestUpdateNoteBook(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
b1UUID := "b1-uuid"
|
b1UUID := "b1-uuid"
|
||||||
b2UUID := "b2-uuid"
|
b2UUID := "b2-uuid"
|
||||||
|
|
@ -333,7 +320,7 @@ func TestUpdateNoteBook(t *testing.T) {
|
||||||
MustExec(t, "inserting b2", db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", b2UUID, "b2-label", 9, false, false)
|
MustExec(t, "inserting b2", db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", b2UUID, "b2-label", 9, false, false)
|
||||||
|
|
||||||
uuid := "n1-uuid"
|
uuid := "n1-uuid"
|
||||||
MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", uuid, b1UUID, "n1 content", 1542058875, 0, 1, false, false, false)
|
MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", uuid, b1UUID, "n1 content", 1542058875, 0, 1, false, false)
|
||||||
|
|
||||||
var rowid int
|
var rowid int
|
||||||
MustScan(t, "getting rowid", db.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", uuid), &rowid)
|
MustScan(t, "getting rowid", db.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", uuid), &rowid)
|
||||||
|
|
@ -361,8 +348,7 @@ func TestUpdateNoteBook(t *testing.T) {
|
||||||
|
|
||||||
func TestUpdateBookName(t *testing.T) {
|
func TestUpdateBookName(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := InitTestMemoryDB(t)
|
||||||
defer TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
b1UUID := "b1-uuid"
|
b1UUID := "b1-uuid"
|
||||||
MustExec(t, "inserting b1", db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", b1UUID, "b1-label", 8, false, false)
|
MustExec(t, "inserting b1", db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", b1UUID, "b1-label", 8, false, false)
|
||||||
|
|
|
||||||
40
pkg/cli/database/schema.sql
Normal file
40
pkg/cli/database/schema.sql
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
-- This is the final state of the CLI database after all migrations.
|
||||||
|
-- Auto-generated by generate-schema.go. Do not edit manually.
|
||||||
|
CREATE TABLE books
|
||||||
|
(
|
||||||
|
uuid text PRIMARY KEY,
|
||||||
|
label text NOT NULL
|
||||||
|
, dirty bool DEFAULT false, usn int DEFAULT 0 NOT NULL, deleted bool DEFAULT false);
|
||||||
|
CREATE TABLE system
|
||||||
|
(
|
||||||
|
key string NOT NULL,
|
||||||
|
value text NOT NULL
|
||||||
|
);
|
||||||
|
CREATE UNIQUE INDEX idx_books_label ON books(label);
|
||||||
|
CREATE UNIQUE INDEX idx_books_uuid ON books(uuid);
|
||||||
|
CREATE TABLE "notes"
|
||||||
|
(
|
||||||
|
uuid text NOT NULL,
|
||||||
|
book_uuid text NOT NULL,
|
||||||
|
body text NOT NULL,
|
||||||
|
added_on integer NOT NULL,
|
||||||
|
edited_on integer DEFAULT 0,
|
||||||
|
dirty bool DEFAULT false,
|
||||||
|
usn int DEFAULT 0 NOT NULL,
|
||||||
|
deleted bool DEFAULT false
|
||||||
|
);
|
||||||
|
CREATE VIRTUAL TABLE note_fts USING fts5(content=notes, body, tokenize="porter unicode61 categories 'L* N* Co Ps Pe'");
|
||||||
|
CREATE TRIGGER notes_after_insert AFTER INSERT ON notes BEGIN
|
||||||
|
INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body);
|
||||||
|
END;
|
||||||
|
CREATE TRIGGER notes_after_delete AFTER DELETE ON notes BEGIN
|
||||||
|
INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body);
|
||||||
|
END;
|
||||||
|
CREATE TRIGGER notes_after_update AFTER UPDATE ON notes BEGIN
|
||||||
|
INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body);
|
||||||
|
INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body);
|
||||||
|
END;
|
||||||
|
|
||||||
|
-- Migration version data.
|
||||||
|
INSERT INTO system (key, value) VALUES ('schema', 14);
|
||||||
|
INSERT INTO system (key, value) VALUES ('remote_schema', 1);
|
||||||
163
pkg/cli/database/schema/main.go
Normal file
163
pkg/cli/database/schema/main.go
Normal file
|
|
@ -0,0 +1,163 @@
|
||||||
|
/* Copyright 2025 Dnote Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Command schema generates the CLI database schema.sql file.
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/dnote/dnote/pkg/cli/config"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/consts"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/database"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/infra"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/migrate"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
tmpDir, err := os.MkdirTemp("", "dnote-schema-gen-*")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
schemaPath := filepath.Join("pkg", "cli", "database", "schema.sql")
|
||||||
|
|
||||||
|
if err := run(tmpDir, schemaPath); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func run(tmpDir, outputPath string) error {
|
||||||
|
schema, err := generateSchema(tmpDir)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.WriteFile(outputPath, []byte(schema), 0644); err != nil {
|
||||||
|
return fmt.Errorf("writing schema file: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Schema generated successfully at %s\n", outputPath)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// generateSchema creates a fresh database, runs all migrations, and extracts the schema
|
||||||
|
func generateSchema(tmpDir string) (string, error) {
|
||||||
|
// Create dnote directory structure in temp dir
|
||||||
|
dnoteDir := filepath.Join(tmpDir, "dnote")
|
||||||
|
if err := os.MkdirAll(dnoteDir, 0755); err != nil {
|
||||||
|
return "", fmt.Errorf("creating dnote dir: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use a file-based database
|
||||||
|
dbPath := filepath.Join(tmpDir, "schema.db")
|
||||||
|
|
||||||
|
// Create context
|
||||||
|
ctx := context.DnoteCtx{
|
||||||
|
Paths: context.Paths{
|
||||||
|
Home: tmpDir,
|
||||||
|
Config: tmpDir,
|
||||||
|
Data: tmpDir,
|
||||||
|
Cache: tmpDir,
|
||||||
|
},
|
||||||
|
Version: "schema-gen",
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open database
|
||||||
|
db, err := database.Open(dbPath)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("opening database: %w", err)
|
||||||
|
}
|
||||||
|
defer db.Close()
|
||||||
|
ctx.DB = db
|
||||||
|
|
||||||
|
// Initialize database with base tables
|
||||||
|
if err := infra.InitDB(ctx); err != nil {
|
||||||
|
return "", fmt.Errorf("initializing database: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize system data
|
||||||
|
if err := infra.InitSystem(ctx); err != nil {
|
||||||
|
return "", fmt.Errorf("initializing system: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create minimal config file
|
||||||
|
if err := config.Write(ctx, config.Config{}); err != nil {
|
||||||
|
return "", fmt.Errorf("writing initial config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run all local migrations
|
||||||
|
if err := migrate.Run(ctx, migrate.LocalSequence, migrate.LocalMode); err != nil {
|
||||||
|
return "", fmt.Errorf("running migrations: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract schema before closing database
|
||||||
|
schema, err := extractSchema(db)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("extracting schema: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add INSERT statements for migration versions.
|
||||||
|
systemData := "\n-- Migration version data.\n"
|
||||||
|
systemData += fmt.Sprintf("INSERT INTO system (key, value) VALUES ('%s', %d);\n", consts.SystemSchema, len(migrate.LocalSequence))
|
||||||
|
systemData += fmt.Sprintf("INSERT INTO system (key, value) VALUES ('%s', %d);\n", consts.SystemRemoteSchema, len(migrate.RemoteSequence))
|
||||||
|
|
||||||
|
return schema + systemData, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// extractSchema extracts the complete schema by querying sqlite_master
|
||||||
|
func extractSchema(db *database.DB) (string, error) {
|
||||||
|
// Query sqlite_master for all schema objects, excluding FTS shadow tables
|
||||||
|
// FTS shadow tables are internal tables automatically created by FTS virtual tables
|
||||||
|
rows, err := db.Conn.Query(`SELECT sql FROM sqlite_master
|
||||||
|
WHERE sql IS NOT NULL
|
||||||
|
AND name NOT LIKE 'sqlite_%'
|
||||||
|
AND (type != 'table'
|
||||||
|
OR (type = 'table' AND name NOT IN (
|
||||||
|
SELECT m1.name FROM sqlite_master m1
|
||||||
|
JOIN sqlite_master m2 ON m1.name LIKE m2.name || '_%'
|
||||||
|
WHERE m2.type = 'table' AND m2.sql LIKE '%VIRTUAL TABLE%'
|
||||||
|
)))`)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("querying sqlite_master: %w", err)
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
var schemas []string
|
||||||
|
for rows.Next() {
|
||||||
|
var sql string
|
||||||
|
if err := rows.Scan(&sql); err != nil {
|
||||||
|
return "", fmt.Errorf("scanning row: %w", err)
|
||||||
|
}
|
||||||
|
schemas = append(schemas, sql)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return "", fmt.Errorf("iterating rows: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add autogenerated header comment
|
||||||
|
header := `-- This is the final state of the CLI database after all migrations.
|
||||||
|
-- Auto-generated by generate-schema.go. Do not edit manually.
|
||||||
|
`
|
||||||
|
return header + strings.Join(schemas, ";\n") + ";\n", nil
|
||||||
|
}
|
||||||
81
pkg/cli/database/schema/main_test.go
Normal file
81
pkg/cli/database/schema/main_test.go
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
/* Copyright 2025 Dnote Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/dnote/dnote/pkg/assert"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/consts"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRun(t *testing.T) {
|
||||||
|
tmpDir := t.TempDir()
|
||||||
|
outputPath := filepath.Join(tmpDir, "schema.sql")
|
||||||
|
|
||||||
|
// Run the function
|
||||||
|
if err := run(tmpDir, outputPath); err != nil {
|
||||||
|
t.Fatalf("run() failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify schema.sql was created
|
||||||
|
content, err := os.ReadFile(outputPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("reading schema.sql: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
schema := string(content)
|
||||||
|
|
||||||
|
// Verify it has the header
|
||||||
|
assert.Equal(t, strings.HasPrefix(schema, "-- This is the final state"), true, "schema.sql should have header comment")
|
||||||
|
|
||||||
|
// Verify schema contains expected tables
|
||||||
|
expectedTables := []string{
|
||||||
|
"CREATE TABLE books",
|
||||||
|
"CREATE TABLE system",
|
||||||
|
"CREATE TABLE \"notes\"",
|
||||||
|
"CREATE VIRTUAL TABLE note_fts",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, expected := range expectedTables {
|
||||||
|
assert.Equal(t, strings.Contains(schema, expected), true, fmt.Sprintf("schema should contain %s", expected))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify schema contains triggers
|
||||||
|
expectedTriggers := []string{
|
||||||
|
"CREATE TRIGGER notes_after_insert",
|
||||||
|
"CREATE TRIGGER notes_after_delete",
|
||||||
|
"CREATE TRIGGER notes_after_update",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, expected := range expectedTriggers {
|
||||||
|
assert.Equal(t, strings.Contains(schema, expected), true, fmt.Sprintf("schema should contain %s", expected))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify schema does not contain sqlite internal tables
|
||||||
|
assert.Equal(t, strings.Contains(schema, "sqlite_sequence"), false, "schema should not contain sqlite_sequence")
|
||||||
|
|
||||||
|
// Verify system key-value pairs for schema versions are present
|
||||||
|
expectedSchemaKey := fmt.Sprintf("INSERT INTO system (key, value) VALUES ('%s',", consts.SystemSchema)
|
||||||
|
assert.Equal(t, strings.Contains(schema, expectedSchemaKey), true, "schema should contain schema version INSERT statement")
|
||||||
|
|
||||||
|
expectedRemoteSchemaKey := fmt.Sprintf("INSERT INTO system (key, value) VALUES ('%s',", consts.SystemRemoteSchema)
|
||||||
|
assert.Equal(t, strings.Contains(schema, expectedRemoteSchemaKey), true, "schema should contain remote_schema version INSERT statement")
|
||||||
|
}
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package database
|
package database
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,24 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package database
|
package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -30,56 +27,13 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultSchemaSQL = `CREATE TABLE books
|
//go:embed schema.sql
|
||||||
(
|
var defaultSchemaSQL string
|
||||||
uuid text PRIMARY KEY,
|
|
||||||
label text NOT NULL
|
// GetDefaultSchemaSQL returns the default schema SQL for tests
|
||||||
, dirty bool DEFAULT false, usn int DEFAULT 0 NOT NULL, deleted bool DEFAULT false);
|
func GetDefaultSchemaSQL() string {
|
||||||
CREATE TABLE system
|
return defaultSchemaSQL
|
||||||
(
|
}
|
||||||
key string NOT NULL,
|
|
||||||
value text NOT NULL
|
|
||||||
);
|
|
||||||
CREATE UNIQUE INDEX idx_books_label ON books(label);
|
|
||||||
CREATE UNIQUE INDEX idx_books_uuid ON books(uuid);
|
|
||||||
CREATE TABLE IF NOT EXISTS "notes"
|
|
||||||
(
|
|
||||||
uuid text NOT NULL,
|
|
||||||
book_uuid text NOT NULL,
|
|
||||||
body text NOT NULL,
|
|
||||||
added_on integer NOT NULL,
|
|
||||||
edited_on integer DEFAULT 0,
|
|
||||||
public bool DEFAULT false,
|
|
||||||
dirty bool DEFAULT false,
|
|
||||||
usn int DEFAULT 0 NOT NULL,
|
|
||||||
deleted bool DEFAULT false
|
|
||||||
);
|
|
||||||
CREATE VIRTUAL TABLE note_fts USING fts5(content=notes, body, tokenize="porter unicode61 categories 'L* N* Co Ps Pe'")
|
|
||||||
/* note_fts(body) */;
|
|
||||||
CREATE TABLE IF NOT EXISTS 'note_fts_data'(id INTEGER PRIMARY KEY, block BLOB);
|
|
||||||
CREATE TABLE IF NOT EXISTS 'note_fts_idx'(segid, term, pgno, PRIMARY KEY(segid, term)) WITHOUT ROWID;
|
|
||||||
CREATE TABLE IF NOT EXISTS 'note_fts_docsize'(id INTEGER PRIMARY KEY, sz BLOB);
|
|
||||||
CREATE TABLE IF NOT EXISTS 'note_fts_config'(k PRIMARY KEY, v) WITHOUT ROWID;
|
|
||||||
CREATE TRIGGER notes_after_insert AFTER INSERT ON notes BEGIN
|
|
||||||
INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body);
|
|
||||||
END;
|
|
||||||
CREATE TRIGGER notes_after_delete AFTER DELETE ON notes BEGIN
|
|
||||||
INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body);
|
|
||||||
END;
|
|
||||||
CREATE TRIGGER notes_after_update AFTER UPDATE ON notes BEGIN
|
|
||||||
INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body);
|
|
||||||
INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body);
|
|
||||||
END;
|
|
||||||
CREATE TABLE actions
|
|
||||||
(
|
|
||||||
uuid text PRIMARY KEY,
|
|
||||||
schema integer NOT NULL,
|
|
||||||
type text NOT NULL,
|
|
||||||
data text NOT NULL,
|
|
||||||
timestamp integer NOT NULL
|
|
||||||
);
|
|
||||||
CREATE UNIQUE INDEX idx_notes_uuid ON notes(uuid);
|
|
||||||
CREATE INDEX idx_notes_book_uuid ON notes(book_uuid);`
|
|
||||||
|
|
||||||
// MustScan scans the given row and fails a test in case of any errors
|
// MustScan scans the given row and fails a test in case of any errors
|
||||||
func MustScan(t *testing.T, message string, row *sql.Row, args ...interface{}) {
|
func MustScan(t *testing.T, message string, row *sql.Row, args ...interface{}) {
|
||||||
|
|
@ -99,29 +53,48 @@ func MustExec(t *testing.T, message string, db *DB, query string, args ...interf
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestDBOptions contains options for test database
|
// InitTestMemoryDB initializes an in-memory test database with the default schema.
|
||||||
type TestDBOptions struct {
|
func InitTestMemoryDB(t *testing.T) *DB {
|
||||||
SchemaSQLPath string
|
return InitTestMemoryDBRaw(t, "")
|
||||||
SkipMigration bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitTestDB initializes a test database and opens connection to it
|
// InitTestFileDB initializes a file-based test database with the default schema.
|
||||||
func InitTestDB(t *testing.T, dbPath string, options *TestDBOptions) *DB {
|
func InitTestFileDB(t *testing.T) (*DB, string) {
|
||||||
|
uuid := mustGenerateTestUUID(t)
|
||||||
|
dbPath := filepath.Join(t.TempDir(), fmt.Sprintf("dnote-%s.db", uuid))
|
||||||
|
db := InitTestFileDBRaw(t, dbPath)
|
||||||
|
return db, dbPath
|
||||||
|
}
|
||||||
|
|
||||||
|
// InitTestFileDBRaw initializes a file-based test database at the specified path with the default schema.
|
||||||
|
func InitTestFileDBRaw(t *testing.T, dbPath string) *DB {
|
||||||
db, err := Open(dbPath)
|
db, err := Open(dbPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(errors.Wrap(err, "opening database connection"))
|
t.Fatal(errors.Wrap(err, "opening database"))
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, _ := filepath.Split(dbPath)
|
if _, err := db.Exec(defaultSchemaSQL); err != nil {
|
||||||
err = os.MkdirAll(dir, 0777)
|
t.Fatal(errors.Wrap(err, "running schema sql"))
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Cleanup(func() { db.Close() })
|
||||||
|
return db
|
||||||
|
}
|
||||||
|
|
||||||
|
// InitTestMemoryDBRaw initializes an in-memory test database without marking migrations complete.
|
||||||
|
// If schemaPath is empty, uses the default schema. Used for migration testing.
|
||||||
|
func InitTestMemoryDBRaw(t *testing.T, schemaPath string) *DB {
|
||||||
|
uuid := mustGenerateTestUUID(t)
|
||||||
|
dbName := fmt.Sprintf("file:%s?mode=memory&cache=shared", uuid)
|
||||||
|
|
||||||
|
db, err := Open(dbName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(errors.Wrap(err, "creating the directory for test database file"))
|
t.Fatal(errors.Wrap(err, "opening in-memory database"))
|
||||||
}
|
}
|
||||||
|
|
||||||
var schemaSQL string
|
var schemaSQL string
|
||||||
if options != nil && options.SchemaSQLPath != "" {
|
if schemaPath != "" {
|
||||||
b := utils.ReadFileAbs(options.SchemaSQLPath)
|
schemaSQL = string(utils.ReadFileAbs(schemaPath))
|
||||||
schemaSQL = string(b)
|
|
||||||
} else {
|
} else {
|
||||||
schemaSQL = defaultSchemaSQL
|
schemaSQL = defaultSchemaSQL
|
||||||
}
|
}
|
||||||
|
|
@ -130,24 +103,10 @@ func InitTestDB(t *testing.T, dbPath string, options *TestDBOptions) *DB {
|
||||||
t.Fatal(errors.Wrap(err, "running schema sql"))
|
t.Fatal(errors.Wrap(err, "running schema sql"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options == nil || !options.SkipMigration {
|
t.Cleanup(func() { db.Close() })
|
||||||
MarkMigrationComplete(t, db)
|
|
||||||
}
|
|
||||||
|
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
// TeardownTestDB closes the test database and removes the its file
|
|
||||||
func TeardownTestDB(t *testing.T, db *DB) {
|
|
||||||
if err := db.Close(); err != nil {
|
|
||||||
t.Fatal(errors.Wrap(err, "closing database"))
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := os.RemoveAll(db.Filepath); err != nil {
|
|
||||||
t.Fatal(errors.Wrap(err, "removing database file"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// OpenTestDB opens the database connection to a test database
|
// OpenTestDB opens the database connection to a test database
|
||||||
// without initializing any schema
|
// without initializing any schema
|
||||||
func OpenTestDB(t *testing.T, dnoteDir string) *DB {
|
func OpenTestDB(t *testing.T, dnoteDir string) *DB {
|
||||||
|
|
@ -160,12 +119,11 @@ func OpenTestDB(t *testing.T, dnoteDir string) *DB {
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarkMigrationComplete marks all migrations as complete in the database
|
// mustGenerateTestUUID generates a UUID for test databases and fails the test on error
|
||||||
func MarkMigrationComplete(t *testing.T, db *DB) {
|
func mustGenerateTestUUID(t *testing.T) string {
|
||||||
if _, err := db.Exec("INSERT INTO system (key, value) VALUES (? , ?);", consts.SystemSchema, 12); err != nil {
|
uuid, err := utils.GenerateUUID()
|
||||||
t.Fatal(errors.Wrap(err, "inserting schema"))
|
if err != nil {
|
||||||
}
|
t.Fatal(errors.Wrap(err, "generating UUID for test database"))
|
||||||
if _, err := db.Exec("INSERT INTO system (key, value) VALUES (? , ?);", consts.SystemRemoteSchema, 1); err != nil {
|
|
||||||
t.Fatal(errors.Wrap(err, "inserting remote schema"))
|
|
||||||
}
|
}
|
||||||
|
return uuid
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
|
||||||
*
|
|
||||||
* This file is part of Dnote.
|
|
||||||
*
|
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package dirs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
type envTestCase struct {
|
|
||||||
envKey string
|
|
||||||
envVal string
|
|
||||||
got *string
|
|
||||||
expected string
|
|
||||||
}
|
|
||||||
|
|
||||||
func testCustomDirs(t *testing.T, testCases []envTestCase) {
|
|
||||||
for _, tc := range testCases {
|
|
||||||
os.Setenv(tc.envKey, tc.envVal)
|
|
||||||
|
|
||||||
Reload()
|
|
||||||
|
|
||||||
assert.Equal(t, *tc.got, tc.expected, "result mismatch")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
|
||||||
*
|
|
||||||
* This file is part of Dnote.
|
|
||||||
*
|
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//go:build linux || darwin
|
|
||||||
|
|
||||||
|
|
||||||
package dirs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"path/filepath"
|
|
||||||
)
|
|
||||||
|
|
||||||
// The environment variable names for the XDG base directory specification
|
|
||||||
var (
|
|
||||||
envConfigHome = "XDG_CONFIG_HOME"
|
|
||||||
envDataHome = "XDG_DATA_HOME"
|
|
||||||
envCacheHome = "XDG_CACHE_HOME"
|
|
||||||
)
|
|
||||||
|
|
||||||
func initDirs() {
|
|
||||||
Home = getHomeDir()
|
|
||||||
ConfigHome = readPath(envConfigHome, getConfigHome(Home))
|
|
||||||
DataHome = readPath(envDataHome, getDataHome(Home))
|
|
||||||
CacheHome = readPath(envCacheHome, getCacheHome(Home))
|
|
||||||
}
|
|
||||||
|
|
||||||
func getConfigHome(homeDir string) string {
|
|
||||||
return filepath.Join(homeDir, ".config")
|
|
||||||
}
|
|
||||||
|
|
||||||
func getDataHome(homeDir string) string {
|
|
||||||
return filepath.Join(homeDir, ".local/share")
|
|
||||||
}
|
|
||||||
|
|
||||||
func getCacheHome(homeDir string) string {
|
|
||||||
return filepath.Join(homeDir, ".cache")
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
|
||||||
*
|
|
||||||
* This file is part of Dnote.
|
|
||||||
*
|
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
|
|
||||||
package dirs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"path/filepath"
|
|
||||||
)
|
|
||||||
|
|
||||||
func initDirs() {
|
|
||||||
Home = getHomeDir()
|
|
||||||
ConfigHome = filepath.Join(Home, ".dnote")
|
|
||||||
DataHome = filepath.Join(Home, ".dnote")
|
|
||||||
CacheHome = filepath.Join(Home, ".dnote")
|
|
||||||
}
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
|
||||||
*
|
|
||||||
* This file is part of Dnote.
|
|
||||||
*
|
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
|
|
||||||
package dirs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"path/filepath"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestDirs(t *testing.T) {
|
|
||||||
home := Home
|
|
||||||
assert.NotEqual(t, home, "", "home is empty")
|
|
||||||
|
|
||||||
configHome := filepath.Join(home, ".dnote")
|
|
||||||
dataHome := filepath.Join(home, ".dnote")
|
|
||||||
cacheHome := filepath.Join(home, ".dnote")
|
|
||||||
|
|
||||||
testCases := []struct {
|
|
||||||
got string
|
|
||||||
expected string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
got: ConfigHome,
|
|
||||||
expected: configHome,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
got: DataHome,
|
|
||||||
expected: dataHome,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
got: CacheHome,
|
|
||||||
expected: cacheHome,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tc := range testCases {
|
|
||||||
assert.Equal(t, tc.got, tc.expected, "result mismatch")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Package infra provides operations and definitions for the
|
// Package infra provides operations and definitions for the
|
||||||
|
|
@ -24,23 +21,28 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/dnote/dnote/pkg/cli/client"
|
||||||
"github.com/dnote/dnote/pkg/cli/config"
|
"github.com/dnote/dnote/pkg/cli/config"
|
||||||
"github.com/dnote/dnote/pkg/cli/consts"
|
"github.com/dnote/dnote/pkg/cli/consts"
|
||||||
"github.com/dnote/dnote/pkg/cli/context"
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
"github.com/dnote/dnote/pkg/cli/database"
|
"github.com/dnote/dnote/pkg/cli/database"
|
||||||
"github.com/dnote/dnote/pkg/cli/dirs"
|
|
||||||
"github.com/dnote/dnote/pkg/cli/log"
|
"github.com/dnote/dnote/pkg/cli/log"
|
||||||
"github.com/dnote/dnote/pkg/cli/migrate"
|
"github.com/dnote/dnote/pkg/cli/migrate"
|
||||||
"github.com/dnote/dnote/pkg/cli/utils"
|
"github.com/dnote/dnote/pkg/cli/utils"
|
||||||
"github.com/dnote/dnote/pkg/clock"
|
"github.com/dnote/dnote/pkg/clock"
|
||||||
|
"github.com/dnote/dnote/pkg/dirs"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// DefaultAPIEndpoint is the default API endpoint used when none is configured
|
||||||
|
DefaultAPIEndpoint = "http://localhost:3001/api"
|
||||||
|
)
|
||||||
|
|
||||||
// RunEFunc is a function type of dnote commands
|
// RunEFunc is a function type of dnote commands
|
||||||
type RunEFunc func(*cobra.Command, []string) error
|
type RunEFunc func(*cobra.Command, []string) error
|
||||||
|
|
||||||
|
|
@ -52,13 +54,18 @@ func checkLegacyDBPath() (string, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf(errors.Wrapf(err, "checking legacy dnote directory at %s", legacyDnoteDir).Error())
|
log.Error(errors.Wrapf(err, "checking legacy dnote directory at %s", legacyDnoteDir).Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDBPath(paths context.Paths) string {
|
func getDBPath(paths context.Paths, customPath string) string {
|
||||||
|
// If custom path is provided, use it
|
||||||
|
if customPath != "" {
|
||||||
|
return customPath
|
||||||
|
}
|
||||||
|
|
||||||
legacyDnoteDir, ok := checkLegacyDBPath()
|
legacyDnoteDir, ok := checkLegacyDBPath()
|
||||||
if ok {
|
if ok {
|
||||||
return fmt.Sprintf("%s/%s", legacyDnoteDir, consts.DnoteDBFileName)
|
return fmt.Sprintf("%s/%s", legacyDnoteDir, consts.DnoteDBFileName)
|
||||||
|
|
@ -67,7 +74,10 @@ func getDBPath(paths context.Paths) string {
|
||||||
return fmt.Sprintf("%s/%s/%s", paths.Data, consts.DnoteDirName, consts.DnoteDBFileName)
|
return fmt.Sprintf("%s/%s/%s", paths.Data, consts.DnoteDirName, consts.DnoteDBFileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCtx(versionTag string) (context.DnoteCtx, error) {
|
// newBaseCtx creates a minimal context with paths and database connection.
|
||||||
|
// This base context is used for file and database initialization before
|
||||||
|
// being enriched with config values by setupCtx.
|
||||||
|
func newBaseCtx(versionTag, customDBPath string) (context.DnoteCtx, error) {
|
||||||
dnoteDir := getLegacyDnotePath(dirs.Home)
|
dnoteDir := getLegacyDnotePath(dirs.Home)
|
||||||
paths := context.Paths{
|
paths := context.Paths{
|
||||||
Home: dirs.Home,
|
Home: dirs.Home,
|
||||||
|
|
@ -77,7 +87,7 @@ func newCtx(versionTag string) (context.DnoteCtx, error) {
|
||||||
LegacyDnote: dnoteDir,
|
LegacyDnote: dnoteDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
dbPath := getDBPath(paths)
|
dbPath := getDBPath(paths, customDBPath)
|
||||||
|
|
||||||
db, err := database.Open(dbPath)
|
db, err := database.Open(dbPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -94,13 +104,14 @@ func newCtx(versionTag string) (context.DnoteCtx, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init initializes the Dnote environment and returns a new dnote context
|
// Init initializes the Dnote environment and returns a new dnote context
|
||||||
func Init(apiEndpoint, versionTag string) (*context.DnoteCtx, error) {
|
// apiEndpoint is used when creating a new config file (e.g., from ldflags during tests)
|
||||||
ctx, err := newCtx(versionTag)
|
func Init(versionTag, apiEndpoint, dbPath string) (*context.DnoteCtx, error) {
|
||||||
|
ctx, err := newBaseCtx(versionTag, dbPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "initializing a context")
|
return nil, errors.Wrap(err, "initializing a context")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := InitFiles(ctx, apiEndpoint); err != nil {
|
if err := initFiles(ctx, apiEndpoint); err != nil {
|
||||||
return nil, errors.Wrap(err, "initializing files")
|
return nil, errors.Wrap(err, "initializing files")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,18 +129,19 @@ func Init(apiEndpoint, versionTag string) (*context.DnoteCtx, error) {
|
||||||
return nil, errors.Wrap(err, "running migration")
|
return nil, errors.Wrap(err, "running migration")
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, err = SetupCtx(ctx)
|
ctx, err = setupCtx(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "setting up the context")
|
return nil, errors.Wrap(err, "setting up the context")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("Running with Dnote context: %+v\n", context.Redact(ctx))
|
log.Debug("context: %+v\n", context.Redact(ctx))
|
||||||
|
|
||||||
return &ctx, nil
|
return &ctx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetupCtx populates the context and returns a new context
|
// setupCtx enriches the base context with values from config file and database.
|
||||||
func SetupCtx(ctx context.DnoteCtx) (context.DnoteCtx, error) {
|
// This is called after files and database have been initialized.
|
||||||
|
func setupCtx(ctx context.DnoteCtx) (context.DnoteCtx, error) {
|
||||||
db := ctx.DB
|
db := ctx.DB
|
||||||
|
|
||||||
var sessionKey string
|
var sessionKey string
|
||||||
|
|
@ -150,14 +162,16 @@ func SetupCtx(ctx context.DnoteCtx) (context.DnoteCtx, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := context.DnoteCtx{
|
ret := context.DnoteCtx{
|
||||||
Paths: ctx.Paths,
|
Paths: ctx.Paths,
|
||||||
Version: ctx.Version,
|
Version: ctx.Version,
|
||||||
DB: ctx.DB,
|
DB: ctx.DB,
|
||||||
SessionKey: sessionKey,
|
SessionKey: sessionKey,
|
||||||
SessionKeyExpiry: sessionKeyExpiry,
|
SessionKeyExpiry: sessionKeyExpiry,
|
||||||
APIEndpoint: cf.APIEndpoint,
|
APIEndpoint: cf.APIEndpoint,
|
||||||
Editor: cf.Editor,
|
Editor: cf.Editor,
|
||||||
Clock: clock.New(),
|
Clock: clock.New(),
|
||||||
|
EnableUpgradeCheck: cf.EnableUpgradeCheck,
|
||||||
|
HTTPClient: client.NewRateLimitedHTTPClient(),
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
|
|
@ -273,7 +287,9 @@ func InitSystem(ctx context.DnoteCtx) error {
|
||||||
return errors.Wrapf(err, "initializing system config for %s", consts.SystemLastSyncAt)
|
return errors.Wrapf(err, "initializing system config for %s", consts.SystemLastSyncAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
if err := tx.Commit(); err != nil {
|
||||||
|
return errors.Wrap(err, "committing transaction")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -309,36 +325,6 @@ func getEditorCommand() string {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func initDir(path string) error {
|
|
||||||
ok, err := utils.FileExists(path)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Wrapf(err, "checking if dir exists at %s", path)
|
|
||||||
}
|
|
||||||
if ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := os.MkdirAll(path, 0755); err != nil {
|
|
||||||
return errors.Wrapf(err, "creating a directory at %s", path)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// initDnoteDir initializes missing directories that Dnote uses
|
|
||||||
func initDnoteDir(ctx context.DnoteCtx) error {
|
|
||||||
if err := initDir(filepath.Join(ctx.Paths.Config, consts.DnoteDirName)); err != nil {
|
|
||||||
return errors.Wrap(err, "initializing config dir")
|
|
||||||
}
|
|
||||||
if err := initDir(filepath.Join(ctx.Paths.Data, consts.DnoteDirName)); err != nil {
|
|
||||||
return errors.Wrap(err, "initializing data dir")
|
|
||||||
}
|
|
||||||
if err := initDir(filepath.Join(ctx.Paths.Cache, consts.DnoteDirName)); err != nil {
|
|
||||||
return errors.Wrap(err, "initializing cache dir")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// initConfigFile populates a new config file if it does not exist yet
|
// initConfigFile populates a new config file if it does not exist yet
|
||||||
func initConfigFile(ctx context.DnoteCtx, apiEndpoint string) error {
|
func initConfigFile(ctx context.DnoteCtx, apiEndpoint string) error {
|
||||||
|
|
@ -353,9 +339,16 @@ func initConfigFile(ctx context.DnoteCtx, apiEndpoint string) error {
|
||||||
|
|
||||||
editor := getEditorCommand()
|
editor := getEditorCommand()
|
||||||
|
|
||||||
|
// Use default API endpoint if none provided
|
||||||
|
endpoint := apiEndpoint
|
||||||
|
if endpoint == "" {
|
||||||
|
endpoint = DefaultAPIEndpoint
|
||||||
|
}
|
||||||
|
|
||||||
cf := config.Config{
|
cf := config.Config{
|
||||||
Editor: editor,
|
Editor: editor,
|
||||||
APIEndpoint: apiEndpoint,
|
APIEndpoint: endpoint,
|
||||||
|
EnableUpgradeCheck: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := config.Write(ctx, cf); err != nil {
|
if err := config.Write(ctx, cf); err != nil {
|
||||||
|
|
@ -365,9 +358,9 @@ func initConfigFile(ctx context.DnoteCtx, apiEndpoint string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitFiles creates, if necessary, the dnote directory and files inside
|
// initFiles creates, if necessary, the dnote directory and files inside
|
||||||
func InitFiles(ctx context.DnoteCtx, apiEndpoint string) error {
|
func initFiles(ctx context.DnoteCtx, apiEndpoint string) error {
|
||||||
if err := initDnoteDir(ctx); err != nil {
|
if err := context.InitDnoteDirs(ctx.Paths); err != nil {
|
||||||
return errors.Wrap(err, "creating the dnote dir")
|
return errors.Wrap(err, "creating the dnote dir")
|
||||||
}
|
}
|
||||||
if err := initConfigFile(ctx, apiEndpoint); err != nil {
|
if err := initConfigFile(ctx, apiEndpoint); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,35 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package infra
|
package infra
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/assert"
|
"github.com/dnote/dnote/pkg/assert"
|
||||||
|
"github.com/dnote/dnote/pkg/cli/config"
|
||||||
"github.com/dnote/dnote/pkg/cli/database"
|
"github.com/dnote/dnote/pkg/cli/database"
|
||||||
|
"github.com/dnote/dnote/pkg/dirs"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInitSystemKV(t *testing.T) {
|
func TestInitSystemKV(t *testing.T) {
|
||||||
// Setup
|
// Setup
|
||||||
db := database.InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := database.InitTestMemoryDB(t)
|
||||||
defer database.TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
var originalCount int
|
var originalCount int
|
||||||
database.MustScan(t, "counting system configs", db.QueryRow("SELECT count(*) FROM system"), &originalCount)
|
database.MustScan(t, "counting system configs", db.QueryRow("SELECT count(*) FROM system"), &originalCount)
|
||||||
|
|
@ -60,8 +60,7 @@ func TestInitSystemKV(t *testing.T) {
|
||||||
|
|
||||||
func TestInitSystemKV_existing(t *testing.T) {
|
func TestInitSystemKV_existing(t *testing.T) {
|
||||||
// Setup
|
// Setup
|
||||||
db := database.InitTestDB(t, "../tmp/dnote-test.db", nil)
|
db := database.InitTestMemoryDB(t)
|
||||||
defer database.TeardownTestDB(t, db)
|
|
||||||
|
|
||||||
database.MustExec(t, "inserting a system config", db, "INSERT INTO system (key, value) VALUES (?, ?)", "testKey", "testVal")
|
database.MustExec(t, "inserting a system config", db, "INSERT INTO system (key, value) VALUES (?, ?)", "testKey", "testVal")
|
||||||
|
|
||||||
|
|
@ -91,3 +90,37 @@ func TestInitSystemKV_existing(t *testing.T) {
|
||||||
db.QueryRow("SELECT value FROM system WHERE key = ?", "testKey"), &val)
|
db.QueryRow("SELECT value FROM system WHERE key = ?", "testKey"), &val)
|
||||||
assert.Equal(t, val, "testVal", "system value should not have been updated")
|
assert.Equal(t, val, "testVal", "system value should not have been updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestInit_APIEndpoint(t *testing.T) {
|
||||||
|
// Create a temporary directory for test
|
||||||
|
tmpDir, err := os.MkdirTemp("", "dnote-init-test-*")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "creating temp dir"))
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
// Set up environment to use our temp directory
|
||||||
|
t.Setenv("XDG_CONFIG_HOME", fmt.Sprintf("%s/config", tmpDir))
|
||||||
|
t.Setenv("XDG_DATA_HOME", fmt.Sprintf("%s/data", tmpDir))
|
||||||
|
t.Setenv("XDG_CACHE_HOME", fmt.Sprintf("%s/cache", tmpDir))
|
||||||
|
|
||||||
|
// Force dirs package to reload with new environment
|
||||||
|
dirs.Reload()
|
||||||
|
|
||||||
|
// Initialize - should create config with default apiEndpoint
|
||||||
|
ctx, err := Init("test-version", "", "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "initializing"))
|
||||||
|
}
|
||||||
|
defer ctx.DB.Close()
|
||||||
|
|
||||||
|
// Read the config that was created
|
||||||
|
cf, err := config.Read(*ctx)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "reading config"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Context should use the apiEndpoint from config
|
||||||
|
assert.Equal(t, ctx.APIEndpoint, DefaultAPIEndpoint, "context should use apiEndpoint from config")
|
||||||
|
assert.Equal(t, cf.APIEndpoint, DefaultAPIEndpoint, "context should use apiEndpoint from config")
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,30 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dnote/color"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/fatih/color"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
debugEnvName = "DNOTE_DEBUG"
|
||||||
|
debugEnvValue = "1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -81,7 +84,7 @@ func Error(msg string) {
|
||||||
|
|
||||||
// Errorf prints an error message with optional format verbs
|
// Errorf prints an error message with optional format verbs
|
||||||
func Errorf(msg string, v ...interface{}) {
|
func Errorf(msg string, v ...interface{}) {
|
||||||
fmt.Fprintf(color.Output, "%s%s %s", indent, ColorRed.Sprintf("⨯"), fmt.Sprintf(msg, v...))
|
fmt.Fprintf(color.Output, "%s%s %s", indent, ColorRed.Sprintf("%s", "⨯"), fmt.Sprintf(msg, v...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Printf prints an normal message
|
// Printf prints an normal message
|
||||||
|
|
@ -96,17 +99,29 @@ func Askf(msg string, masked bool, v ...interface{}) {
|
||||||
|
|
||||||
var symbol string
|
var symbol string
|
||||||
if masked {
|
if masked {
|
||||||
symbol = ColorGray.Sprintf(symbolChar)
|
symbol = ColorGray.Sprintf("%s", symbolChar)
|
||||||
} else {
|
} else {
|
||||||
symbol = ColorGreen.Sprintf(symbolChar)
|
symbol = ColorGreen.Sprintf("%s", symbolChar)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(color.Output, "%s%s %s: ", indent, symbol, fmt.Sprintf(msg, v...))
|
fmt.Fprintf(color.Output, "%s%s %s: ", indent, symbol, fmt.Sprintf(msg, v...))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isDebug returns true if debug mode is enabled
|
||||||
|
func isDebug() bool {
|
||||||
|
return os.Getenv(debugEnvName) == debugEnvValue
|
||||||
|
}
|
||||||
|
|
||||||
// Debug prints to the console if DNOTE_DEBUG is set
|
// Debug prints to the console if DNOTE_DEBUG is set
|
||||||
func Debug(msg string, v ...interface{}) {
|
func Debug(msg string, v ...interface{}) {
|
||||||
if os.Getenv("DNOTE_DEBUG") == "1" {
|
if isDebug() {
|
||||||
fmt.Fprintf(color.Output, "%s %s", ColorGray.Sprint("DEBUG:"), fmt.Sprintf(msg, v...))
|
fmt.Fprintf(color.Output, "%s %s", ColorGray.Sprint("DEBUG:"), fmt.Sprintf(msg, v...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DebugNewline prints a newline only in debug mode
|
||||||
|
func DebugNewline() {
|
||||||
|
if isDebug() {
|
||||||
|
fmt.Println()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,23 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/cli/infra"
|
"github.com/dnote/dnote/pkg/cli/infra"
|
||||||
"github.com/dnote/dnote/pkg/cli/log"
|
"github.com/dnote/dnote/pkg/cli/log"
|
||||||
|
|
@ -28,12 +26,10 @@ import (
|
||||||
|
|
||||||
// commands
|
// commands
|
||||||
"github.com/dnote/dnote/pkg/cli/cmd/add"
|
"github.com/dnote/dnote/pkg/cli/cmd/add"
|
||||||
"github.com/dnote/dnote/pkg/cli/cmd/cat"
|
|
||||||
"github.com/dnote/dnote/pkg/cli/cmd/edit"
|
"github.com/dnote/dnote/pkg/cli/cmd/edit"
|
||||||
"github.com/dnote/dnote/pkg/cli/cmd/find"
|
"github.com/dnote/dnote/pkg/cli/cmd/find"
|
||||||
"github.com/dnote/dnote/pkg/cli/cmd/login"
|
"github.com/dnote/dnote/pkg/cli/cmd/login"
|
||||||
"github.com/dnote/dnote/pkg/cli/cmd/logout"
|
"github.com/dnote/dnote/pkg/cli/cmd/logout"
|
||||||
"github.com/dnote/dnote/pkg/cli/cmd/ls"
|
|
||||||
"github.com/dnote/dnote/pkg/cli/cmd/remove"
|
"github.com/dnote/dnote/pkg/cli/cmd/remove"
|
||||||
"github.com/dnote/dnote/pkg/cli/cmd/root"
|
"github.com/dnote/dnote/pkg/cli/cmd/root"
|
||||||
"github.com/dnote/dnote/pkg/cli/cmd/sync"
|
"github.com/dnote/dnote/pkg/cli/cmd/sync"
|
||||||
|
|
@ -45,8 +41,32 @@ import (
|
||||||
var apiEndpoint string
|
var apiEndpoint string
|
||||||
var versionTag = "master"
|
var versionTag = "master"
|
||||||
|
|
||||||
|
// parseDBPath extracts --dbPath flag value from command line arguments
|
||||||
|
// regardless of where it appears (before or after subcommand).
|
||||||
|
// Returns empty string if not found.
|
||||||
|
func parseDBPath(args []string) string {
|
||||||
|
for i, arg := range args {
|
||||||
|
// Handle --dbPath=value
|
||||||
|
if strings.HasPrefix(arg, "--dbPath=") {
|
||||||
|
return strings.TrimPrefix(arg, "--dbPath=")
|
||||||
|
}
|
||||||
|
// Handle --dbPath value
|
||||||
|
if arg == "--dbPath" && i+1 < len(args) {
|
||||||
|
return args[i+1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ctx, err := infra.Init(apiEndpoint, versionTag)
|
// Parse flags early to get --dbPath before initializing database
|
||||||
|
// We need to manually parse --dbPath because it can appear after the subcommand
|
||||||
|
// (e.g., "dnote sync --full --dbPath=./custom.db") and root.ParseFlags only
|
||||||
|
// parses flags before the subcommand.
|
||||||
|
dbPath := parseDBPath(os.Args[1:])
|
||||||
|
|
||||||
|
// Initialize context - defaultAPIEndpoint is used when creating new config file
|
||||||
|
ctx, err := infra.Init(versionTag, apiEndpoint, dbPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(errors.Wrap(err, "initializing context"))
|
panic(errors.Wrap(err, "initializing context"))
|
||||||
}
|
}
|
||||||
|
|
@ -57,10 +77,8 @@ func main() {
|
||||||
root.Register(login.NewCmd(*ctx))
|
root.Register(login.NewCmd(*ctx))
|
||||||
root.Register(logout.NewCmd(*ctx))
|
root.Register(logout.NewCmd(*ctx))
|
||||||
root.Register(add.NewCmd(*ctx))
|
root.Register(add.NewCmd(*ctx))
|
||||||
root.Register(ls.NewCmd(*ctx))
|
|
||||||
root.Register(sync.NewCmd(*ctx))
|
root.Register(sync.NewCmd(*ctx))
|
||||||
root.Register(version.NewCmd(*ctx))
|
root.Register(version.NewCmd(*ctx))
|
||||||
root.Register(cat.NewCmd(*ctx))
|
|
||||||
root.Register(view.NewCmd(*ctx))
|
root.Register(view.NewCmd(*ctx))
|
||||||
root.Register(find.NewCmd(*ctx))
|
root.Register(find.NewCmd(*ctx))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
@ -23,6 +20,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/assert"
|
"github.com/dnote/dnote/pkg/assert"
|
||||||
|
|
@ -35,14 +33,17 @@ import (
|
||||||
|
|
||||||
var binaryName = "test-dnote"
|
var binaryName = "test-dnote"
|
||||||
|
|
||||||
var testDir = "./tmp/.dnote"
|
// setupTestEnv creates a unique test directory for parallel test execution
|
||||||
|
func setupTestEnv(t *testing.T) (string, testutils.RunDnoteCmdOptions) {
|
||||||
var opts = testutils.RunDnoteCmdOptions{
|
testDir := t.TempDir()
|
||||||
Env: []string{
|
opts := testutils.RunDnoteCmdOptions{
|
||||||
fmt.Sprintf("XDG_CONFIG_HOME=%s", testDir),
|
Env: []string{
|
||||||
fmt.Sprintf("XDG_DATA_HOME=%s", testDir),
|
fmt.Sprintf("XDG_CONFIG_HOME=%s", testDir),
|
||||||
fmt.Sprintf("XDG_CACHE_HOME=%s", testDir),
|
fmt.Sprintf("XDG_DATA_HOME=%s", testDir),
|
||||||
},
|
fmt.Sprintf("XDG_CACHE_HOME=%s", testDir),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return testDir, opts
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
|
@ -55,10 +56,11 @@ func TestMain(m *testing.M) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInit(t *testing.T) {
|
func TestInit(t *testing.T) {
|
||||||
|
testDir, opts := setupTestEnv(t)
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
// run an arbitrary command "view" due to https://github.com/spf13/cobra/issues/1056
|
// run an arbitrary command "view" due to https://github.com/spf13/cobra/issues/1056
|
||||||
testutils.RunDnoteCmd(t, opts, binaryName, "view")
|
testutils.RunDnoteCmd(t, opts, binaryName, "view")
|
||||||
defer testutils.RemoveDir(t, testDir)
|
|
||||||
|
|
||||||
db := database.OpenTestDB(t, testDir)
|
db := database.OpenTestDB(t, testDir)
|
||||||
|
|
||||||
|
|
@ -107,11 +109,11 @@ func TestInit(t *testing.T) {
|
||||||
|
|
||||||
func TestAddNote(t *testing.T) {
|
func TestAddNote(t *testing.T) {
|
||||||
t.Run("new book", func(t *testing.T) {
|
t.Run("new book", func(t *testing.T) {
|
||||||
|
testDir, opts := setupTestEnv(t)
|
||||||
|
|
||||||
// Set up and execute
|
// Set up and execute
|
||||||
testutils.RunDnoteCmd(t, opts, binaryName, "add", "js", "-c", "foo")
|
testutils.RunDnoteCmd(t, opts, binaryName, "add", "js", "-c", "foo")
|
||||||
testutils.WaitDnoteCmd(t, opts, testutils.UserContent, binaryName, "add", "js")
|
testutils.MustWaitDnoteCmd(t, opts, testutils.UserContent, binaryName, "add", "js")
|
||||||
|
|
||||||
defer testutils.RemoveDir(t, testDir)
|
|
||||||
|
|
||||||
db := database.OpenTestDB(t, testDir)
|
db := database.OpenTestDB(t, testDir)
|
||||||
|
|
||||||
|
|
@ -138,13 +140,14 @@ func TestAddNote(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("existing book", func(t *testing.T) {
|
t.Run("existing book", func(t *testing.T) {
|
||||||
|
_, opts := setupTestEnv(t)
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil)
|
db, dbPath := database.InitTestFileDB(t)
|
||||||
testutils.Setup3(t, db)
|
testutils.Setup3(t, db)
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
testutils.RunDnoteCmd(t, opts, binaryName, "add", "js", "-c", "foo")
|
testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "add", "js", "-c", "foo")
|
||||||
defer testutils.RemoveDir(t, testDir)
|
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
|
|
||||||
|
|
@ -179,13 +182,14 @@ func TestAddNote(t *testing.T) {
|
||||||
|
|
||||||
func TestEditNote(t *testing.T) {
|
func TestEditNote(t *testing.T) {
|
||||||
t.Run("content flag", func(t *testing.T) {
|
t.Run("content flag", func(t *testing.T) {
|
||||||
|
_, opts := setupTestEnv(t)
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil)
|
db, dbPath := database.InitTestFileDB(t)
|
||||||
testutils.Setup4(t, db)
|
testutils.Setup4(t, db)
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
testutils.RunDnoteCmd(t, opts, binaryName, "edit", "2", "-c", "foo bar")
|
testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "edit", "2", "-c", "foo bar")
|
||||||
defer testutils.RemoveDir(t, testDir)
|
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
var noteCount, bookCount int
|
var noteCount, bookCount int
|
||||||
|
|
@ -212,13 +216,14 @@ func TestEditNote(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("book flag", func(t *testing.T) {
|
t.Run("book flag", func(t *testing.T) {
|
||||||
|
_, opts := setupTestEnv(t)
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil)
|
db, dbPath := database.InitTestFileDB(t)
|
||||||
testutils.Setup5(t, db)
|
testutils.Setup5(t, db)
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
testutils.RunDnoteCmd(t, opts, binaryName, "edit", "2", "-b", "linux")
|
testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "edit", "2", "-b", "linux")
|
||||||
defer testutils.RemoveDir(t, testDir)
|
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
var noteCount, bookCount int
|
var noteCount, bookCount int
|
||||||
|
|
@ -246,13 +251,14 @@ func TestEditNote(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("book flag and content flag", func(t *testing.T) {
|
t.Run("book flag and content flag", func(t *testing.T) {
|
||||||
|
_, opts := setupTestEnv(t)
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil)
|
db, dbPath := database.InitTestFileDB(t)
|
||||||
testutils.Setup5(t, db)
|
testutils.Setup5(t, db)
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
testutils.RunDnoteCmd(t, opts, binaryName, "edit", "2", "-b", "linux", "-c", "n2 body updated")
|
testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "edit", "2", "-b", "linux", "-c", "n2 body updated")
|
||||||
defer testutils.RemoveDir(t, testDir)
|
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
var noteCount, bookCount int
|
var noteCount, bookCount int
|
||||||
|
|
@ -282,13 +288,14 @@ func TestEditNote(t *testing.T) {
|
||||||
|
|
||||||
func TestEditBook(t *testing.T) {
|
func TestEditBook(t *testing.T) {
|
||||||
t.Run("name flag", func(t *testing.T) {
|
t.Run("name flag", func(t *testing.T) {
|
||||||
|
_, opts := setupTestEnv(t)
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil)
|
db, dbPath := database.InitTestFileDB(t)
|
||||||
testutils.Setup1(t, db)
|
testutils.Setup1(t, db)
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
testutils.RunDnoteCmd(t, opts, binaryName, "edit", "js", "-n", "js-edited")
|
testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "edit", "js", "-n", "js-edited")
|
||||||
defer testutils.RemoveDir(t, testDir)
|
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
var noteCount, bookCount int
|
var noteCount, bookCount int
|
||||||
|
|
@ -341,17 +348,18 @@ func TestRemoveNote(t *testing.T) {
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(fmt.Sprintf("--yes=%t", tc.yesFlag), func(t *testing.T) {
|
t.Run(fmt.Sprintf("--yes=%t", tc.yesFlag), func(t *testing.T) {
|
||||||
|
_, opts := setupTestEnv(t)
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil)
|
db, dbPath := database.InitTestFileDB(t)
|
||||||
testutils.Setup2(t, db)
|
testutils.Setup2(t, db)
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
if tc.yesFlag {
|
if tc.yesFlag {
|
||||||
testutils.RunDnoteCmd(t, opts, binaryName, "remove", "-y", "1")
|
testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "remove", "-y", "1")
|
||||||
} else {
|
} else {
|
||||||
testutils.WaitDnoteCmd(t, opts, testutils.UserConfirm, binaryName, "remove", "1")
|
testutils.MustWaitDnoteCmd(t, opts, testutils.ConfirmRemoveNote, binaryName, "--dbPath", dbPath, "remove", "1")
|
||||||
}
|
}
|
||||||
defer testutils.RemoveDir(t, testDir)
|
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
var noteCount, bookCount, jsNoteCount, linuxNoteCount int
|
var noteCount, bookCount, jsNoteCount, linuxNoteCount int
|
||||||
|
|
@ -428,19 +436,19 @@ func TestRemoveBook(t *testing.T) {
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(fmt.Sprintf("--yes=%t", tc.yesFlag), func(t *testing.T) {
|
t.Run(fmt.Sprintf("--yes=%t", tc.yesFlag), func(t *testing.T) {
|
||||||
|
_, opts := setupTestEnv(t)
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil)
|
db, dbPath := database.InitTestFileDB(t)
|
||||||
testutils.Setup2(t, db)
|
testutils.Setup2(t, db)
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
if tc.yesFlag {
|
if tc.yesFlag {
|
||||||
testutils.RunDnoteCmd(t, opts, binaryName, "remove", "-y", "js")
|
testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "remove", "-y", "js")
|
||||||
} else {
|
} else {
|
||||||
testutils.WaitDnoteCmd(t, opts, testutils.UserConfirm, binaryName, "remove", "js")
|
testutils.MustWaitDnoteCmd(t, opts, testutils.ConfirmRemoveBook, binaryName, "--dbPath", dbPath, "remove", "js")
|
||||||
}
|
}
|
||||||
|
|
||||||
defer testutils.RemoveDir(t, testDir)
|
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
var noteCount, bookCount, jsNoteCount, linuxNoteCount int
|
var noteCount, bookCount, jsNoteCount, linuxNoteCount int
|
||||||
database.MustScan(t, "counting books", db.QueryRow("SELECT count(*) FROM books"), &bookCount)
|
database.MustScan(t, "counting books", db.QueryRow("SELECT count(*) FROM books"), &bookCount)
|
||||||
|
|
@ -501,3 +509,125 @@ func TestRemoveBook(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDBPathFlag(t *testing.T) {
|
||||||
|
// Helper function to verify database contents
|
||||||
|
verifyDatabase := func(t *testing.T, dbPath, expectedBook, expectedNote string) *database.DB {
|
||||||
|
ok, err := utils.FileExists(dbPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(errors.Wrapf(err, "checking if custom db exists at %s", dbPath))
|
||||||
|
}
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("custom database was not created at %s", dbPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
db, err := database.Open(dbPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(errors.Wrapf(err, "opening db at %s", dbPath))
|
||||||
|
}
|
||||||
|
|
||||||
|
var noteCount, bookCount int
|
||||||
|
database.MustScan(t, "counting books", db.QueryRow("SELECT count(*) FROM books"), &bookCount)
|
||||||
|
database.MustScan(t, "counting notes", db.QueryRow("SELECT count(*) FROM notes"), ¬eCount)
|
||||||
|
|
||||||
|
assert.Equalf(t, bookCount, 1, fmt.Sprintf("%s book count mismatch", dbPath))
|
||||||
|
assert.Equalf(t, noteCount, 1, fmt.Sprintf("%s note count mismatch", dbPath))
|
||||||
|
|
||||||
|
var book database.Book
|
||||||
|
database.MustScan(t, "getting book", db.QueryRow("SELECT label FROM books"), &book.Label)
|
||||||
|
assert.Equalf(t, book.Label, expectedBook, fmt.Sprintf("%s book label mismatch", dbPath))
|
||||||
|
|
||||||
|
var note database.Note
|
||||||
|
database.MustScan(t, "getting note", db.QueryRow("SELECT body FROM notes"), ¬e.Body)
|
||||||
|
assert.Equalf(t, note.Body, expectedNote, fmt.Sprintf("%s note body mismatch", dbPath))
|
||||||
|
|
||||||
|
return db
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup - use two different custom database paths
|
||||||
|
testDir, customOpts := setupTestEnv(t)
|
||||||
|
customDBPath1 := fmt.Sprintf("%s/custom-test1.db", testDir)
|
||||||
|
customDBPath2 := fmt.Sprintf("%s/custom-test2.db", testDir)
|
||||||
|
|
||||||
|
// Execute - add different notes to each database
|
||||||
|
testutils.RunDnoteCmd(t, customOpts, binaryName, "--dbPath", customDBPath1, "add", "db1-book", "-c", "content in db1")
|
||||||
|
testutils.RunDnoteCmd(t, customOpts, binaryName, "--dbPath", customDBPath2, "add", "db2-book", "-c", "content in db2")
|
||||||
|
|
||||||
|
// Test both databases
|
||||||
|
db1 := verifyDatabase(t, customDBPath1, "db1-book", "content in db1")
|
||||||
|
defer db1.Close()
|
||||||
|
|
||||||
|
db2 := verifyDatabase(t, customDBPath2, "db2-book", "content in db2")
|
||||||
|
defer db2.Close()
|
||||||
|
|
||||||
|
// Verify that the databases are independent
|
||||||
|
var db1HasDB2Book int
|
||||||
|
db1.QueryRow("SELECT count(*) FROM books WHERE label = ?", "db2-book").Scan(&db1HasDB2Book)
|
||||||
|
assert.Equal(t, db1HasDB2Book, 0, "db1 should not have db2's book")
|
||||||
|
|
||||||
|
var db2HasDB1Book int
|
||||||
|
db2.QueryRow("SELECT count(*) FROM books WHERE label = ?", "db1-book").Scan(&db2HasDB1Book)
|
||||||
|
assert.Equal(t, db2HasDB1Book, 0, "db2 should not have db1's book")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestView(t *testing.T) {
|
||||||
|
t.Run("view note by rowid", func(t *testing.T) {
|
||||||
|
_, opts := setupTestEnv(t)
|
||||||
|
|
||||||
|
db, dbPath := database.InitTestFileDB(t)
|
||||||
|
testutils.Setup4(t, db)
|
||||||
|
|
||||||
|
output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view", "1")
|
||||||
|
|
||||||
|
assert.Equal(t, strings.Contains(output, "Booleans have toString()"), true, "should contain note content")
|
||||||
|
assert.Equal(t, strings.Contains(output, "book name"), true, "should show metadata")
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("view note content only", func(t *testing.T) {
|
||||||
|
_, opts := setupTestEnv(t)
|
||||||
|
|
||||||
|
db, dbPath := database.InitTestFileDB(t)
|
||||||
|
testutils.Setup4(t, db)
|
||||||
|
|
||||||
|
output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view", "1", "--content-only")
|
||||||
|
|
||||||
|
assert.Equal(t, strings.Contains(output, "Booleans have toString()"), true, "should contain note content")
|
||||||
|
assert.Equal(t, strings.Contains(output, "book name"), false, "should not show metadata")
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("list books", func(t *testing.T) {
|
||||||
|
_, opts := setupTestEnv(t)
|
||||||
|
|
||||||
|
db, dbPath := database.InitTestFileDB(t)
|
||||||
|
testutils.Setup1(t, db)
|
||||||
|
|
||||||
|
output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view")
|
||||||
|
|
||||||
|
assert.Equal(t, strings.Contains(output, "js"), true, "should list js book")
|
||||||
|
assert.Equal(t, strings.Contains(output, "linux"), true, "should list linux book")
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("list notes in book", func(t *testing.T) {
|
||||||
|
_, opts := setupTestEnv(t)
|
||||||
|
|
||||||
|
db, dbPath := database.InitTestFileDB(t)
|
||||||
|
testutils.Setup2(t, db)
|
||||||
|
|
||||||
|
output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view", "js")
|
||||||
|
|
||||||
|
assert.Equal(t, strings.Contains(output, "n1 body"), true, "should list note 1")
|
||||||
|
assert.Equal(t, strings.Contains(output, "n2 body"), true, "should list note 2")
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("view note by book name and rowid", func(t *testing.T) {
|
||||||
|
_, opts := setupTestEnv(t)
|
||||||
|
|
||||||
|
db, dbPath := database.InitTestFileDB(t)
|
||||||
|
testutils.Setup4(t, db)
|
||||||
|
|
||||||
|
output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view", "js", "2")
|
||||||
|
|
||||||
|
assert.Equal(t, strings.Contains(output, "Date object implements mathematical comparisons"), true, "should contain note content")
|
||||||
|
assert.Equal(t, strings.Contains(output, "book name"), true, "should show metadata")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,5 @@ CREATE TRIGGER notes_after_update AFTER UPDATE ON notes BEGIN
|
||||||
INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body);
|
INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body);
|
||||||
INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body);
|
INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body);
|
||||||
END;
|
END;
|
||||||
CREATE TABLE actions
|
|
||||||
(
|
|
||||||
uuid text PRIMARY KEY,
|
|
||||||
schema integer NOT NULL,
|
|
||||||
type text NOT NULL,
|
|
||||||
data text NOT NULL,
|
|
||||||
timestamp integer NOT NULL
|
|
||||||
);
|
|
||||||
CREATE UNIQUE INDEX idx_notes_uuid ON notes(uuid);
|
CREATE UNIQUE INDEX idx_notes_uuid ON notes(uuid);
|
||||||
CREATE INDEX idx_notes_book_uuid ON notes(book_uuid);
|
CREATE INDEX idx_notes_book_uuid ON notes(book_uuid);
|
||||||
|
|
|
||||||
42
pkg/cli/migrate/fixtures/local-14-pre-schema.sql
Normal file
42
pkg/cli/migrate/fixtures/local-14-pre-schema.sql
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
CREATE TABLE books
|
||||||
|
(
|
||||||
|
uuid text PRIMARY KEY,
|
||||||
|
label text NOT NULL
|
||||||
|
, dirty bool DEFAULT false, usn int DEFAULT 0 NOT NULL, deleted bool DEFAULT false);
|
||||||
|
CREATE TABLE system
|
||||||
|
(
|
||||||
|
key string NOT NULL,
|
||||||
|
value text NOT NULL
|
||||||
|
);
|
||||||
|
CREATE UNIQUE INDEX idx_books_label ON books(label);
|
||||||
|
CREATE UNIQUE INDEX idx_books_uuid ON books(uuid);
|
||||||
|
CREATE TABLE IF NOT EXISTS "notes"
|
||||||
|
(
|
||||||
|
uuid text NOT NULL,
|
||||||
|
book_uuid text NOT NULL,
|
||||||
|
body text NOT NULL,
|
||||||
|
added_on integer NOT NULL,
|
||||||
|
edited_on integer DEFAULT 0,
|
||||||
|
public bool DEFAULT false,
|
||||||
|
dirty bool DEFAULT false,
|
||||||
|
usn int DEFAULT 0 NOT NULL,
|
||||||
|
deleted bool DEFAULT false
|
||||||
|
);
|
||||||
|
CREATE VIRTUAL TABLE note_fts USING fts5(content=notes, body, tokenize="porter unicode61 categories 'L* N* Co Ps Pe'")
|
||||||
|
/* note_fts(body) */;
|
||||||
|
CREATE TABLE IF NOT EXISTS 'note_fts_data'(id INTEGER PRIMARY KEY, block BLOB);
|
||||||
|
CREATE TABLE IF NOT EXISTS 'note_fts_idx'(segid, term, pgno, PRIMARY KEY(segid, term)) WITHOUT ROWID;
|
||||||
|
CREATE TABLE IF NOT EXISTS 'note_fts_docsize'(id INTEGER PRIMARY KEY, sz BLOB);
|
||||||
|
CREATE TABLE IF NOT EXISTS 'note_fts_config'(k PRIMARY KEY, v) WITHOUT ROWID;
|
||||||
|
CREATE TRIGGER notes_after_insert AFTER INSERT ON notes BEGIN
|
||||||
|
INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body);
|
||||||
|
END;
|
||||||
|
CREATE TRIGGER notes_after_delete AFTER DELETE ON notes BEGIN
|
||||||
|
INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body);
|
||||||
|
END;
|
||||||
|
CREATE TRIGGER notes_after_update AFTER UPDATE ON notes BEGIN
|
||||||
|
INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body);
|
||||||
|
INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body);
|
||||||
|
END;
|
||||||
|
CREATE UNIQUE INDEX idx_notes_uuid ON notes(uuid);
|
||||||
|
CREATE INDEX idx_notes_book_uuid ON notes(book_uuid);
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Package migrate provides migration logic for both sqlite and
|
// Package migrate provides migration logic for both sqlite and
|
||||||
|
|
@ -23,7 +20,6 @@ package migrate
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -232,7 +228,7 @@ func readSchema(ctx context.DnoteCtx) (schema, error) {
|
||||||
|
|
||||||
path := getSchemaPath(ctx)
|
path := getSchemaPath(ctx)
|
||||||
|
|
||||||
b, err := ioutil.ReadFile(path)
|
b, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ret, errors.Wrap(err, "Failed to read schema file")
|
return ret, errors.Wrap(err, "Failed to read schema file")
|
||||||
}
|
}
|
||||||
|
|
@ -252,7 +248,7 @@ func writeSchema(ctx context.DnoteCtx, s schema) error {
|
||||||
return errors.Wrap(err, "Failed to marshal schema into yaml")
|
return errors.Wrap(err, "Failed to marshal schema into yaml")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ioutil.WriteFile(path, d, 0644); err != nil {
|
if err := os.WriteFile(path, d, 0644); err != nil {
|
||||||
return errors.Wrap(err, "Failed to write schema file")
|
return errors.Wrap(err, "Failed to write schema file")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -504,7 +500,7 @@ func migrateToV1(ctx context.DnoteCtx) error {
|
||||||
func migrateToV2(ctx context.DnoteCtx) error {
|
func migrateToV2(ctx context.DnoteCtx) error {
|
||||||
notePath := fmt.Sprintf("%s/dnote", ctx.Paths.LegacyDnote)
|
notePath := fmt.Sprintf("%s/dnote", ctx.Paths.LegacyDnote)
|
||||||
|
|
||||||
b, err := ioutil.ReadFile(notePath)
|
b, err := os.ReadFile(notePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Failed to read the note file")
|
return errors.Wrap(err, "Failed to read the note file")
|
||||||
}
|
}
|
||||||
|
|
@ -548,7 +544,7 @@ func migrateToV2(ctx context.DnoteCtx) error {
|
||||||
return errors.Wrap(err, "Failed to marshal new dnote into JSON")
|
return errors.Wrap(err, "Failed to marshal new dnote into JSON")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(notePath, d, 0644)
|
err = os.WriteFile(notePath, d, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Failed to write the new dnote into the file")
|
return errors.Wrap(err, "Failed to write the new dnote into the file")
|
||||||
}
|
}
|
||||||
|
|
@ -561,7 +557,7 @@ func migrateToV3(ctx context.DnoteCtx) error {
|
||||||
notePath := fmt.Sprintf("%s/dnote", ctx.Paths.LegacyDnote)
|
notePath := fmt.Sprintf("%s/dnote", ctx.Paths.LegacyDnote)
|
||||||
actionsPath := fmt.Sprintf("%s/actions", ctx.Paths.LegacyDnote)
|
actionsPath := fmt.Sprintf("%s/actions", ctx.Paths.LegacyDnote)
|
||||||
|
|
||||||
b, err := ioutil.ReadFile(notePath)
|
b, err := os.ReadFile(notePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Failed to read the note file")
|
return errors.Wrap(err, "Failed to read the note file")
|
||||||
}
|
}
|
||||||
|
|
@ -615,7 +611,7 @@ func migrateToV3(ctx context.DnoteCtx) error {
|
||||||
return errors.Wrap(err, "Failed to marshal actions into JSON")
|
return errors.Wrap(err, "Failed to marshal actions into JSON")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(actionsPath, a, 0644)
|
err = os.WriteFile(actionsPath, a, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Failed to write the actions into a file")
|
return errors.Wrap(err, "Failed to write the actions into a file")
|
||||||
}
|
}
|
||||||
|
|
@ -647,7 +643,7 @@ func getEditorCommand() string {
|
||||||
func migrateToV4(ctx context.DnoteCtx) error {
|
func migrateToV4(ctx context.DnoteCtx) error {
|
||||||
configPath := fmt.Sprintf("%s/dnoterc", ctx.Paths.LegacyDnote)
|
configPath := fmt.Sprintf("%s/dnoterc", ctx.Paths.LegacyDnote)
|
||||||
|
|
||||||
b, err := ioutil.ReadFile(configPath)
|
b, err := os.ReadFile(configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Failed to read the config file")
|
return errors.Wrap(err, "Failed to read the config file")
|
||||||
}
|
}
|
||||||
|
|
@ -668,7 +664,7 @@ func migrateToV4(ctx context.DnoteCtx) error {
|
||||||
return errors.Wrap(err, "Failed to marshal config into JSON")
|
return errors.Wrap(err, "Failed to marshal config into JSON")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(configPath, data, 0644)
|
err = os.WriteFile(configPath, data, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Failed to write the config into a file")
|
return errors.Wrap(err, "Failed to write the config into a file")
|
||||||
}
|
}
|
||||||
|
|
@ -680,7 +676,7 @@ func migrateToV4(ctx context.DnoteCtx) error {
|
||||||
func migrateToV5(ctx context.DnoteCtx) error {
|
func migrateToV5(ctx context.DnoteCtx) error {
|
||||||
actionsPath := fmt.Sprintf("%s/actions", ctx.Paths.LegacyDnote)
|
actionsPath := fmt.Sprintf("%s/actions", ctx.Paths.LegacyDnote)
|
||||||
|
|
||||||
b, err := ioutil.ReadFile(actionsPath)
|
b, err := os.ReadFile(actionsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "reading the actions file")
|
return errors.Wrap(err, "reading the actions file")
|
||||||
}
|
}
|
||||||
|
|
@ -738,7 +734,7 @@ func migrateToV5(ctx context.DnoteCtx) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "marshalling result into JSON")
|
return errors.Wrap(err, "marshalling result into JSON")
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(actionsPath, a, 0644)
|
err = os.WriteFile(actionsPath, a, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "writing the result into a file")
|
return errors.Wrap(err, "writing the result into a file")
|
||||||
}
|
}
|
||||||
|
|
@ -750,7 +746,7 @@ func migrateToV5(ctx context.DnoteCtx) error {
|
||||||
func migrateToV6(ctx context.DnoteCtx) error {
|
func migrateToV6(ctx context.DnoteCtx) error {
|
||||||
notePath := fmt.Sprintf("%s/dnote", ctx.Paths.LegacyDnote)
|
notePath := fmt.Sprintf("%s/dnote", ctx.Paths.LegacyDnote)
|
||||||
|
|
||||||
b, err := ioutil.ReadFile(notePath)
|
b, err := os.ReadFile(notePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Failed to read the note file")
|
return errors.Wrap(err, "Failed to read the note file")
|
||||||
}
|
}
|
||||||
|
|
@ -791,7 +787,7 @@ func migrateToV6(ctx context.DnoteCtx) error {
|
||||||
return errors.Wrap(err, "Failed to marshal new dnote into JSON")
|
return errors.Wrap(err, "Failed to marshal new dnote into JSON")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(notePath, d, 0644)
|
err = os.WriteFile(notePath, d, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Failed to write the new dnote into the file")
|
return errors.Wrap(err, "Failed to write the new dnote into the file")
|
||||||
}
|
}
|
||||||
|
|
@ -805,7 +801,7 @@ func migrateToV6(ctx context.DnoteCtx) error {
|
||||||
func migrateToV7(ctx context.DnoteCtx) error {
|
func migrateToV7(ctx context.DnoteCtx) error {
|
||||||
actionPath := fmt.Sprintf("%s/actions", ctx.Paths.LegacyDnote)
|
actionPath := fmt.Sprintf("%s/actions", ctx.Paths.LegacyDnote)
|
||||||
|
|
||||||
b, err := ioutil.ReadFile(actionPath)
|
b, err := os.ReadFile(actionPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "reading actions file")
|
return errors.Wrap(err, "reading actions file")
|
||||||
}
|
}
|
||||||
|
|
@ -857,7 +853,7 @@ func migrateToV7(ctx context.DnoteCtx) error {
|
||||||
return errors.Wrap(err, "marshalling new actions")
|
return errors.Wrap(err, "marshalling new actions")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(actionPath, d, 0644)
|
err = os.WriteFile(actionPath, d, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "writing new actions to a file")
|
return errors.Wrap(err, "writing new actions to a file")
|
||||||
}
|
}
|
||||||
|
|
@ -874,7 +870,7 @@ func migrateToV8(ctx context.DnoteCtx) error {
|
||||||
|
|
||||||
// 1. Migrate the the dnote file
|
// 1. Migrate the the dnote file
|
||||||
dnoteFilePath := fmt.Sprintf("%s/dnote", ctx.Paths.LegacyDnote)
|
dnoteFilePath := fmt.Sprintf("%s/dnote", ctx.Paths.LegacyDnote)
|
||||||
b, err := ioutil.ReadFile(dnoteFilePath)
|
b, err := os.ReadFile(dnoteFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "reading the notes")
|
return errors.Wrap(err, "reading the notes")
|
||||||
}
|
}
|
||||||
|
|
@ -914,7 +910,7 @@ func migrateToV8(ctx context.DnoteCtx) error {
|
||||||
|
|
||||||
// 2. Migrate the actions file
|
// 2. Migrate the actions file
|
||||||
actionsPath := fmt.Sprintf("%s/actions", ctx.Paths.LegacyDnote)
|
actionsPath := fmt.Sprintf("%s/actions", ctx.Paths.LegacyDnote)
|
||||||
b, err = ioutil.ReadFile(actionsPath)
|
b, err = os.ReadFile(actionsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "reading the actions")
|
return errors.Wrap(err, "reading the actions")
|
||||||
}
|
}
|
||||||
|
|
@ -939,7 +935,7 @@ func migrateToV8(ctx context.DnoteCtx) error {
|
||||||
|
|
||||||
// 3. Migrate the timestamps file
|
// 3. Migrate the timestamps file
|
||||||
timestampsPath := fmt.Sprintf("%s/timestamps", ctx.Paths.LegacyDnote)
|
timestampsPath := fmt.Sprintf("%s/timestamps", ctx.Paths.LegacyDnote)
|
||||||
b, err = ioutil.ReadFile(timestampsPath)
|
b, err = os.ReadFile(timestampsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "reading the timestamps")
|
return errors.Wrap(err, "reading the timestamps")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package migrate
|
package migrate
|
||||||
|
|
@ -21,7 +18,6 @@ package migrate
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -65,7 +61,7 @@ func TestMigrateToV1(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(errors.Wrap(err, "Failed to get absolute YAML path").Error())
|
panic(errors.Wrap(err, "Failed to get absolute YAML path").Error())
|
||||||
}
|
}
|
||||||
ioutil.WriteFile(yamlPath, []byte{}, 0644)
|
os.WriteFile(yamlPath, []byte{}, 0644)
|
||||||
|
|
||||||
// execute
|
// execute
|
||||||
if err := migrateToV1(ctx); err != nil {
|
if err := migrateToV1(ctx); err != nil {
|
||||||
|
|
@ -354,14 +350,18 @@ func TestMigrateToV7(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMigrateToV8(t *testing.T) {
|
func TestMigrateToV8(t *testing.T) {
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-1-pre-schema.sql", SkipMigration: true}
|
tmpDir := t.TempDir()
|
||||||
db := database.InitTestDB(t, "../tmp/.dnote/dnote-test.db", &opts)
|
dnoteDir := tmpDir + "/.dnote"
|
||||||
defer database.TeardownTestDB(t, db)
|
if err := os.MkdirAll(dnoteDir, 0755); err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "creating legacy dnote directory"))
|
||||||
|
}
|
||||||
|
|
||||||
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-1-pre-schema.sql")
|
||||||
|
|
||||||
ctx := context.DnoteCtx{
|
ctx := context.DnoteCtx{
|
||||||
Paths: context.Paths{
|
Paths: context.Paths{
|
||||||
Home: "../tmp",
|
Home: tmpDir,
|
||||||
LegacyDnote: "../tmp/.dnote",
|
LegacyDnote: dnoteDir,
|
||||||
},
|
},
|
||||||
DB: db,
|
DB: db,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,23 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package migrate
|
package migrate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/cli/consts"
|
"github.com/dnote/dnote/pkg/cli/consts"
|
||||||
"github.com/dnote/dnote/pkg/cli/context"
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
"github.com/dnote/dnote/pkg/cli/log"
|
"github.com/dnote/dnote/pkg/cli/log"
|
||||||
|
|
@ -47,6 +45,8 @@ var LocalSequence = []migration{
|
||||||
lm10,
|
lm10,
|
||||||
lm11,
|
lm11,
|
||||||
lm12,
|
lm12,
|
||||||
|
lm13,
|
||||||
|
lm14,
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoteSequence is a list of remote migrations to be run
|
// RemoteSequence is a list of remote migrations to be run
|
||||||
|
|
@ -141,7 +141,7 @@ func Run(ctx context.DnoteCtx, migrations []migration, mode int) error {
|
||||||
return errors.Wrap(err, "getting the current schema")
|
return errors.Wrap(err, "getting the current schema")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("current schema: %s %d of %d\n", consts.SystemSchema, schema, len(migrations))
|
log.Debug("%s: %d of %d\n", schemaKey, schema, len(migrations))
|
||||||
|
|
||||||
toRun := migrations[schema:]
|
toRun := migrations[schema:]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package migrate
|
package migrate
|
||||||
|
|
@ -21,13 +18,14 @@ package migrate
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"github.com/dnote/actions"
|
"github.com/dnote/actions"
|
||||||
"github.com/dnote/dnote/pkg/assert"
|
"github.com/dnote/dnote/pkg/assert"
|
||||||
"github.com/dnote/dnote/pkg/cli/consts"
|
"github.com/dnote/dnote/pkg/cli/consts"
|
||||||
|
|
@ -37,12 +35,13 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var paths context.Paths = context.Paths{
|
// initTestDBNoMigration initializes a test database with schema.sql but removes
|
||||||
Home: "../../tmp",
|
// migration version data so tests can control the migration state themselves.
|
||||||
Cache: "../../tmp",
|
func initTestDBNoMigration(t *testing.T) *database.DB {
|
||||||
Config: "../../tmp",
|
db := database.InitTestMemoryDBRaw(t, "")
|
||||||
Data: "../../tmp",
|
// Remove migration versions from schema.sql so tests can set their own
|
||||||
LegacyDnote: "../../tmp",
|
database.MustExec(t, "clearing schema versions", db, "DELETE FROM system WHERE key IN (?, ?)", consts.SystemSchema, consts.SystemRemoteSchema)
|
||||||
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExecute_bump_schema(t *testing.T) {
|
func TestExecute_bump_schema(t *testing.T) {
|
||||||
|
|
@ -60,11 +59,8 @@ func TestExecute_bump_schema(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
func() {
|
func() {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SkipMigration: true}
|
db := initTestDBNoMigration(t)
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
|
|
||||||
database.MustExec(t, "inserting a schema", db, "INSERT INTO system (key, value) VALUES (?, ?)", tc.schemaKey, 8)
|
database.MustExec(t, "inserting a schema", db, "INSERT INTO system (key, value) VALUES (?, ?)", tc.schemaKey, 8)
|
||||||
|
|
||||||
|
|
@ -117,11 +113,8 @@ func TestRun_nonfresh(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
func() {
|
func() {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SkipMigration: true}
|
db := initTestDBNoMigration(t)
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
database.MustExec(t, "inserting a schema", db, "INSERT INTO system (key, value) VALUES (?, ?)", tc.schemaKey, 2)
|
database.MustExec(t, "inserting a schema", db, "INSERT INTO system (key, value) VALUES (?, ?)", tc.schemaKey, 2)
|
||||||
database.MustExec(t, "creating a temporary table for testing", db,
|
database.MustExec(t, "creating a temporary table for testing", db,
|
||||||
"CREATE TABLE migrate_run_test ( name string )")
|
"CREATE TABLE migrate_run_test ( name string )")
|
||||||
|
|
@ -197,11 +190,8 @@ func TestRun_fresh(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
func() {
|
func() {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SkipMigration: true}
|
db := initTestDBNoMigration(t)
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
|
|
||||||
database.MustExec(t, "creating a temporary table for testing", db,
|
database.MustExec(t, "creating a temporary table for testing", db,
|
||||||
"CREATE TABLE migrate_run_test ( name string )")
|
"CREATE TABLE migrate_run_test ( name string )")
|
||||||
|
|
@ -271,11 +261,8 @@ func TestRun_up_to_date(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
func() {
|
func() {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SkipMigration: true}
|
db := initTestDBNoMigration(t)
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
|
|
||||||
database.MustExec(t, "creating a temporary table for testing", db,
|
database.MustExec(t, "creating a temporary table for testing", db,
|
||||||
"CREATE TABLE migrate_run_test ( name string )")
|
"CREATE TABLE migrate_run_test ( name string )")
|
||||||
|
|
@ -326,11 +313,8 @@ func TestRun_up_to_date(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration1(t *testing.T) {
|
func TestLocalMigration1(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-1-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-1-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
data := testutils.MustMarshalJSON(t, actions.AddBookDataV1{BookName: "js"})
|
data := testutils.MustMarshalJSON(t, actions.AddBookDataV1{BookName: "js"})
|
||||||
a1UUID := testutils.MustGenerateUUID(t)
|
a1UUID := testutils.MustGenerateUUID(t)
|
||||||
database.MustExec(t, "inserting action", db,
|
database.MustExec(t, "inserting action", db,
|
||||||
|
|
@ -404,11 +388,8 @@ func TestLocalMigration1(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration2(t *testing.T) {
|
func TestLocalMigration2(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-1-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-1-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
c1 := "note 1 - v1"
|
c1 := "note 1 - v1"
|
||||||
c2 := "note 1 - v2"
|
c2 := "note 1 - v2"
|
||||||
css := "css"
|
css := "css"
|
||||||
|
|
@ -491,11 +472,8 @@ func TestLocalMigration2(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration3(t *testing.T) {
|
func TestLocalMigration3(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-1-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-1-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
data := testutils.MustMarshalJSON(t, actions.AddNoteDataV2{NoteUUID: "note-1-uuid", BookName: "js", Content: "note 1", Public: false})
|
data := testutils.MustMarshalJSON(t, actions.AddNoteDataV2{NoteUUID: "note-1-uuid", BookName: "js", Content: "note 1", Public: false})
|
||||||
a1UUID := testutils.MustGenerateUUID(t)
|
a1UUID := testutils.MustGenerateUUID(t)
|
||||||
database.MustExec(t, "inserting action", db,
|
database.MustExec(t, "inserting action", db,
|
||||||
|
|
@ -566,11 +544,8 @@ func TestLocalMigration3(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration4(t *testing.T) {
|
func TestLocalMigration4(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-1-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-1-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
|
|
||||||
b1UUID := testutils.MustGenerateUUID(t)
|
b1UUID := testutils.MustGenerateUUID(t)
|
||||||
database.MustExec(t, "inserting css book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "css")
|
database.MustExec(t, "inserting css book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "css")
|
||||||
|
|
@ -610,11 +585,8 @@ func TestLocalMigration4(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration5(t *testing.T) {
|
func TestLocalMigration5(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-5-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-5-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
|
|
||||||
b1UUID := testutils.MustGenerateUUID(t)
|
b1UUID := testutils.MustGenerateUUID(t)
|
||||||
database.MustExec(t, "inserting css book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "css")
|
database.MustExec(t, "inserting css book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "css")
|
||||||
|
|
@ -672,11 +644,8 @@ func TestLocalMigration5(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration6(t *testing.T) {
|
func TestLocalMigration6(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-5-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-5-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
|
|
||||||
data := testutils.MustMarshalJSON(t, actions.AddBookDataV1{BookName: "js"})
|
data := testutils.MustMarshalJSON(t, actions.AddBookDataV1{BookName: "js"})
|
||||||
a1UUID := testutils.MustGenerateUUID(t)
|
a1UUID := testutils.MustGenerateUUID(t)
|
||||||
|
|
@ -705,11 +674,8 @@ func TestLocalMigration6(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration7_trash(t *testing.T) {
|
func TestLocalMigration7_trash(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-7-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-7-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
|
|
||||||
b1UUID := testutils.MustGenerateUUID(t)
|
b1UUID := testutils.MustGenerateUUID(t)
|
||||||
database.MustExec(t, "inserting trash book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "trash")
|
database.MustExec(t, "inserting trash book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "trash")
|
||||||
|
|
@ -738,11 +704,8 @@ func TestLocalMigration7_trash(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration7_conflicts(t *testing.T) {
|
func TestLocalMigration7_conflicts(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-7-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-7-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
|
|
||||||
b1UUID := testutils.MustGenerateUUID(t)
|
b1UUID := testutils.MustGenerateUUID(t)
|
||||||
database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "conflicts")
|
database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "conflicts")
|
||||||
|
|
@ -771,11 +734,8 @@ func TestLocalMigration7_conflicts(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration7_conflicts_dup(t *testing.T) {
|
func TestLocalMigration7_conflicts_dup(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-7-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-7-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
|
|
||||||
b1UUID := testutils.MustGenerateUUID(t)
|
b1UUID := testutils.MustGenerateUUID(t)
|
||||||
database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "conflicts")
|
database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "conflicts")
|
||||||
|
|
@ -809,11 +769,8 @@ func TestLocalMigration7_conflicts_dup(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration8(t *testing.T) {
|
func TestLocalMigration8(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-8-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-8-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
|
|
||||||
b1UUID := testutils.MustGenerateUUID(t)
|
b1UUID := testutils.MustGenerateUUID(t)
|
||||||
database.MustExec(t, "inserting book 1", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1")
|
database.MustExec(t, "inserting book 1", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1")
|
||||||
|
|
@ -846,13 +803,13 @@ func TestLocalMigration8(t *testing.T) {
|
||||||
var n1AddedOn, n1EditedOn int64
|
var n1AddedOn, n1EditedOn int64
|
||||||
var n1USN int
|
var n1USN int
|
||||||
var n1Public, n1Dirty, n1Deleted bool
|
var n1Public, n1Dirty, n1Deleted bool
|
||||||
database.MustScan(t, "scanning n1", db.QueryRow("SELECT book_uuid, body, added_on, edited_on, usn, public, dirty, deleted FROM notes WHERE uuid = ?", n1UUID), &n1BookUUID, &n1Body, &n1AddedOn, &n1EditedOn, &n1USN, &n1Public, &n1Dirty, &n1Deleted)
|
database.MustScan(t, "scanning n1", db.QueryRow("SELECT book_uuid, body, added_on, edited_on, usn, public, dirty, deleted FROM notes WHERE uuid = ?", n1UUID), &n1BookUUID, &n1Body, &n1AddedOn, &n1EditedOn, &n1USN, &n1Public, &n1Dirty, &n1Deleted)
|
||||||
|
|
||||||
var n2BookUUID, n2Body string
|
var n2BookUUID, n2Body string
|
||||||
var n2AddedOn, n2EditedOn int64
|
var n2AddedOn, n2EditedOn int64
|
||||||
var n2USN int
|
var n2USN int
|
||||||
var n2Public, n2Dirty, n2Deleted bool
|
var n2Public, n2Dirty, n2Deleted bool
|
||||||
database.MustScan(t, "scanning n2", db.QueryRow("SELECT book_uuid, body, added_on, edited_on, usn, public, dirty, deleted FROM notes WHERE uuid = ?", n2UUID), &n2BookUUID, &n2Body, &n2AddedOn, &n2EditedOn, &n2USN, &n2Public, &n2Dirty, &n2Deleted)
|
database.MustScan(t, "scanning n2", db.QueryRow("SELECT book_uuid, body, added_on, edited_on, usn, public, dirty, deleted FROM notes WHERE uuid = ?", n2UUID), &n2BookUUID, &n2Body, &n2AddedOn, &n2EditedOn, &n2USN, &n2Public, &n2Dirty, &n2Deleted)
|
||||||
|
|
||||||
assert.Equal(t, n1BookUUID, b1UUID, "n1 BookUUID mismatch")
|
assert.Equal(t, n1BookUUID, b1UUID, "n1 BookUUID mismatch")
|
||||||
assert.Equal(t, n1Body, "n1 Body", "n1 Body mismatch")
|
assert.Equal(t, n1Body, "n1 Body", "n1 Body mismatch")
|
||||||
|
|
@ -875,11 +832,8 @@ func TestLocalMigration8(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration9(t *testing.T) {
|
func TestLocalMigration9(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-9-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-9-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
|
|
||||||
b1UUID := testutils.MustGenerateUUID(t)
|
b1UUID := testutils.MustGenerateUUID(t)
|
||||||
database.MustExec(t, "inserting book 1", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1")
|
database.MustExec(t, "inserting book 1", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1")
|
||||||
|
|
@ -921,11 +875,8 @@ func TestLocalMigration9(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration10(t *testing.T) {
|
func TestLocalMigration10(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-10-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-10-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
|
|
||||||
b1UUID := testutils.MustGenerateUUID(t)
|
b1UUID := testutils.MustGenerateUUID(t)
|
||||||
database.MustExec(t, "inserting book ", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "123")
|
database.MustExec(t, "inserting book ", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "123")
|
||||||
|
|
@ -993,11 +944,8 @@ func TestLocalMigration10(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration11(t *testing.T) {
|
func TestLocalMigration11(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-11-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-11-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
|
|
||||||
b1UUID := testutils.MustGenerateUUID(t)
|
b1UUID := testutils.MustGenerateUUID(t)
|
||||||
database.MustExec(t, "inserting book 1", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "foo")
|
database.MustExec(t, "inserting book 1", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "foo")
|
||||||
|
|
@ -1073,13 +1021,12 @@ func TestLocalMigration11(t *testing.T) {
|
||||||
|
|
||||||
func TestLocalMigration12(t *testing.T) {
|
func TestLocalMigration12(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-12-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-12-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
data := []byte("editor: vim")
|
data := []byte("editor: vim")
|
||||||
path := fmt.Sprintf("%s/dnoterc", ctx.Paths.LegacyDnote)
|
path := fmt.Sprintf("%s/%s/dnoterc", ctx.Paths.Config, consts.DnoteDirName)
|
||||||
if err := ioutil.WriteFile(path, data, 0644); err != nil {
|
if err := os.WriteFile(path, data, 0644); err != nil {
|
||||||
t.Fatal(errors.Wrap(err, "Failed to write schema file"))
|
t.Fatal(errors.Wrap(err, "Failed to write schema file"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1090,7 +1037,7 @@ func TestLocalMigration12(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test
|
// test
|
||||||
b, err := ioutil.ReadFile(path)
|
b, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(errors.Wrap(err, "reading config"))
|
t.Fatal(errors.Wrap(err, "reading config"))
|
||||||
}
|
}
|
||||||
|
|
@ -1108,11 +1055,98 @@ func TestLocalMigration12(t *testing.T) {
|
||||||
assert.NotEqual(t, cf.APIEndpoint, "", "apiEndpoint was not populated")
|
assert.NotEqual(t, cf.APIEndpoint, "", "apiEndpoint was not populated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLocalMigration13(t *testing.T) {
|
||||||
|
// set up
|
||||||
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-12-pre-schema.sql")
|
||||||
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
|
|
||||||
|
data := []byte("editor: vim\napiEndpoint: https://test.com/api")
|
||||||
|
|
||||||
|
path := fmt.Sprintf("%s/%s/dnoterc", ctx.Paths.Config, consts.DnoteDirName)
|
||||||
|
if err := os.WriteFile(path, data, 0644); err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "Failed to write schema file"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// execute
|
||||||
|
err := lm13.run(ctx, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "failed to run"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// test
|
||||||
|
b, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "reading config"))
|
||||||
|
}
|
||||||
|
|
||||||
|
type config struct {
|
||||||
|
Editor string `yaml:"editor"`
|
||||||
|
ApiEndpoint string `yaml:"apiEndpoint"`
|
||||||
|
EnableUpgradeCheck bool `yaml:"enableUpgradeCheck"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var cf config
|
||||||
|
err = yaml.Unmarshal(b, &cf)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "unmarshalling config"))
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, cf.Editor, "vim", "editor mismatch")
|
||||||
|
assert.Equal(t, cf.ApiEndpoint, "https://test.com/api", "apiEndpoint mismatch")
|
||||||
|
assert.Equal(t, cf.EnableUpgradeCheck, true, "enableUpgradeCheck mismatch")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLocalMigration14(t *testing.T) {
|
||||||
|
// set up
|
||||||
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/local-14-pre-schema.sql")
|
||||||
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
|
|
||||||
|
b1UUID := testutils.MustGenerateUUID(t)
|
||||||
|
database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1")
|
||||||
|
|
||||||
|
n1UUID := testutils.MustGenerateUUID(t)
|
||||||
|
database.MustExec(t, "inserting note", db, `INSERT INTO notes
|
||||||
|
(uuid, book_uuid, body, added_on, edited_on, public, dirty, usn, deleted) VALUES
|
||||||
|
(?, ?, ?, ?, ?, ?, ?, ?, ?)`, n1UUID, b1UUID, "test note", 1, 2, true, false, 0, false)
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
tx, err := db.Begin()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "beginning a transaction"))
|
||||||
|
}
|
||||||
|
|
||||||
|
err = lm14.run(ctx, tx)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
t.Fatal(errors.Wrap(err, "failed to run"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tx.Commit()
|
||||||
|
|
||||||
|
// Test - verify public column was dropped by checking column names
|
||||||
|
rows, err := db.Query("SELECT name FROM pragma_table_info('notes')")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "getting table info"))
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
var name string
|
||||||
|
err := rows.Scan(&name)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "scanning column name"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if name == "public" {
|
||||||
|
t.Fatal("public column still exists after migration")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestRemoteMigration1(t *testing.T) {
|
func TestRemoteMigration1(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/remote-1-pre-schema.sql", SkipMigration: true}
|
db := database.InitTestMemoryDBRaw(t, "./fixtures/remote-1-pre-schema.sql")
|
||||||
ctx := context.InitTestCtx(t, paths, &opts)
|
ctx := context.InitTestCtxWithDB(t, db)
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
testutils.Login(t, &ctx)
|
testutils.Login(t, &ctx)
|
||||||
|
|
||||||
JSBookUUID := "existing-js-book-uuid"
|
JSBookUUID := "existing-js-book-uuid"
|
||||||
|
|
@ -1152,7 +1186,6 @@ func TestRemoteMigration1(t *testing.T) {
|
||||||
|
|
||||||
ctx.APIEndpoint = server.URL
|
ctx.APIEndpoint = server.URL
|
||||||
|
|
||||||
db := ctx.DB
|
|
||||||
database.MustExec(t, "inserting js book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", JSBookUUID, "js")
|
database.MustExec(t, "inserting js book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", JSBookUUID, "js")
|
||||||
database.MustExec(t, "inserting css book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", CSSBookUUID, "css")
|
database.MustExec(t, "inserting css book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", CSSBookUUID, "css")
|
||||||
database.MustExec(t, "inserting linux book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", linuxBookUUID, "linux")
|
database.MustExec(t, "inserting linux book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", linuxBookUUID, "linux")
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package migrate
|
package migrate
|
||||||
|
|
@ -539,7 +536,10 @@ var lm12 = migration{
|
||||||
return errors.Wrap(err, "reading config")
|
return errors.Wrap(err, "reading config")
|
||||||
}
|
}
|
||||||
|
|
||||||
cf.APIEndpoint = "https://api.getdnote.com"
|
// Only set if not already configured
|
||||||
|
if cf.APIEndpoint == "" {
|
||||||
|
cf.APIEndpoint = "https://api.getdnote.com"
|
||||||
|
}
|
||||||
|
|
||||||
err = config.Write(ctx, cf)
|
err = config.Write(ctx, cf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -550,6 +550,37 @@ var lm12 = migration{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lm13 = migration{
|
||||||
|
name: "add enableUpgradeCheck to the configuration file",
|
||||||
|
run: func(ctx context.DnoteCtx, tx *database.DB) error {
|
||||||
|
cf, err := config.Read(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "reading config")
|
||||||
|
}
|
||||||
|
|
||||||
|
cf.EnableUpgradeCheck = true
|
||||||
|
|
||||||
|
err = config.Write(ctx, cf)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "writing config")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var lm14 = migration{
|
||||||
|
name: "drop-public-from-notes",
|
||||||
|
run: func(ctx context.DnoteCtx, tx *database.DB) error {
|
||||||
|
_, err := tx.Exec(`ALTER TABLE notes DROP COLUMN public;`)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "dropping public column from notes")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
var rm1 = migration{
|
var rm1 = migration{
|
||||||
name: "sync-book-uuids-from-server",
|
name: "sync-book-uuids-from-server",
|
||||||
run: func(ctx context.DnoteCtx, tx *database.DB) error {
|
run: func(ctx context.DnoteCtx, tx *database.DB) error {
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Package output provides functions to print informations on the terminal
|
// Package output provides functions to print informations on the terminal
|
||||||
|
|
@ -22,6 +19,7 @@ package output
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/cli/database"
|
"github.com/dnote/dnote/pkg/cli/database"
|
||||||
|
|
@ -29,7 +27,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NoteInfo prints a note information
|
// NoteInfo prints a note information
|
||||||
func NoteInfo(info database.NoteInfo) {
|
func NoteInfo(w io.Writer, info database.NoteInfo) {
|
||||||
log.Infof("book name: %s\n", info.BookLabel)
|
log.Infof("book name: %s\n", info.BookLabel)
|
||||||
log.Infof("created at: %s\n", time.Unix(0, info.AddedOn).Format("Jan 2, 2006 3:04pm (MST)"))
|
log.Infof("created at: %s\n", time.Unix(0, info.AddedOn).Format("Jan 2, 2006 3:04pm (MST)"))
|
||||||
if info.EditedOn != 0 {
|
if info.EditedOn != 0 {
|
||||||
|
|
@ -38,13 +36,13 @@ func NoteInfo(info database.NoteInfo) {
|
||||||
log.Infof("note id: %d\n", info.RowID)
|
log.Infof("note id: %d\n", info.RowID)
|
||||||
log.Infof("note uuid: %s\n", info.UUID)
|
log.Infof("note uuid: %s\n", info.UUID)
|
||||||
|
|
||||||
fmt.Printf("\n------------------------content------------------------\n")
|
fmt.Fprintf(w, "\n------------------------content------------------------\n")
|
||||||
fmt.Printf("%s", info.Content)
|
fmt.Fprintf(w, "%s", info.Content)
|
||||||
fmt.Printf("\n-------------------------------------------------------\n")
|
fmt.Fprintf(w, "\n-------------------------------------------------------\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func NoteContent(info database.NoteInfo) {
|
func NoteContent(w io.Writer, info database.NoteInfo) {
|
||||||
fmt.Printf("%s", info.Content)
|
fmt.Fprintf(w, "%s", info.Content)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BookInfo prints a note information
|
// BookInfo prints a note information
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Package testutils provides utilities used in tests
|
// Package testutils provides utilities used in tests
|
||||||
|
|
@ -23,7 +20,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -31,6 +27,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/dnote/dnote/pkg/assert"
|
||||||
"github.com/dnote/dnote/pkg/cli/consts"
|
"github.com/dnote/dnote/pkg/cli/consts"
|
||||||
"github.com/dnote/dnote/pkg/cli/context"
|
"github.com/dnote/dnote/pkg/cli/context"
|
||||||
"github.com/dnote/dnote/pkg/cli/database"
|
"github.com/dnote/dnote/pkg/cli/database"
|
||||||
|
|
@ -38,12 +35,25 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Login simulates a logged in user by inserting credentials in the local database
|
// Prompts for user input
|
||||||
func Login(t *testing.T, ctx *context.DnoteCtx) {
|
const (
|
||||||
db := ctx.DB
|
PromptRemoveNote = "remove this note?"
|
||||||
|
PromptDeleteBook = "delete book"
|
||||||
|
PromptEmptyServer = "The server is empty but you have local data"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Timeout for waiting for prompts in tests
|
||||||
|
const promptTimeout = 10 * time.Second
|
||||||
|
|
||||||
|
// LoginDB sets up login credentials in the database for tests
|
||||||
|
func LoginDB(t *testing.T, db *database.DB) {
|
||||||
database.MustExec(t, "inserting sessionKey", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, "someSessionKey")
|
database.MustExec(t, "inserting sessionKey", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, "someSessionKey")
|
||||||
database.MustExec(t, "inserting sessionKeyExpiry", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, time.Now().Add(24*time.Hour).Unix())
|
database.MustExec(t, "inserting sessionKeyExpiry", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, time.Now().Add(24*time.Hour).Unix())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Login simulates a logged in user by inserting credentials in the local database
|
||||||
|
func Login(t *testing.T, ctx *context.DnoteCtx) {
|
||||||
|
LoginDB(t, ctx.DB)
|
||||||
|
|
||||||
ctx.SessionKey = "someSessionKey"
|
ctx.SessionKey = "someSessionKey"
|
||||||
ctx.SessionKeyExpiry = time.Now().Add(24 * time.Hour).Unix()
|
ctx.SessionKeyExpiry = time.Now().Add(24 * time.Hour).Unix()
|
||||||
|
|
@ -81,7 +91,7 @@ func WriteFile(ctx context.DnoteCtx, content []byte, filename string) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ioutil.WriteFile(dp, content, 0644); err != nil {
|
if err := os.WriteFile(dp, content, 0644); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +100,7 @@ func WriteFile(ctx context.DnoteCtx, content []byte, filename string) {
|
||||||
func ReadFile(ctx context.DnoteCtx, filename string) []byte {
|
func ReadFile(ctx context.DnoteCtx, filename string) []byte {
|
||||||
path := filepath.Join(ctx.Paths.LegacyDnote, filename)
|
path := filepath.Join(ctx.Paths.LegacyDnote, filename)
|
||||||
|
|
||||||
b, err := ioutil.ReadFile(path)
|
b, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
@ -101,7 +111,7 @@ func ReadFile(ctx context.DnoteCtx, filename string) []byte {
|
||||||
// ReadJSON reads JSON fixture to the struct at the destination address
|
// ReadJSON reads JSON fixture to the struct at the destination address
|
||||||
func ReadJSON(path string, destination interface{}) {
|
func ReadJSON(path string, destination interface{}) {
|
||||||
var dat []byte
|
var dat []byte
|
||||||
dat, err := ioutil.ReadFile(path)
|
dat, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(errors.Wrap(err, "Failed to load fixture payload"))
|
panic(errors.Wrap(err, "Failed to load fixture payload"))
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +144,7 @@ type RunDnoteCmdOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunDnoteCmd runs a dnote command
|
// RunDnoteCmd runs a dnote command
|
||||||
func RunDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, binaryName string, arg ...string) {
|
func RunDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, binaryName string, arg ...string) string {
|
||||||
t.Logf("running: %s %s", binaryName, strings.Join(arg, " "))
|
t.Logf("running: %s %s", binaryName, strings.Join(arg, " "))
|
||||||
|
|
||||||
cmd, stderr, stdout, err := NewDnoteCmd(opts, binaryName, arg...)
|
cmd, stderr, stdout, err := NewDnoteCmd(opts, binaryName, arg...)
|
||||||
|
|
@ -152,60 +162,100 @@ func RunDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, binaryName string, arg .
|
||||||
|
|
||||||
// Print stdout if and only if test fails later
|
// Print stdout if and only if test fails later
|
||||||
t.Logf("\n%s", stdout)
|
t.Logf("\n%s", stdout)
|
||||||
|
|
||||||
|
return stdout.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// WaitDnoteCmd runs a dnote command and waits until the command is exited
|
// WaitDnoteCmd runs a dnote command and passes stdout to the callback.
|
||||||
func WaitDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, runFunc func(io.WriteCloser) error, binaryName string, arg ...string) {
|
func WaitDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, runFunc func(io.Reader, io.WriteCloser) error, binaryName string, arg ...string) (string, error) {
|
||||||
t.Logf("running: %s %s", binaryName, strings.Join(arg, " "))
|
t.Logf("running: %s %s", binaryName, strings.Join(arg, " "))
|
||||||
|
|
||||||
cmd, stderr, stdout, err := NewDnoteCmd(opts, binaryName, arg...)
|
binaryPath, err := filepath.Abs(binaryName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Logf("\n%s", stdout)
|
return "", errors.Wrap(err, "getting absolute path to test binary")
|
||||||
t.Fatal(errors.Wrap(err, "getting command").Error())
|
}
|
||||||
|
|
||||||
|
cmd := exec.Command(binaryPath, arg...)
|
||||||
|
cmd.Env = opts.Env
|
||||||
|
|
||||||
|
var stderr bytes.Buffer
|
||||||
|
cmd.Stderr = &stderr
|
||||||
|
|
||||||
|
stdout, err := cmd.StdoutPipe()
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.Wrap(err, "getting stdout pipe")
|
||||||
}
|
}
|
||||||
|
|
||||||
stdin, err := cmd.StdinPipe()
|
stdin, err := cmd.StdinPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Logf("\n%s", stdout)
|
return "", errors.Wrap(err, "getting stdin")
|
||||||
t.Fatal(errors.Wrap(err, "getting stdin %s"))
|
|
||||||
}
|
}
|
||||||
defer stdin.Close()
|
defer stdin.Close()
|
||||||
|
|
||||||
// Start the program
|
if err = cmd.Start(); err != nil {
|
||||||
err = cmd.Start()
|
return "", errors.Wrap(err, "starting command")
|
||||||
if err != nil {
|
|
||||||
t.Logf("\n%s", stdout)
|
|
||||||
t.Fatal(errors.Wrap(err, "starting command"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = runFunc(stdin)
|
var output bytes.Buffer
|
||||||
|
tee := io.TeeReader(stdout, &output)
|
||||||
|
|
||||||
|
err = runFunc(tee, stdin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Logf("\n%s", stdout)
|
t.Logf("\n%s", output.String())
|
||||||
t.Fatal(errors.Wrap(err, "running with stdin"))
|
return output.String(), errors.Wrap(err, "running callback")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cmd.Wait()
|
io.Copy(&output, stdout)
|
||||||
if err != nil {
|
|
||||||
t.Logf("\n%s", stdout)
|
if err := cmd.Wait(); err != nil {
|
||||||
t.Fatal(errors.Wrapf(err, "running command %s", stderr.String()))
|
t.Logf("\n%s", output.String())
|
||||||
|
return output.String(), errors.Wrapf(err, "command failed: %s", stderr.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print stdout if and only if test fails later
|
t.Logf("\n%s", output.String())
|
||||||
t.Logf("\n%s", stdout)
|
return output.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserConfirm simulates confirmation from the user by writing to stdin
|
func MustWaitDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, runFunc func(io.Reader, io.WriteCloser) error, binaryName string, arg ...string) string {
|
||||||
func UserConfirm(stdin io.WriteCloser) error {
|
output, err := WaitDnoteCmd(t, opts, runFunc, binaryName, arg...)
|
||||||
// confirm
|
if err != nil {
|
||||||
if _, err := io.WriteString(stdin, "y\n"); err != nil {
|
t.Fatal(err)
|
||||||
return errors.Wrap(err, "indicating confirmation in stdin")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserContent simulates content from the user by writing to stdin
|
// MustWaitForPrompt waits for an expected prompt with a default timeout.
|
||||||
func UserContent(stdin io.WriteCloser) error {
|
// Fails the test if the prompt is not found or an error occurs.
|
||||||
|
func MustWaitForPrompt(t *testing.T, stdout io.Reader, expectedPrompt string) {
|
||||||
|
if err := assert.WaitForPrompt(stdout, expectedPrompt, promptTimeout); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConfirmRemoveNote waits for prompt for removing a note and confirms.
|
||||||
|
func ConfirmRemoveNote(stdout io.Reader, stdin io.WriteCloser) error {
|
||||||
|
return assert.RespondToPrompt(stdout, stdin, PromptRemoveNote, "y\n", promptTimeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConfirmRemoveBook waits for prompt for deleting a book confirms.
|
||||||
|
func ConfirmRemoveBook(stdout io.Reader, stdin io.WriteCloser) error {
|
||||||
|
return assert.RespondToPrompt(stdout, stdin, PromptDeleteBook, "y\n", promptTimeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserConfirmEmptyServerSync waits for an empty server prompt and confirms.
|
||||||
|
func UserConfirmEmptyServerSync(stdout io.Reader, stdin io.WriteCloser) error {
|
||||||
|
return assert.RespondToPrompt(stdout, stdin, PromptEmptyServer, "y\n", promptTimeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserCancelEmptyServerSync waits for an empty server prompt and cancels.
|
||||||
|
func UserCancelEmptyServerSync(stdout io.Reader, stdin io.WriteCloser) error {
|
||||||
|
return assert.RespondToPrompt(stdout, stdin, PromptEmptyServer, "n\n", promptTimeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserContent simulates content from the user by writing to stdin.
|
||||||
|
// This is used for piped input where no prompt is shown.
|
||||||
|
func UserContent(stdout io.Reader, stdin io.WriteCloser) error {
|
||||||
longText := `Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
longText := `Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
||||||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.`
|
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.`
|
||||||
|
|
||||||
|
|
@ -249,3 +299,12 @@ func MustGenerateUUID(t *testing.T) string {
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MustOpenDatabase(t *testing.T, dbPath string) *database.DB {
|
||||||
|
db, err := database.Open(dbPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(errors.Wrap(err, "opening database"))
|
||||||
|
}
|
||||||
|
|
||||||
|
return db
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package testutils
|
package testutils
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Package ui provides the user interface for the program
|
// Package ui provides the user interface for the program
|
||||||
|
|
@ -21,7 +18,6 @@ package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -122,7 +118,7 @@ func GetEditorInput(ctx context.DnoteCtx, fpath string) (string, error) {
|
||||||
return "", errors.Wrap(err, "waiting for the editor")
|
return "", errors.Wrap(err, "waiting for the editor")
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := ioutil.ReadFile(fpath)
|
b, err := os.ReadFile(fpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrap(err, "reading the temporary content file")
|
return "", errors.Wrap(err, "reading the temporary content file")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
@ -30,11 +27,7 @@ import (
|
||||||
|
|
||||||
func TestGetTmpContentPath(t *testing.T) {
|
func TestGetTmpContentPath(t *testing.T) {
|
||||||
t.Run("no collision", func(t *testing.T) {
|
t.Run("no collision", func(t *testing.T) {
|
||||||
ctx := context.InitTestCtx(t, context.Paths{
|
ctx := context.InitTestCtx(t)
|
||||||
Data: "../tmp",
|
|
||||||
Cache: "../tmp",
|
|
||||||
}, nil)
|
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
res, err := GetTmpContentPath(ctx)
|
res, err := GetTmpContentPath(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -47,11 +40,7 @@ func TestGetTmpContentPath(t *testing.T) {
|
||||||
|
|
||||||
t.Run("one existing session", func(t *testing.T) {
|
t.Run("one existing session", func(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
ctx := context.InitTestCtx(t, context.Paths{
|
ctx := context.InitTestCtx(t)
|
||||||
Data: "../tmp2",
|
|
||||||
Cache: "../tmp2",
|
|
||||||
}, nil)
|
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
p := fmt.Sprintf("%s/%s", ctx.Paths.Cache, "DNOTE_TMPCONTENT_0.md")
|
p := fmt.Sprintf("%s/%s", ctx.Paths.Cache, "DNOTE_TMPCONTENT_0.md")
|
||||||
if _, err := os.Create(p); err != nil {
|
if _, err := os.Create(p); err != nil {
|
||||||
|
|
@ -71,11 +60,7 @@ func TestGetTmpContentPath(t *testing.T) {
|
||||||
|
|
||||||
t.Run("two existing sessions", func(t *testing.T) {
|
t.Run("two existing sessions", func(t *testing.T) {
|
||||||
// set up
|
// set up
|
||||||
ctx := context.InitTestCtx(t, context.Paths{
|
ctx := context.InitTestCtx(t)
|
||||||
Data: "../tmp3",
|
|
||||||
Cache: "../tmp3",
|
|
||||||
}, nil)
|
|
||||||
defer context.TeardownTestCtx(t, ctx)
|
|
||||||
|
|
||||||
p1 := fmt.Sprintf("%s/%s", ctx.Paths.Cache, "DNOTE_TMPCONTENT_0.md")
|
p1 := fmt.Sprintf("%s/%s", ctx.Paths.Cache, "DNOTE_TMPCONTENT_0.md")
|
||||||
if _, err := os.Create(p1); err != nil {
|
if _, err := os.Create(p1); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
@ -26,6 +23,7 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/dnote/dnote/pkg/cli/log"
|
"github.com/dnote/dnote/pkg/cli/log"
|
||||||
|
"github.com/dnote/dnote/pkg/prompt"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
)
|
)
|
||||||
|
|
@ -73,26 +71,16 @@ func PromptPassword(message string, dest *string) error {
|
||||||
|
|
||||||
// Confirm prompts for user input to confirm a choice
|
// Confirm prompts for user input to confirm a choice
|
||||||
func Confirm(question string, optimistic bool) (bool, error) {
|
func Confirm(question string, optimistic bool) (bool, error) {
|
||||||
var choices string
|
message := prompt.FormatQuestion(question, optimistic)
|
||||||
if optimistic {
|
|
||||||
choices = "(Y/n)"
|
|
||||||
} else {
|
|
||||||
choices = "(y/N)"
|
|
||||||
}
|
|
||||||
|
|
||||||
message := fmt.Sprintf("%s %s", question, choices)
|
// Use log.Askf for colored prompt in CLI
|
||||||
|
log.Askf(message, false)
|
||||||
|
|
||||||
var input string
|
confirmed, err := prompt.ReadYesNo(os.Stdin, optimistic)
|
||||||
if err := PromptInput(message, &input); err != nil {
|
if err != nil {
|
||||||
return false, errors.Wrap(err, "Failed to get user input")
|
return false, errors.Wrap(err, "Failed to get user input")
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmed := input == "y"
|
|
||||||
|
|
||||||
if optimistic {
|
|
||||||
confirmed = confirmed || input == ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return confirmed, nil
|
return confirmed, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,4 +98,4 @@ func ReadStdInput() (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(lines, "\n"), nil
|
return strings.Join(lines, "\n"), nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Monomax Software Pty Ltd
|
/* Copyright 2025 Dnote Authors
|
||||||
*
|
*
|
||||||
* This file is part of Dnote.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Dnote is free software: you can redistribute it and/or modify
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* Dnote is distributed in the hope that it will be useful,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* GNU General Public License for more details.
|
* See the License for the specific language governing permissions and
|
||||||
*
|
* limitations under the License.
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package upgrade
|
package upgrade
|
||||||
|
|
@ -112,6 +109,11 @@ func checkVersion(ctx context.DnoteCtx) error {
|
||||||
|
|
||||||
// Check triggers update if needed
|
// Check triggers update if needed
|
||||||
func Check(ctx context.DnoteCtx) error {
|
func Check(ctx context.DnoteCtx) error {
|
||||||
|
// If upgrade check is not enabled, do not proceed further
|
||||||
|
if !ctx.EnableUpgradeCheck {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
shouldCheck, err := shouldCheckUpdate(ctx)
|
shouldCheck, err := shouldCheckUpdate(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "checking if dnote should check update")
|
return errors.Wrap(err, "checking if dnote should check update")
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue