Skip to content

Commit

Permalink
Loosen validation requirements for dropped indices (#69)
Browse files Browse the repository at this point in the history
Motivation
----------
We shouldn't require the index definition details for indices being
dropped.

Modifications
-------------
Accept dropped indices with only a name attribute.

Update to NPM lockfile v2.

Improve some local test scripts.

Fixes #67
  • Loading branch information
brantburnett authored Aug 10, 2021
1 parent 82e5c8d commit 42691aa
Show file tree
Hide file tree
Showing 6 changed files with 10,376 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: required
language: node_js
node_js:
- "12"
- "14"
services:
- docker
before_script:
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
FROM node:12 as build
FROM node:14 as build

RUN npm install -g npm@7.19.1
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY ./ ./
RUN npm run-script lint && \
npm run-script build

FROM node:12
FROM node:14
LABEL maintainer=bburnett@centeredgesoftware.com
WORKDIR /app
COPY --from=build /app ./

RUN ["ln", "-s", "/app/bin/couchbase-index-manager", "/bin/couchbase-index-manager"]
ENTRYPOINT ["/app/bin/couchbase-index-manager"]
9 changes: 6 additions & 3 deletions app/index-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ export const IndexValidators = {
},
post_validate: function() {
if (!this.is_primary) {
if (!this.index_key || this.index_key.length === 0) {
const isDrop = this.lifecycle && this.lifecycle.drop;
console.log(`isDrop ${this.name}: ${isDrop}`);

if (!isDrop && (!this.index_key || this.index_key.length === 0)) {
throw new Error('index_key must include at least one key');
}
} else {
Expand Down Expand Up @@ -524,8 +527,8 @@ export class IndexDefinition extends IndexDefinitionBase {
* @param {IndexManager} manager
*/
async normalize(manager) {
if (this.is_primary) {
// Not required for primary index
if (this.is_primary || (this.lifecycle && this.lifecycle.drop)) {
// Not required for primary index or drops
return;
}

Expand Down
2 changes: 1 addition & 1 deletion env/Up.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Param(
[string]
[Parameter(Position=0)]
$Version = "4.6.4"
$Version = "6.5.1"
)

if ($Version -match "^(\d+\.)*\d+$") {
Expand Down
4 changes: 4 additions & 0 deletions example/beer-sample/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ name: sg_roleAccess_x1
index_key:
- (all (array (`op`.`name`) for `op` in object_pairs((((meta().`xattrs`).`_sync`).`role_access`)) end))
retain_deleted_xattr: false
---
name: oldIndex
lifecycle:
drop: true
Loading

0 comments on commit 42691aa

Please sign in to comment.