-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add support for connector upgrades #51
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
FROM node:20-alpine | ||
ARG CONNECTOR_VERSION | ||
|
||
RUN apk add jq curl | ||
|
||
COPY /docker /scripts | ||
RUN : "${CONNECTOR_VERSION:?Connector version must be set}" | ||
RUN echo ${CONNECTOR_VERSION} > /scripts/CONNECTOR_VERSION | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we bake in the version. |
||
|
||
COPY /functions /functions | ||
RUN /scripts/package-restore.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env sh | ||
set -eu -o pipefail | ||
|
||
connector_path="${HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH:-/functions}" | ||
target_connector_version="$(cat /scripts/CONNECTOR_VERSION)" | ||
|
||
cd "$connector_path" | ||
|
||
set +e | ||
existing_connector_version=$(jq '.dependencies["@hasura/ndc-lambda-sdk"]' -r package.json) | ||
exit_status=$? | ||
if [ $exit_status -ne 0 ]; then | ||
echo "Unable to read the @hasura/ndc-lambda-sdk version from your package.json" | ||
echo "Please manually upgrade the @hasura/ndc-lambda-sdk package in your package.json to version $target_connector_version" | ||
exit 1 | ||
fi | ||
|
||
if [ $existing_connector_version = "null" ]; then | ||
# This is very strange, their package.json must have the SDK installed but doesn't | ||
# We'll roll with it and just install the package | ||
echo "Missing the @hasura/ndc-lambda-sdk package in your package.json. Installing version $target_connector_version" | ||
else | ||
echo "Upgrading @hasura/ndc-lambda-sdk package from version $existing_connector_version to version $target_connector_version" | ||
fi | ||
|
||
# We do a --package-lock-only because we don't want to change the node_modules directory. | ||
# This is because the existing node_modules directory may have been installed on a | ||
# different platform since it is being volume mounted into a Linux container | ||
npm install "@hasura/ndc-lambda-sdk@$target_connector_version" --save-exact --no-update-notifier --package-lock-only | ||
exit_status=$? | ||
set -e | ||
|
||
if [ $exit_status -ne 0 ]; then | ||
echo "Failed to upgrade @hasura/ndc-lambda-sdk package to version $target_connector_version" | ||
echo "Please manually upgrade the @hasura/ndc-lambda-sdk package in your package.json to version $target_connector_version" | ||
exit 1 | ||
fi | ||
|
||
echo "Successfully upgraded @hasura/ndc-lambda-sdk package to version $target_connector_version" | ||
echo "You may need to run 'npm install' to install the new dependencies locally" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the version of? The
npm
binary itself?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or does this return the version field from
package.json
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets the version field from package.json.