Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/papi.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,12 @@ function searchFilter(params, schema) {
}
} else {
if (name !== 'owner_uuids') {
constraint = '(' + name + '=' + esc(value) + ')';
if (value.toString().charAt(0) === '~') {
value = value.toString().substr(1, value.toString().length);
constraint = '(' + name + '=' + esc(value) + '*)';
} else {
constraint = '(' + name + '=' + esc(value) + ')';
}
} else {
constraint = '(|(' + name + '=' + esc(value) +
')(!(owner_uuids=*)))';
Expand Down
8 changes: 8 additions & 0 deletions test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,15 @@ test('GET /packages (Search by name)', function (t) {
searchAndCheckPkgs(t, query, testFilter);
});

test('GET /packages (Search by substring name)', function (t) {
var query = '/packages?name=~api_test';

var testFilter = function (p) {
return /^api_test_/.test(p.name);
};

searchAndCheckPkgs(t, query, testFilter);
});

test('GET /packages (Search by wildcard)', function (t) {
var query = '/packages?name=api_test_*';
Expand Down
51 changes: 51 additions & 0 deletions tools/rsync-to
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

#
# Copyright (c) 2015, Joyent, Inc.
#

#
# Rsync the master in this working copy to the install on the given HN.
#

#set -o xtrace
set -o errexit

TOP=$(cd $(dirname $0)/../; pwd)
NODE="root@$1"

if [[ -z "$PAPI_ZONE" ]]; then
PAPI_ZONE=$(ssh $NODE "vmadm lookup -1 alias=papi0" 2>/dev/null)
fi
echo "PAPI_ZONE: $PAPI_ZONE"

extraOpts=
if [[ $(uname -s) != "SunOS" ]]; then
extraOpts="--exclude *.node --exclude build"
else
# Clean node_modules everytime.
ssh $NODE rm -rf /zones/$PAPI_ZONE/root/opt/smartdc/papi/node_modules
fi

rsync -av ${TOP}/ \
$NODE:/zones/$PAPI_ZONE/root/opt/smartdc/papi/ \
$extraOpts \
--exclude .git/ \
--exclude /config.json \
--exclude /deps/ \
--exclude /doc/ \
--exclude /tools/ \
--exclude /tmp/ \

state=$(ssh ${NODE} svcs -z ${PAPI_ZONE} -H -o state papi)
if [[ "$state" == "maintenance" ]]; then
ssh ${NODE} svcadm -z ${PAPI_ZONE} clear papi
else
ssh ${NODE} svcadm -z ${PAPI_ZONE} restart papi
fi