Skip to content

Added volume_cifs_share_create#267

Open
kcantrel wants to merge 3 commits intomainfrom
add_create_cifs_share
Open

Added volume_cifs_share_create#267
kcantrel wants to merge 3 commits intomainfrom
add_create_cifs_share

Conversation

@kcantrel
Copy link
Collaborator

No description provided.

@kcantrel kcantrel requested a review from Copilot February 11, 2026 21:49
@github-actions
Copy link
Contributor

github-actions bot commented Feb 11, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

Management-Utilities/Workload-Factory-API-Samples/wf_utils:136

  • run_curl now supports PATCH, but the function header comment/documentation still lists only GET/POST/PUT/DELETE. Please update the documented supported methods (and parameter description for data payload) to match the new behavior so callers don’t miss that PATCH is valid.
    POST|PUT|PATCH)
      curl -X "$method" -sw "%{http_code},%{errormsg}" "$url" \
         -H "Accept: $accept" "${extraHeaders[@]}" \
         -H "Content-Type:application/json" \
         -H "Authorization: Bearer $token" --data "$data" -o $output > $errorOutput

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#
# Declare an array of required options and the error message to display if they are not set.
declare -A required_options
required_options["REFRESH_TOKEN"]='Error: A BlueXP refresh tokon is required to run this script. It can be obtain from this web page:
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

Typo in required option error message: "refresh tokon" should be "refresh token".

Suggested change
required_options["REFRESH_TOKEN"]='Error: A BlueXP refresh tokon is required to run this script. It can be obtain from this web page:
required_options["REFRESH_TOKEN"]='Error: A BlueXP refresh token is required to run this script. It can be obtain from this web page:

Copilot uses AI. Check for mistakes.
required_options["BLUEXP_ACCOUNT_ID"]='Error: A BlueXP account ID is required to run this script.
You can get the list of accounts you have access to by running the "list_bluexp_accts" script
found in this GitHub repository: https://github.com/NetApp/FSx-ONTAP-samples-scripts/tree/main/Management-Utilities/Workload-Factory-API-Samples\n\n'
required_options["CREDENTIALS_ID"]='Error: The ID of the credentials to delete is required.
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

The CREDENTIALS_ID missing-parameter message says "credentials to delete", which doesn’t match this script’s purpose (creating a CIFS share) and could confuse users. Please reword it to describe the credentials ID needed to perform the API call (e.g., the Workload Factory credentials ID for the AWS account).

Suggested change
required_options["CREDENTIALS_ID"]='Error: The ID of the credentials to delete is required.
required_options["CREDENTIALS_ID"]='Error: The Workload Factory credentials ID for the AWS account is required to run this script.

Copilot uses AI. Check for mistakes.
Comment on lines +120 to +126
cifsShares=$(jq -r '.cifsShares' $tmpout)
#
# Create a new share definition.
newShare='{"name":"'$CIFS_SHARE_NAME'","path":"'/$CIFS_SHARE_NAME'","acls":[{"userOrGroup":"Everyone","permission":"full_control","type":"windows"}]}'
#
# Add the new share to the existing ones.
cifsShares=$(echo "$cifsShares" | jq -r '. += ['$newShare']')
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

If the volume currently has no CIFS shares, .cifsShares may be null/missing; in that case jq '. += [...]' will fail. Consider defaulting to an empty array when extracting (e.g., .cifsShares // []) before appending, so the script works on volumes with zero existing shares.

Suggested change
cifsShares=$(jq -r '.cifsShares' $tmpout)
#
# Create a new share definition.
newShare='{"name":"'$CIFS_SHARE_NAME'","path":"'/$CIFS_SHARE_NAME'","acls":[{"userOrGroup":"Everyone","permission":"full_control","type":"windows"}]}'
#
# Add the new share to the existing ones.
cifsShares=$(echo "$cifsShares" | jq -r '. += ['$newShare']')
cifsShares=$(jq -r '.cifsShares // []' "$tmpout")
#
# Create a new share definition.
newShare='{"name":"'$CIFS_SHARE_NAME'","path":"'/$CIFS_SHARE_NAME'","acls":[{"userOrGroup":"Everyone","permission":"full_control","type":"windows"}]}'
#
# Add the new share to the existing ones.
cifsShares=$(echo "$cifsShares" | jq --argjson newShare "$newShare" '. += [$newShare]')

Copilot uses AI. Check for mistakes.
Comment on lines +120 to +128
cifsShares=$(jq -r '.cifsShares' $tmpout)
#
# Create a new share definition.
newShare='{"name":"'$CIFS_SHARE_NAME'","path":"'/$CIFS_SHARE_NAME'","acls":[{"userOrGroup":"Everyone","permission":"full_control","type":"windows"}]}'
#
# Add the new share to the existing ones.
cifsShares=$(echo "$cifsShares" | jq -r '. += ['$newShare']')
cifsShares="{\"cifsShares\": $cifsShares}"
run_curl PATCH "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/fsx/v2/credentials/${CREDENTIALS_ID}/regions/${AWS_REGION}/file-systems/${FILESYSTEM_ID}/volumes/${VOLUME_ID}" $tmpout $tmperr "$cifsShares"
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

newShare is built via shell string concatenation and then injected directly into a jq program (. += [ ... ]). If CIFS_SHARE_NAME contains quotes, backslashes, or jq-significant characters, this can produce invalid JSON or unintended jq parsing. Prefer building the object inside jq using --arg/--argjson (or jq -n) and appending using structured JSON rather than code injection.

Suggested change
cifsShares=$(jq -r '.cifsShares' $tmpout)
#
# Create a new share definition.
newShare='{"name":"'$CIFS_SHARE_NAME'","path":"'/$CIFS_SHARE_NAME'","acls":[{"userOrGroup":"Everyone","permission":"full_control","type":"windows"}]}'
#
# Add the new share to the existing ones.
cifsShares=$(echo "$cifsShares" | jq -r '. += ['$newShare']')
cifsShares="{\"cifsShares\": $cifsShares}"
run_curl PATCH "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/fsx/v2/credentials/${CREDENTIALS_ID}/regions/${AWS_REGION}/file-systems/${FILESYSTEM_ID}/volumes/${VOLUME_ID}" $tmpout $tmperr "$cifsShares"
#
# Build the updated cifsShares payload by appending the new share using jq.
cifsSharesPayload=$(jq --arg shareName "$CIFS_SHARE_NAME" '
.cifsShares as $shares
| {
cifsShares: (
($shares // []) + [
{
name: $shareName,
path: ("/" + $shareName),
acls: [
{
userOrGroup: "Everyone",
permission: "full_control",
type: "windows"
}
]
}
]
)
}
' "$tmpout")
#
run_curl PATCH "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/fsx/v2/credentials/${CREDENTIALS_ID}/regions/${AWS_REGION}/file-systems/${FILESYSTEM_ID}/volumes/${VOLUME_ID}" $tmpout $tmperr "$cifsSharesPayload"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants