Skip to content
Merged
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
54 changes: 54 additions & 0 deletions .github/workflows/sync-release-to-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Sync release to main

on:
workflow_run:
workflows: [Release]
types: [completed]
branches: [release]

permissions:
contents: write
pull-requests: write

jobs:
sync:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Check if release is ahead of main
id: check
run: |
git fetch origin main release
AHEAD=$(git rev-list --count origin/main..origin/release)
echo "ahead=$AHEAD" >> $GITHUB_OUTPUT

- name: Create sync PR
if: steps.check.outputs.ahead != '0'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
EXISTING=$(gh pr list --repo ${{ github.repository }} --base main --head release --state open --json number --jq '.[0].number')
if [ -n "$EXISTING" ]; then
echo "Sync PR #$EXISTING already exists"
else
gh pr create \
--repo ${{ github.repository }} \
--base main \
--head release \
--title "chore: sync release to main" \
--body "Automated sync of release tags back to main."
fi

- name: Auto-merge sync PR
if: steps.check.outputs.ahead != '0'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR=$(gh pr list --repo ${{ github.repository }} --base main --head release --state open --json number --jq '.[0].number')
if [ -n "$PR" ]; then
gh pr merge "$PR" --repo ${{ github.repository }} --merge
fi
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"@aws-sdk/credential-providers": "^3.1024.0",
"@smithy/shared-ini-file-loader": "^4.4.7",
"@tigrisdata/iam": "^1.4.1",
"@tigrisdata/storage": "^2.16.2",
"@tigrisdata/storage": "^3.0.0",
"commander": "^14.0.3",
"enquirer": "^2.4.1",
"jose": "^6.2.2",
Expand Down
14 changes: 6 additions & 8 deletions src/lib/access-keys/list.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getIAMConfig } from '@auth/iam.js';
import { listAccessKeys } from '@tigrisdata/iam';
import { failWithError } from '@utils/exit.js';
import { formatOutput, formatPaginatedOutput } from '@utils/format.js';
import { formatPaginatedOutput } from '@utils/format.js';
import {
msg,
printEmpty,
Expand All @@ -17,7 +17,7 @@ export default async function list(options: Record<string, unknown>) {
printStart(context);

const format = getFormat(options);
const { limit, pageToken, isPaginated } = getPaginationOptions(options);
const { limit, pageToken } = getPaginationOptions(options);

const config = await getIAMConfig(context);

Expand Down Expand Up @@ -52,15 +52,13 @@ export default async function list(options: Record<string, unknown>) {

const nextToken = data.paginationToken || undefined;

const output = isPaginated
? formatPaginatedOutput(keys, format!, 'keys', 'key', columns, {
paginationToken: nextToken,
})
: formatOutput(keys, format!, 'keys', 'key', columns);
const output = formatPaginatedOutput(keys, format!, 'keys', 'key', columns, {
paginationToken: nextToken,
});

console.log(output);

if (isPaginated && format !== 'json' && format !== 'xml') {
if (format !== 'json' && format !== 'xml') {
printPaginationHint(nextToken);
}

Expand Down
24 changes: 15 additions & 9 deletions src/lib/buckets/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default async function list(options: Record<string, unknown>) {
}

const { data, error } = await listBuckets({
...(forksOf || !isPaginated
...(forksOf
? {}
: {
...(limit !== undefined ? { limit } : {}),
Expand Down Expand Up @@ -57,7 +57,7 @@ export default async function list(options: Record<string, unknown>) {
failWithError(context, infoError);
}

if (!bucketInfo.hasForks) {
if (!bucketInfo.forkInfo?.hasChildren) {
printEmpty(context);
return;
}
Expand All @@ -67,7 +67,10 @@ export default async function list(options: Record<string, unknown>) {
for (const bucket of data.buckets) {
if (bucket.name === forksOf) continue;
const { data: info } = await getBucketInfo(bucket.name, { config });
if (info?.sourceBucketName === forksOf) {
const isChildOf = info?.forkInfo?.parents?.some(
(p) => p.bucketName === forksOf
);
if (isChildOf) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent JSON output format for fork list commands

Medium Severity

The --forks-of path in buckets list and the forks list command still use formatOutput, which outputs a raw JSON array. Every other list command was migrated to formatPaginatedOutput, which wraps results in { "items": [...] }. This means buckets list --format json returns { "items": [...] } but buckets list --forks-of X --format json returns [...], creating an inconsistent JSON contract from the same command depending on flags.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7226291. Configure here.

forks.push({ name: bucket.name, created: bucket.creationDate });
}
}
Expand Down Expand Up @@ -99,15 +102,18 @@ export default async function list(options: Record<string, unknown>) {

const nextToken = data.paginationToken || undefined;

const output = isPaginated
? formatPaginatedOutput(buckets, format!, 'buckets', 'bucket', columns, {
paginationToken: nextToken,
})
: formatOutput(buckets, format!, 'buckets', 'bucket', columns);
const output = formatPaginatedOutput(
buckets,
format!,
'buckets',
'bucket',
columns,
{ paginationToken: nextToken }
);

console.log(output);

if (isPaginated && format !== 'json' && format !== 'xml') {
if (format !== 'json' && format !== 'xml') {
printPaginationHint(nextToken);
}

Expand Down
7 changes: 5 additions & 2 deletions src/lib/forks/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default async function list(options: Record<string, unknown>) {
failWithError(context, infoError);
}

if (!bucketInfo.hasForks) {
if (!bucketInfo.forkInfo?.hasChildren) {
printEmpty(context);
return;
}
Expand All @@ -47,7 +47,10 @@ export default async function list(options: Record<string, unknown>) {
if (bucket.name === name) continue;

const { data: info } = await getBucketInfo(bucket.name, { config });
if (info?.sourceBucketName === name) {
const isChildOf = info?.forkInfo?.parents?.some(
(p) => p.bucketName === name
);
if (isChildOf) {
forks.push({
name: bucket.name,
created: bucket.creationDate,
Expand Down
19 changes: 11 additions & 8 deletions src/lib/iam/policies/list.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getOAuthIAMConfig } from '@auth/iam.js';
import { listPolicies } from '@tigrisdata/iam';
import { failWithError } from '@utils/exit.js';
import { formatOutput, formatPaginatedOutput } from '@utils/format.js';
import { formatPaginatedOutput } from '@utils/format.js';
import {
msg,
printEmpty,
Expand All @@ -17,7 +17,7 @@ export default async function list(options: Record<string, unknown>) {
printStart(context);

const format = getFormat(options);
const { limit, pageToken, isPaginated } = getPaginationOptions(options);
const { limit, pageToken } = getPaginationOptions(options);

const iamConfig = await getOAuthIAMConfig(context);

Expand Down Expand Up @@ -62,15 +62,18 @@ export default async function list(options: Record<string, unknown>) {

const nextToken = data.paginationToken || undefined;

const output = isPaginated
? formatPaginatedOutput(policies, format!, 'policies', 'policy', columns, {
paginationToken: nextToken,
})
: formatOutput(policies, format!, 'policies', 'policy', columns);
const output = formatPaginatedOutput(
policies,
format!,
'policies',
'policy',
columns,
{ paginationToken: nextToken }
);

console.log(output);

if (isPaginated && format !== 'json' && format !== 'xml') {
if (format !== 'json' && format !== 'xml') {
printPaginationHint(nextToken);
}

Expand Down
53 changes: 46 additions & 7 deletions src/lib/ls.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { getStorageConfig } from '@auth/provider.js';
import { list, listBuckets } from '@tigrisdata/storage';
import { exitWithError } from '@utils/exit.js';
import { formatOutput, formatSize } from '@utils/format.js';
import { getFormat, getOption } from '@utils/options.js';
import { formatPaginatedOutput, formatSize } from '@utils/format.js';
import { printPaginationHint } from '@utils/messages.js';
import { getFormat, getOption, getPaginationOptions } from '@utils/options.js';
import { parseAnyPath } from '@utils/path.js';

export default async function ls(options: Record<string, unknown>) {
Expand All @@ -13,11 +14,16 @@ export default async function ls(options: Record<string, unknown>) {
'snapshot',
]);
const format = getFormat(options);
const { limit, pageToken } = getPaginationOptions(options);

if (!pathString) {
// No path provided, list all buckets
const config = await getStorageConfig();
const { data, error } = await listBuckets({ config });
const { data, error } = await listBuckets({
...(limit !== undefined ? { limit } : {}),
...(pageToken ? { paginationToken: pageToken } : {}),
config,
});

if (error) {
exitWithError(error);
Expand All @@ -28,12 +34,28 @@ export default async function ls(options: Record<string, unknown>) {
created: bucket.creationDate,
}));

const output = formatOutput(buckets, format!, 'buckets', 'bucket', [
const columns = [
{ key: 'name', header: 'Name' },
{ key: 'created', header: 'Created' },
]);
];

const nextToken = data.paginationToken || undefined;

const output = formatPaginatedOutput(
buckets,
format!,
'buckets',
'bucket',
columns,
{ paginationToken: nextToken }
);

console.log(output);

if (format !== 'json' && format !== 'xml') {
printPaginationHint(nextToken);
}

return;
}

Expand All @@ -51,6 +73,8 @@ export default async function ls(options: Record<string, unknown>) {
const { data, error } = await list({
prefix,
...(snapshotVersion ? { snapshotVersion } : {}),
...(limit !== undefined ? { limit } : {}),
...(pageToken ? { paginationToken: pageToken } : {}),
config: {
...config,
bucket,
Expand Down Expand Up @@ -84,11 +108,26 @@ export default async function ls(options: Record<string, unknown>) {
item.key !== '' && arr.findIndex((i) => i.key === item.key) === index
);

const output = formatOutput(objects, format!, 'objects', 'object', [
const columns = [
{ key: 'key', header: 'Key' },
{ key: 'size', header: 'Size' },
{ key: 'modified', header: 'Modified' },
]);
];

const nextToken = data.paginationToken || undefined;

const output = formatPaginatedOutput(
objects,
format!,
'objects',
'object',
columns,
{ paginationToken: nextToken }
);

console.log(output);

if (format !== 'json' && format !== 'xml') {
printPaginationHint(nextToken);
}
}
23 changes: 11 additions & 12 deletions src/lib/objects/list.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { getStorageConfig } from '@auth/provider.js';
import { list } from '@tigrisdata/storage';
import { failWithError } from '@utils/exit.js';
import {
formatOutput,
formatPaginatedOutput,
formatSize,
} from '@utils/format.js';
import { formatPaginatedOutput, formatSize } from '@utils/format.js';
import {
msg,
printEmpty,
Expand All @@ -29,7 +25,7 @@ export default async function listObjects(options: Record<string, unknown>) {
'snapshotVersion',
'snapshot',
]);
const { limit, pageToken, isPaginated } = getPaginationOptions(options);
const { limit, pageToken } = getPaginationOptions(options);

if (!bucketArg) {
failWithError(context, 'Bucket name is required');
Expand Down Expand Up @@ -75,15 +71,18 @@ export default async function listObjects(options: Record<string, unknown>) {

const nextToken = data.paginationToken || undefined;

const output = isPaginated
? formatPaginatedOutput(objects, format!, 'objects', 'object', columns, {
paginationToken: nextToken,
})
: formatOutput(objects, format!, 'objects', 'object', columns);
const output = formatPaginatedOutput(
objects,
format!,
'objects',
'object',
columns,
{ paginationToken: nextToken }
);

console.log(output);

if (isPaginated && format !== 'json' && format !== 'xml') {
if (format !== 'json' && format !== 'xml') {
printPaginationHint(nextToken);
}

Expand Down
Loading
Loading