-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/spotinst/openapi into fea…
…ture/SPOTSEC-4343/public-docs-secops-rest-api
- Loading branch information
Showing
9 changed files
with
236 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: pr-jira-validation | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
# workflow_dispatch: | ||
# inputs: | ||
# branch_name: | ||
# description: "Name of the branch to test !" | ||
# required: true | ||
# default: "DOC-2064-test-shimi-3" | ||
|
||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get source branch | ||
id: get_source_branch | ||
run: echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV | ||
#run: echo "branch=${{ inputs.branch_name }}" >> $GITHUB_ENV | ||
# | ||
|
||
- name: Get branch creation event | ||
id: get_branch_creation_event | ||
run: | | ||
echo "repo - ${{ github.repository }}" | ||
BRANCH_CREATION_EVENT=$(gh api -H "Accept: application/vnd.github.v3+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{ github.repository }}/activity | jq -c '[.[] | select(.activity_type == "branch_creation" and .ref == "refs/heads/${{ env.branch }}")] | .[0]') | ||
echo "branch_creation_event - $BRANCH_CREATION_EVENT" | ||
echo "branch_creation_event=$BRANCH_CREATION_EVENT" >> $GITHUB_ENV | ||
- name: Validate branch creator | ||
id: validate_branch_creator | ||
run: | | ||
ACTOR_LOGIN=$(echo '${{ env.branch_creation_event }}' | jq -r '.actor.login') | ||
echo "ACTOR_LOGIN - $ACTOR_LOGIN" | ||
if [ "$ACTOR_LOGIN" != "jira[bot]" ]; then | ||
echo "Branch was not created by jira[bot]." | ||
exit 1 | ||
fi | ||
- name: Validate PR body for Jira ticket link | ||
id: validate_pr_body | ||
run: | | ||
PR_BODY=$(jq -r '.pull_request.body' < $GITHUB_EVENT_PATH) | ||
echo "PR-body - $PR_BODY" | ||
if ! echo "$PR_BODY" | grep -q -e "https://spotinst.atlassian.net/browse/DOC-" -e "https://spotinst.atlassian.net/browse/AUT-"; then | ||
echo "PR body does not contain a valid Jira ticket link (DOC or AUT)." | ||
exit 1 | ||
fi | ||
- name: Extract Jira ticket ID | ||
id: extract_jira_ticket | ||
run: | | ||
PR_BODY=$(jq -r '.pull_request.body' < $GITHUB_EVENT_PATH) | ||
JIRA_TICKET=$(echo "$PR_BODY" | grep -o -e "DOC-[0-9]*" -e "AUT-[0-9]*" | head -n 1) | ||
if [ -z "$JIRA_TICKET" ]; then | ||
echo "No DOC or AUT Jira ticket found in the PR body." | ||
exit 1 | ||
fi | ||
echo "jira_ticket=$JIRA_TICKET" >> $GITHUB_ENV | ||
- name: Verify Jira ticket status | ||
id: verify_jira_ticket | ||
env: | ||
JIRA_USER: ${{ secrets.JIRA_USER }} | ||
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} | ||
run: | | ||
JIRA_TICKET=${{ env.jira_ticket }} | ||
JIRA_API_URL="https://spotinst.atlassian.net/rest/api/2/issue/$JIRA_TICKET" | ||
JIRA_STATUS=$(curl -s -u $JIRA_USER:$JIRA_API_TOKEN $JIRA_API_URL | jq -r '.fields.status.name') | ||
echo "JIRA_STATUS - $JIRA_STATUS" | ||
if [ "$JIRA_STATUS" != "Approved for Publishing" ]; then | ||
if [[ "$JIRA_TICKET" == *DOC* ]]; then | ||
echo "Jira ticket $JIRA_TICKET is not in 'Approved for Publishing' status and it is from 'DOC' project." | ||
exit 1 | ||
fi | ||
fi | ||
echo "All validations passed." |
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
8 changes: 8 additions & 0 deletions
8
api/services/ocean/rightsizing/parameters/clusterIdentifier.yaml
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,8 @@ | ||
in: query | ||
name: clusterIdentifier | ||
schema: | ||
type: string | ||
required: true | ||
example: dev-cluster | ||
description: > | ||
Identifier of cluster. |
28 changes: 28 additions & 0 deletions
28
api/services/ocean/rightsizing/paths/oceanRightsizingAcknowledgeRollbacks.yaml
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,28 @@ | ||
post: | ||
summary: "Acknowledge Rightsizing Rollbacks" | ||
description: | | ||
Acknowledge rightsizing rollbacks For ocean cluster. | ||
operationId: "AcknowledgeRightsizingRollbacks" | ||
tags: | ||
- "Ocean Automatic Rightsizing" | ||
parameters: | ||
- $ref: "../parameters/oceanId.yaml" | ||
- $ref: "../parameters/clusterIdentifier.yaml" | ||
- $ref: "../../../../commons/parameters/accountId.yaml" | ||
requestBody: | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
allOf: | ||
- $ref: "../schemas/oceanRightsizingRollbacksAcknowledgeRequest.yaml" | ||
responses: | ||
200: | ||
description: Ocean Rightsizing Acknowledge Rollbacks Response | ||
content: | ||
application/json: | ||
schema: | ||
allOf: | ||
- $ref: "../../../../commons/schemas/responseWrapper.yaml" | ||
400: | ||
description: "Bad Request" |
15 changes: 15 additions & 0 deletions
15
api/services/ocean/rightsizing/paths/oceanRightsizingRollbacks.yaml
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,15 @@ | ||
get: | ||
summary: "List Ocean Rightsizing Rollbacks" | ||
description: List the rightsizing rollback for ocean cluster. | ||
operationId: "oceanRightsizingRollbackList" | ||
tags: | ||
- "Ocean Automatic Rightsizing" | ||
parameters: | ||
- $ref: "../parameters/oceanId.yaml" | ||
- $ref: "../../../../commons/parameters/accountId.yaml" | ||
|
||
responses: | ||
200: | ||
$ref: "../responses/oceanRightsizingRollbacksResponse.yaml" | ||
400: | ||
description: "Bad Request" |
66 changes: 66 additions & 0 deletions
66
api/services/ocean/rightsizing/responses/oceanRightsizingRollbacksResponse.yaml
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,66 @@ | ||
description: Ocean Rightsizing Rollbacks Response | ||
content: | ||
application/json: | ||
schema: | ||
allOf: | ||
- $ref: "../../../../commons/schemas/responseItemWrapper.yaml" | ||
- type: object | ||
properties: | ||
request: | ||
type: object | ||
properties: | ||
url: | ||
example: "/ocean/{oceanId}/rightSizing/rollbacks" | ||
method: | ||
example: "GET" | ||
response: | ||
type: object | ||
properties: | ||
items: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
clusterIdentifier: | ||
type: string | ||
description: The cluster identifier | ||
example: test-k8s | ||
namespace: | ||
type: string | ||
description: The namespace of the workload | ||
example: kube-system | ||
resourceType: | ||
type: string | ||
description: The type of the resource | ||
example: deployment | ||
resourceName: | ||
type: string | ||
description: The name of the resource | ||
example: resource-name | ||
rollbackType: | ||
type: string | ||
description: The type of the rollback | ||
example: OUT_OF_MEMORY | ||
rollbackTime: | ||
type: string | ||
format: date-time | ||
description: The time of the rollback | ||
example: 2024-11-01T10:50:29.000+0000 | ||
cpuAtRollback: | ||
type: number | ||
description: The cpu at the time of the rollback | ||
example: 0.23 | ||
cpuAfterRollback: | ||
type: number | ||
description: The cpu after the rollback | ||
example: 0.33 | ||
memoryAtRollback: | ||
type: number | ||
description: The memory at the time of the rollback | ||
example: 128 | ||
memoryAfterRollback: | ||
type: number | ||
description: The memory after the rollback | ||
example: 185 | ||
kind: | ||
example: "mcs:ocean:rightsizing:rollback" |
19 changes: 19 additions & 0 deletions
19
api/services/ocean/rightsizing/schemas/oceanRightsizingRollbacksAcknowledgeRequest.yaml
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,19 @@ | ||
type: object | ||
properties: | ||
acknowledgeRollbacks: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
namespace: | ||
type: string | ||
description: The namespace of the workload | ||
example: kube-system | ||
resourceType: | ||
type: string | ||
description: The type of the resource | ||
example: deployment | ||
resourceName: | ||
type: string | ||
description: The name of the resource | ||
example: resource-name |
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