Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remote S3 support #1284

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions app/apollo/models/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ const CHANNEL_CONSTANTS = {
TYPES: {
GITHUB: 'github',
GITLAB: 'gitlab',
/*S3: 's3',*/ // Not yet supported, set EXPERIMENTAL_REMOTE_S3 env var to experiment
},
},
};

const MAX_REMOTE_PARAMETERS_LENGTH = process.env.REMOTE_PARAMETERS_LENGTH_LIMIT || 1000;

// console.log('NODE_ENV: ' + config.util.getEnv('NODE_ENV') + `, DIRECTIVE_LIMITS: ${JSON.stringify(DIRECTIVE_LIMITS)}`);
Expand Down
1 change: 1 addition & 0 deletions app/apollo/resolvers/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ const channelResolvers = {
}

// Validate remote.remoteType
if( process.env.EXPERIMENTAL_REMOTE_S3 ) CHANNEL_CONSTANTS.REMOTE.TYPES.S3 = 's3';
if( !remote.remoteType || !Object.values(CHANNEL_CONSTANTS.REMOTE.TYPES).includes( remote.remoteType ) ) {
throw new RazeeValidationError( context.req.t( 'The remote type {{remoteType}} is not valid. Allowed values: [{{remoteTypes}}]', { remoteType: remote.remoteType, 'remoteTypes': Array.from( Object.values(CHANNEL_CONSTANTS.REMOTE.TYPES) ).join(' ') } ), context );
}
Expand Down
33 changes: 33 additions & 0 deletions app/apollo/test/channel.remote.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ describe('channel remote graphql test suite', () => {
before(async () => {
console.log( 'Setting EXPERIMENTAL env vars' ); // IMPORTANT: Must be deleted in 'after()' to avoid impacting other tests that do not expect these vars to be set.
process.env.EXPERIMENTAL_GITOPS_ALT = 'true';
process.env.EXPERIMENTAL_REMOTE_S3 = 'true';

mongoServer = new MongoMemoryServer( { binary: { version: '4.2.17' } } );
await mongoServer.start();
Expand All @@ -128,6 +129,7 @@ describe('channel remote graphql test suite', () => {

console.log( 'Deleting EXPERIMENTAL env vars' );
delete process.env.EXPERIMENTAL_GITOPS_ALT;
delete process.env.EXPERIMENTAL_REMOTE_S3;
}); // after

it('add a remote channel of remoteType github with a remote parameter', async () => {
Expand Down Expand Up @@ -755,4 +757,35 @@ describe('channel remote graphql test suite', () => {
}
});

it('add a remote channel of remoteType s3 with a remote parameter', async () => {
try {
const result = await channelRemoteApi.addRemoteChannel(userRootToken, {
orgId: org01._id,
name: 's3ChannelName',
contentType: 'remote',
remote: {
remoteType: 's3',
parameters: [
{
key: 'url',
value: 'dummy-s3-url',
},
],
},
});
console.log( `addRemoteChannel result: ${JSON.stringify( result.data, null, 2 )}` );
const addChannel = result.data.data.addChannel;

expect(addChannel.uuid).to.be.an('string');

console.log( `channel (remoteType: s3) created: ${channel01Uuid}` );
} catch (error) {
if (error.response) {
console.error('error encountered: ', error.response.data);
} else {
console.error('error encountered: ', error);
}
throw error;
}
});
});
7 changes: 4 additions & 3 deletions local-dev/api/configCreateRemote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ if [ "$0" = "$BASH_SOURCE" ]; then
fi

export RAZEE_CONFIG_NAME=${1:-pConfigName}
RAZEE_ORG_ID=${2:-${RAZEE_ORG_ID:-pOrgId}}
RAZEE_REMOTE_TYPE=${2:-github}
RAZEE_ORG_ID=${3:-${RAZEE_ORG_ID:-pOrgId}}

RAZEE_QUERY='mutation ($orgId: String!, $name: String!, $contentType: String, $remote: ChannelRemoteInput) { addChannel(orgId: $orgId, name: $name, contentType: $contentType, remote: $remote) { uuid } }'
RAZEE_VARIABLES='{"name":"'"${RAZEE_CONFIG_NAME}"'","orgId":"'"${RAZEE_ORG_ID}"'","contentType":"'"remote"'","remote":{"remoteType":"'"github"'","parameters":[{"key":"'"k1"'", "value":"'"v1"'"}]}}'
RAZEE_VARIABLES='{"name":"'"${RAZEE_CONFIG_NAME}"'","orgId":"'"${RAZEE_ORG_ID}"'","contentType":"'"remote"'","remote":{"remoteType":"'"${RAZEE_REMOTE_TYPE}"'","parameters":[{"key":"'"k1"'", "value":"'"v1"'"}]}}'

echo "" && echo "CREATE config by name (contentType: remote)"
echo "" && echo "CREATE config by name (contentType: remote, remoteType: ${RAZEE_REMOTE_TYPE})"
unset RAZEE_CONFIG_UUID
unset RAZEE_CONFIG_NAME
RESPONSE=$(${SCRIPT_DIR}/graphqlPost.sh "${RAZEE_QUERY}" "${RAZEE_VARIABLES}")
Expand Down