Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
DevOps committed Jun 19, 2023
2 parents 05635d9 + 0cf7b85 commit 2f2d5db
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 666 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CasualOS Changelog

## V3.1.33

#### Date: 6/19/2023

### :rocket: Improvements

- Removed unused DynamoDB tables from the backend.

## V3.1.32

#### Date: 6/17/2023
Expand Down
9 changes: 0 additions & 9 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ services:
restart: always
ports:
- '6379:6379'
dynamodb:
command: '-jar DynamoDBLocal.jar -sharedDb -dbPath ./data'
image: 'amazon/dynamodb-local:latest'
restart: always
ports:
- '9125:8000'
volumes:
- './services/data/dynamodb:/home/dynamodblocal/data'
working_dir: /home/dynamodblocal
s3:
image: localstack/localstack:latest
environment:
Expand Down
3 changes: 0 additions & 3 deletions src/aux-auth/scripts/auth-configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ function createConfigs(dev, version) {
define: {
...versionVariables,
...developmentVariables,
DYNAMODB_ENDPOINT: dev
? JSON.stringify('http://dynamodb:8000')
: JSON.stringify(undefined),
S3_ENDPOINT: dev
? JSON.stringify('http://s3:4566')
: JSON.stringify(undefined),
Expand Down
169 changes: 0 additions & 169 deletions src/aux-auth/scripts/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,16 @@ AWS.config.update({
secretAccessKey: 'xxxx',
});

const ddb = new AWS.DynamoDB({
endpoint: 'http://localhost:9125',
apiVersion: '2012-08-10',
});

const s3 = new AWS.S3({
endpoint: 'http://localhost:4566',
apiVersion: '2006-03-01',
s3ForcePathStyle: true,
});

// See env.json
const USERS_TABLE = 'Users';
const USER_ADDRESSES_TABLE = 'UserAddresses';
const LOGIN_REQUESTS_TABLE = 'LoginRequests';
const SESSIONS_TABLE = 'Sessions';
const RECORDS_TABLE = 'Records';
const EMAIL_TABLE = 'EmailRules';
const SMS_TABLE = 'SmsRules';
const PUBLIC_RECORDS_TABLE = 'PublicRecords';
const PUBLIC_RECORDS_KEYS_TABLE = 'PublicRecordsKeys';
const DATA_TABLE = 'Data';
const MANUAL_DATA_TABLE = 'ManualData';
const FILES_TABLE = 'Files';
const FILES_BUCKET = 'files-bucket';
const EVENTS_TABLE = 'Events';

async function start() {
const tablesResult = await ddb.listTables({}).promise();
const reset = process.argv.includes('--reset');

const templateSrc = readFileSync(
Expand All @@ -49,133 +30,7 @@ async function start() {
);
const template = YAML.parseDocument(templateSrc).toJSON();

await createOrUpdateTable(
tablesResult,
USERS_TABLE,
reset,
template.Resources.UsersTable.Properties
);
await createOrUpdateTable(
tablesResult,
USER_ADDRESSES_TABLE,
reset,
template.Resources.UserAddressesTable.Properties
);
await createOrUpdateTable(
tablesResult,
RECORDS_TABLE,
reset,
template.Resources.RecordsTable.Properties
);
await createOrUpdateTable(
tablesResult,
EMAIL_TABLE,
reset,
template.Resources.EmailRulesTable.Properties
);

await ddb
.putItem({
TableName: EMAIL_TABLE,
Item: {
id: { S: 'deny_test' },
type: { S: 'deny' },
pattern: { S: '^test@casualsimulation\\.org$' },
},
})
.promise();

await ddb
.putItem({
TableName: EMAIL_TABLE,
Item: {
id: { S: 'allow_casualsim' },
type: { S: 'allow' },
pattern: { S: '@casualsimulation\\.org$' },
},
})
.promise();

await createOrUpdateTable(
tablesResult,
SMS_TABLE,
reset,
template.Resources.SmsRulesTable.Properties
);

await ddb
.putItem({
TableName: SMS_TABLE,
Item: {
id: { S: 'deny_test' },
type: { S: 'deny' },
pattern: { S: '^\\+1999' },
},
})
.promise();

await ddb
.putItem({
TableName: SMS_TABLE,
Item: {
id: { S: 'allow_usa' },
type: { S: 'allow' },
pattern: { S: '^\\+1' },
},
})
.promise();

await createOrUpdateTable(
tablesResult,
PUBLIC_RECORDS_TABLE,
reset,
template.Resources.PublicRecordsTable.Properties
);
await createOrUpdateTable(
tablesResult,
PUBLIC_RECORDS_KEYS_TABLE,
reset,
template.Resources.PublicRecordsKeysTable.Properties
);
await createOrUpdateTable(
tablesResult,
DATA_TABLE,
reset,
template.Resources.DataTable.Properties
);
await createOrUpdateTable(
tablesResult,
MANUAL_DATA_TABLE,
reset,
template.Resources.ManualDataTable.Properties
);
await createOrUpdateTable(
tablesResult,
FILES_TABLE,
reset,
template.Resources.FilesTable.Properties
);

await createS3Buckets(reset);

await createOrUpdateTable(
tablesResult,
EVENTS_TABLE,
reset,
template.Resources.EventsTable.Properties
);
await createOrUpdateTable(
tablesResult,
LOGIN_REQUESTS_TABLE,
reset,
template.Resources.LoginRequestsTable.Properties
);
await createOrUpdateTable(
tablesResult,
SESSIONS_TABLE,
reset,
template.Resources.SessionsTable.Properties
);
}

start().then(
Expand Down Expand Up @@ -252,27 +107,3 @@ async function deleteBucket(bucketName) {
})
.promise();
}

async function createOrUpdateTable(tables, tableName, reset, params) {
const hasTable = tables.TableNames.includes(tableName);
if (!hasTable || reset) {
if (hasTable) {
console.log(`Deleting ${tableName} Table`);
await ddb
.deleteTable({
TableName: tableName,
})
.promise();
}

console.log(`Creating ${tableName} Table`);
await ddb
.createTable({
TableName: tableName,
...params,
})
.promise();
} else {
console.log(`${tableName} Table already exists`);
}
}
Loading

0 comments on commit 2f2d5db

Please sign in to comment.