This is an automated email from the ASF dual-hosted git repository.
jscheffl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new b87ed753a57 Add encryption column for variables (#45209)
b87ed753a57 is described below
commit b87ed753a574c4b872cdbd119d53e335cf0d7e06
Author: Shubham Raj <[email protected]>
AuthorDate: Thu Dec 26 02:51:03 2024 +0530
Add encryption column for variables (#45209)
* add encryption column
* col name
* fix tests
---
airflow/api_fastapi/core_api/datamodels/variables.py | 1 +
airflow/api_fastapi/core_api/openapi/v1-generated.yaml | 4 ++++
airflow/api_fastapi/core_api/routes/public/variables.py | 2 +-
airflow/ui/openapi-gen/requests/schemas.gen.ts | 6 +++++-
airflow/ui/openapi-gen/requests/types.gen.ts | 1 +
airflow/ui/src/pages/Variables/Variables.tsx | 4 ++++
tests/api_fastapi/core_api/routes/public/test_variables.py | 11 +++++++++++
7 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/airflow/api_fastapi/core_api/datamodels/variables.py
b/airflow/api_fastapi/core_api/datamodels/variables.py
index 9f232880c47..ab40415ac3c 100644
--- a/airflow/api_fastapi/core_api/datamodels/variables.py
+++ b/airflow/api_fastapi/core_api/datamodels/variables.py
@@ -35,6 +35,7 @@ class VariableResponse(BaseModel):
key: str
val: str | None = Field(alias="value")
description: str | None
+ is_encrypted: bool
@model_validator(mode="after")
def redact_val(self) -> Self:
diff --git a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml
b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml
index 008e4112c3f..aee6f8bacf1 100644
--- a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml
+++ b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml
@@ -9698,11 +9698,15 @@ components:
- type: string
- type: 'null'
title: Description
+ is_encrypted:
+ type: boolean
+ title: Is Encrypted
type: object
required:
- key
- value
- description
+ - is_encrypted
title: VariableResponse
description: Variable serializer for responses.
VersionInfo:
diff --git a/airflow/api_fastapi/core_api/routes/public/variables.py
b/airflow/api_fastapi/core_api/routes/public/variables.py
index d1a38da21c0..ccc8ee7dc22 100644
--- a/airflow/api_fastapi/core_api/routes/public/variables.py
+++ b/airflow/api_fastapi/core_api/routes/public/variables.py
@@ -87,7 +87,7 @@ def get_variables(
SortParam,
Depends(
SortParam(
- ["key", "id", "_val", "description"],
+ ["key", "id", "_val", "description", "is_encrypted"],
Variable,
).dynamic_depends()
),
diff --git a/airflow/ui/openapi-gen/requests/schemas.gen.ts
b/airflow/ui/openapi-gen/requests/schemas.gen.ts
index 7690edf497c..630698f3cab 100644
--- a/airflow/ui/openapi-gen/requests/schemas.gen.ts
+++ b/airflow/ui/openapi-gen/requests/schemas.gen.ts
@@ -5562,9 +5562,13 @@ export const $VariableResponse = {
],
title: "Description",
},
+ is_encrypted: {
+ type: "boolean",
+ title: "Is Encrypted",
+ },
},
type: "object",
- required: ["key", "value", "description"],
+ required: ["key", "value", "description", "is_encrypted"],
title: "VariableResponse",
description: "Variable serializer for responses.",
} as const;
diff --git a/airflow/ui/openapi-gen/requests/types.gen.ts
b/airflow/ui/openapi-gen/requests/types.gen.ts
index f7bfd1c0d26..31c1d21514d 100644
--- a/airflow/ui/openapi-gen/requests/types.gen.ts
+++ b/airflow/ui/openapi-gen/requests/types.gen.ts
@@ -1302,6 +1302,7 @@ export type VariableResponse = {
key: string;
value: string | null;
description: string | null;
+ is_encrypted: boolean;
};
/**
diff --git a/airflow/ui/src/pages/Variables/Variables.tsx
b/airflow/ui/src/pages/Variables/Variables.tsx
index 00d22d09010..cd5aa961e36 100644
--- a/airflow/ui/src/pages/Variables/Variables.tsx
+++ b/airflow/ui/src/pages/Variables/Variables.tsx
@@ -56,6 +56,10 @@ const columns: Array<ColumnDef<VariableResponse>> = [
skeletonWidth: 50,
},
},
+ {
+ accessorKey: "is_encrypted",
+ header: "Is Encrypted",
+ },
];
export const Variables = () => {
diff --git a/tests/api_fastapi/core_api/routes/public/test_variables.py
b/tests/api_fastapi/core_api/routes/public/test_variables.py
index e71d7da2e9a..5371a347905 100644
--- a/tests/api_fastapi/core_api/routes/public/test_variables.py
+++ b/tests/api_fastapi/core_api/routes/public/test_variables.py
@@ -116,6 +116,7 @@ class TestGetVariable(TestVariableEndpoint):
"key": TEST_VARIABLE_KEY,
"value": TEST_VARIABLE_VALUE,
"description": TEST_VARIABLE_DESCRIPTION,
+ "is_encrypted": True,
},
),
(
@@ -124,6 +125,7 @@ class TestGetVariable(TestVariableEndpoint):
"key": TEST_VARIABLE_KEY2,
"value": "***",
"description": TEST_VARIABLE_DESCRIPTION2,
+ "is_encrypted": True,
},
),
(
@@ -132,6 +134,7 @@ class TestGetVariable(TestVariableEndpoint):
"key": TEST_VARIABLE_KEY3,
"value": '{"password": "***"}',
"description": TEST_VARIABLE_DESCRIPTION3,
+ "is_encrypted": True,
},
),
(
@@ -140,6 +143,7 @@ class TestGetVariable(TestVariableEndpoint):
"key": TEST_VARIABLE_SEARCH_KEY,
"value": TEST_VARIABLE_SEARCH_VALUE,
"description": TEST_VARIABLE_SEARCH_DESCRIPTION,
+ "is_encrypted": True,
},
),
],
@@ -225,6 +229,7 @@ class TestPatchVariable(TestVariableEndpoint):
"key": TEST_VARIABLE_KEY,
"value": "The new value",
"description": "The new description",
+ "is_encrypted": True,
},
),
(
@@ -239,6 +244,7 @@ class TestPatchVariable(TestVariableEndpoint):
"key": TEST_VARIABLE_KEY,
"value": "The new value",
"description": TEST_VARIABLE_DESCRIPTION,
+ "is_encrypted": True,
},
),
(
@@ -253,6 +259,7 @@ class TestPatchVariable(TestVariableEndpoint):
"key": TEST_VARIABLE_KEY2,
"value": "***",
"description": TEST_VARIABLE_DESCRIPTION2,
+ "is_encrypted": True,
},
),
(
@@ -267,6 +274,7 @@ class TestPatchVariable(TestVariableEndpoint):
"key": TEST_VARIABLE_KEY3,
"value": '{"password": "***"}',
"description": "new description",
+ "is_encrypted": True,
},
),
],
@@ -311,6 +319,7 @@ class TestPostVariable(TestVariableEndpoint):
"key": "new variable key",
"value": "new variable value",
"description": "new variable description",
+ "is_encrypted": True,
},
),
(
@@ -323,6 +332,7 @@ class TestPostVariable(TestVariableEndpoint):
"key": "another_password",
"value": "***",
"description": "another password",
+ "is_encrypted": True,
},
),
(
@@ -335,6 +345,7 @@ class TestPostVariable(TestVariableEndpoint):
"key": "another value with sensitive information",
"value": '{"password": "***"}',
"description": "some description",
+ "is_encrypted": True,
},
),
],