Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zwiterrion committed Dec 5, 2023
1 parent 76779b3 commit 17737be
Show file tree
Hide file tree
Showing 16 changed files with 119 additions and 125 deletions.
1 change: 1 addition & 0 deletions . dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
server/.env
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
server/.env
2 changes: 0 additions & 2 deletions cli/src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ async fn run_docker_container(container_name: &String) -> WasmoResult<u16> {
"AUTH_MODE=NO_AUTH",
"-e",
&format!("MANAGER_ALLOWED_DOMAINS=localhost:5001,localhost:{}", port),
"-e",
"STORAGE=LOCAL",
"maif/wasmo",
])
.stdout(Stdio::piped())
Expand Down
13 changes: 2 additions & 11 deletions docs/documentation/app/builder/environment-variables/_page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Wasmo Builder is fully configurable and the only way to configure it is to use t
- [Using the CLI](#using-the-cli)
- [Miscellaneous](#miscellaneous)

## Storage <Badges values={['STOS3', 'DOCKER_S3', 'LOCAL']} raw />
## Storage <Badges values={['S3', 'DOCKER_S3']} raw />

Wasmo Builder can be run on three differents ways:

Expand All @@ -30,17 +30,8 @@ AWS_DEFAULT_REGION=<DEFAULT 'us-east-1'>
# optional
S3_FORCE_PATH_STYLE=<DEFAULT false>
```
- `STORAGE=LOCAL`: Use the filesystem to store generated Wasm binaries. The Builder UI is not available with this storage type. You should use this
storage if you want to quickly start an instance and only use the Wasmo CLI. The `local` storage
involves setting an interval to the cleanup job. The job removes binaries with outdated dates.
```
# required
STORAGE=LOCAL
# optional
LOCAL_WASM_JOB_CLEANING=<DEFAULT 60 * 60 * 1000> # 1 hour
```

Expand Down Expand Up @@ -85,7 +76,7 @@ AUTH_MODE=NO_AUTH | BASIC_AUTH | OTOROSHI_AUTH
# Listening PORT
PORT= <DEFAULT '5001'>
# Storage used
STORAGE= <DEFAULT 'LOCAL'>
STORAGE=
# S3
# Specifies an access key associated with your S3 instance
Expand Down
6 changes: 3 additions & 3 deletions server/configuration.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const STORAGE = {
S3: "S3",
DOCKER_S3: 'DOCKER_S3',
LOCAL: "LOCAL",
DOCKER_S3: 'DOCKER_S3'
};

const AUTHENTICATION = {
Expand All @@ -15,7 +14,7 @@ module.exports = {
AUTHENTICATION,
ENV: {
PORT: process.env.MANAGER_PORT || 5001,
STORAGE: process.env.STORAGE || STORAGE.LOCAL,
STORAGE: process.env.STORAGE,

// process.env.AWS_ACCESS_KEY_ID,
// process.env.AWS_SECRET_ACCESS_KEY,
Expand All @@ -31,6 +30,7 @@ module.exports = {
MANAGER_TEMPLATES: process.env.MANAGER_TEMPLATES,
MANAGER_MAX_PARALLEL_JOBS: process.env.MANAGER_MAX_PARALLEL_JOBS || 2,
MANAGER_ALLOWED_DOMAINS: process.env.MANAGER_ALLOWED_DOMAINS || 'localhost:5001',
CHECK_DOMAINS: process.env.CHECK_DOMAINS,

AUTH_MODE: process.env.AUTH_MODE || AUTHENTICATION.NO_AUTH,

Expand Down
40 changes: 23 additions & 17 deletions server/datastores/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,40 @@ module.exports = class Datastore {
/**
* Get current user
*/
getUser(email) { console.log('getUser') }
getUser(email) { return Promise.resolve() }
/**
* Get plugins of user
* @returns {Object[]}
*/
getUserPlugins(email) { console.log('getUserPlugins') }
getUserPlugins(email) { return Promise.resolve() }
/**
* register a new user if not present
* @param {string} email
*/
createUserIfNotExists(email) { console.log('createUserIfNotExists') }
createUserIfNotExists(email) { return Promise.resolve() }
/**
* Get user list
*/
getUsers() { console.log('getUsers') }
getUsers() { return Promise.resolve([]) }
/**
* Update a specific user with new content
* @param {string} email
* @param {JSON} content
*/
updateUser(email, content) { console.log('updateUser') }
updateUser(email, content) { return Promise.resolve() }

/**
* Save wasm file
* @param {string} wasmFolder
*/
putWasmFileToS3(wasmFolder) { console.log('putWasmFileToS3') }
putWasmFileToS3(wasmFolder) { return Promise.resolve() }

/**
* Save logs file
* @param {string} logId
* @param {string} logsFolder
*/
putBuildLogsToS3(logId, logsFolder) { }
putBuildLogsToS3(logId, logsFolder) { return Promise.resolve() }

/**
* Save plugin information after build process
Expand All @@ -49,68 +49,74 @@ module.exports = class Datastore {
* @param {string} newHash
* @param {string} generateWasmName
*/
putWasmInformationsToS3(email, pluginId, newHash, generateWasmName) { }
putWasmInformationsToS3(email, pluginId, newHash, generateWasmName) { return Promise.resolve() }

/**
* Fetch wasm from datastore
* @param {string} wasmId
*/
getWasm(wasmId) { console.log('getWasm') }
getWasm(wasmId) { return Promise.resolve() }

/**
* Run and return execution of wasm file
* @param {string} wasmId
* @param {JSON} runOptions
*/
runWasm(wasmId, runOptions) { console.log('runWasm') }
runWasm(wasmId, runOptions) { return Promise.resolve() }

/**
* Check the presence of a specific wasm in database
* @param {string} wasmId
* @param {boolean} release
*/
isWasmExists(wasmId, release) { console.log('isWasmExists') }
isWasmExists(wasmId, release) {
return Promise.resolve()
}

/**
* Fetch plugin sources
* @param {string} pluginId
* @returns sources as buffer
*/
getSources = pluginId => console.log('getSources')
getSources = pluginId => {
return Promise.resolve()
}

/**
* Fetch configuration file
* @param {string} email
* @param {string} pluginId
*/
getConfigurations = (email, pluginId) => console.log('getConfigurations')
getConfigurations = (email, pluginId) => {
return Promise.resolve()
}

/**
* Delete specific plugin
* @param {string} email
* @param {string} pluginId
*/
deletePlugin = (email, pluginId) => console.log('deletePlugin');
deletePlugin = (email, pluginId) => Promise.resolve()

/**
* Update plugin content
* @param {string} id
* @param {JSON} body
*/
updatePlugin = (id, body) => console.log('updatePlugin');
updatePlugin = (id, body) => Promise.resolve()

/**
* Create plugin with name and version of specific type
* @param {string} email
* @param {JSON} metadata
*/
createEmptyPlugin = (email, metadata, isGithub) => console.log('createEmptyPlugin')
createEmptyPlugin = (email, metadata, isGithub) => Promise.resolve()

/**
* Edit the plugin name
* @param {string} email
* @param {string} pluginId
* @param {string} newName
*/
patchPluginName = (email, pluginId, newName) => console.log('patchPluginName')
patchPluginName = (email, pluginId, newName) => Promise.resolve()
};
4 changes: 2 additions & 2 deletions server/datastores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ let datastore;

if ([STORAGE.S3, STORAGE.DOCKER_S3].includes(ENV.STORAGE)) {
datastore = new S3Datastore();
} else if (ENV.STORAGE === STORAGE.LOCAL) {

} else {
datastore = new Datastore()
}

/** @type {Datastore} */
Expand Down
Loading

0 comments on commit 17737be

Please sign in to comment.