From 258e96a25584f41b95fc9de5d36e04bacec8e364 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 5 Mar 2022 03:38:36 +0000 Subject: [PATCH 1/2] docs: correct readme --- play-with-sld/kubernetes/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/play-with-sld/kubernetes/README.md b/play-with-sld/kubernetes/README.md index aeeff88a..40e8db33 100644 --- a/play-with-sld/kubernetes/README.md +++ b/play-with-sld/kubernetes/README.md @@ -58,6 +58,7 @@ kubectl apply -f k8s/istio/istio-tls.yaml ### 7-Finally Add EXTERNAL-IP in /etc/hosts ``` + # kubectl -n istio-system get service istio-ingressgateway NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE istio-ingressgateway LoadBalancer 10.96.218.227 172.19.255.200 From 8ba223af167e17e05a8eb3f11159b84fbe6f220f Mon Sep 17 00:00:00 2001 From: root Date: Sat, 5 Mar 2022 13:53:15 +0000 Subject: [PATCH 2/2] fix: fixed trim schema --- .github/workflows/sld-api-docker-image.yml | 4 +- sld-api-backend/schemas/schemas.py | 112 ++++++++++----------- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/.github/workflows/sld-api-docker-image.yml b/.github/workflows/sld-api-docker-image.yml index a144279d..4081f32b 100644 --- a/.github/workflows/sld-api-docker-image.yml +++ b/.github/workflows/sld-api-docker-image.yml @@ -26,10 +26,10 @@ jobs: - name: Build the Docker image with tag working-directory: ./sld-api-backend - run: docker build . --file Dockerfile --tag ${{ secrets.DOCKER_USERNAME }}/sld-api:2.1.2 + run: docker build . --file Dockerfile --tag ${{ secrets.DOCKER_USERNAME }}/sld-api:2.1.3 - name: Docker Push with tag - run: docker push ${{ secrets.DOCKER_USERNAME }}/sld-api:2.1.2 + run: docker push ${{ secrets.DOCKER_USERNAME }}/sld-api:2.1.3 - name: Build the Docker image working-directory: ./sld-api-backend diff --git a/sld-api-backend/schemas/schemas.py b/sld-api-backend/schemas/schemas.py index 0a31c717..3280ca87 100644 --- a/sld-api-backend/schemas/schemas.py +++ b/sld-api-backend/schemas/schemas.py @@ -1,13 +1,13 @@ -from pydantic import BaseModel, EmailStr, Field, ValidationError, validator +from pydantic import BaseModel, EmailStr, Field, ValidationError, validator, SecretStr, constr from typing import Optional, List class UserBase(BaseModel): - username: str + username: constr(strip_whitespace=True) class UserCreate(UserBase): - fullname: str + fullname: constr(strip_whitespace=True) password: str email: EmailStr = None squad: List[str] = [] @@ -16,7 +16,7 @@ class UserCreate(UserBase): class UserCreateMaster(UserBase): - fullname: str + fullname: constr(strip_whitespace=True) password: str email: EmailStr = None is_active: bool = True @@ -64,12 +64,12 @@ class TokenData(BaseModel): class StackBase(BaseModel): - stack_name: str - git_repo: str - branch: str = "master" + stack_name: constr(strip_whitespace=True) + git_repo: constr(strip_whitespace=True) + branch: constr(strip_whitespace=True) = "master" squad_access: List[str] = ["*"] - tf_version: str = "1.0.0" - description: str + tf_version: constr(strip_whitespace=True) = "1.1.7" + description: constr(strip_whitespace=True) class StackCreate(StackBase): @@ -78,7 +78,7 @@ class StackCreate(StackBase): class Stack(StackBase): id: int - task_id: str + task_id: constr(strip_whitespace=True) user_id: int class Config: @@ -86,17 +86,17 @@ class Config: class AwsBase(BaseModel): - squad: str - environment: str - access_key_id: str - secret_access_key: Optional[str] = Field(None, example="string") - default_region: str + squad: constr(strip_whitespace=True) + environment: constr(strip_whitespace=True) + access_key_id: constr(strip_whitespace=True) + secret_access_key: Optional[constr(strip_whitespace=True)] = Field(None, example="string") + default_region: constr(strip_whitespace=True) class AwsAsumeProfile(AwsBase): - profile_name: Optional[str] = None - role_arn: Optional[str] = None - source_profile: Optional[str] = None + profile_name: Optional[constr(strip_whitespace=True)] = None + role_arn: Optional[constr(strip_whitespace=True)] = None + source_profile: Optional[constr(strip_whitespace=True)] = None class Aws(AwsBase): @@ -107,8 +107,8 @@ class Config: class GcloudBase(BaseModel): - squad: str - environment: str + squad: constr(strip_whitespace=True) + environment: constr(strip_whitespace=True) gcloud_keyfile_json: dict @@ -120,12 +120,12 @@ class Config: class AzureBase(BaseModel): - squad: str - environment: str - subscription_id: str - client_id: str - client_secret: str - tenant_id: str + squad: constr(strip_whitespace=True) + environment: constr(strip_whitespace=True) + subscription_id: constr(strip_whitespace=True) + client_id: constr(strip_whitespace=True) + client_secret: constr(strip_whitespace=True) + tenant_id: constr(strip_whitespace=True) class Azure(AwsBase): @@ -136,41 +136,41 @@ class Config: class DeployBase(BaseModel): - name: str - stack_name: str - username: str - squad: str - environment: str - variables: str + name: constr(strip_whitespace=True) + stack_name: constr(strip_whitespace=True) + username: constr(strip_whitespace=True) + squad: constr(strip_whitespace=True) + environment: constr(strip_whitespace=True) + variables: constr(strip_whitespace=True) class DeployCreate(BaseModel): - name: str - squad: str - stack_name: str - environment: str - start_time: Optional[str] = Field(None, example="30 7 * * 0-4") - destroy_time: Optional[str] = Field(None, example="30 18 * * 0-4") + name: constr(strip_whitespace=True) + squad: constr(strip_whitespace=True) + stack_name: constr(strip_whitespace=True) + environment: constr(strip_whitespace=True) + start_time: Optional[constr(strip_whitespace=True)] = Field(None, example="30 7 * * 0-4") + destroy_time: Optional[constr(strip_whitespace=True)] = Field(None, example="30 18 * * 0-4") variables: dict class DeployCreateMaster(DeployCreate): - squad: str + squad: constr(strip_whitespace=True) class DeployDeleteMaster(BaseModel): - squad: str + squad: constr(strip_whitespace=True) class DeployUpdate(BaseModel): - start_time: str - destroy_time: str + start_time: constr(strip_whitespace=True) + destroy_time: constr(strip_whitespace=True) variables: dict class Deploy(StackBase): id: int - task_id: str + task_id: constr(strip_whitespace=True) user_id: int class Config: @@ -178,31 +178,31 @@ class Config: class PlanCreate(BaseModel): - name: str - stack_name: str - squad: str - environment: str - start_time: Optional[str] = Field(None, example="30 7 * * 0-4") - destroy_time: Optional[str] = Field(None, example="30 18 * * 0-4") + name: constr(strip_whitespace=True) + stack_name: constr(strip_whitespace=True) + squad: constr(strip_whitespace=True) + environment: constr(strip_whitespace=True) + start_time: Optional[constr(strip_whitespace=True)] = Field(None, example="30 7 * * 0-4") + destroy_time: Optional[constr(strip_whitespace=True)] = Field(None, example="30 18 * * 0-4") variables: dict class TasksBase(BaseModel): id: str - deploy_id: str - name: str + deploy_id: constr(strip_whitespace=True) + name: constr(strip_whitespace=True) class ActivityLogs(BaseModel): id: int - username: str - squad: str - action: str + username: constr(strip_whitespace=True) + squad: constr(strip_whitespace=True) + action: constr(strip_whitespace=True) class Config: orm_mode = True class ScheduleUpdate(BaseModel): - start_time: Optional[str] = Field(None, example="30 7 * * 0-4") - destroy_time: Optional[str] = Field(None, example="30 18 * * 0-4") + start_time: Optional[constr(strip_whitespace=True)] = Field(None, example="30 7 * * 0-4") + destroy_time: Optional[constr(strip_whitespace=True)] = Field(None, example="30 18 * * 0-4")