-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from truenas/NAS-130250
NAS-130250 / 24.10 / Validate k8s to docker migration file
- Loading branch information
Showing
2 changed files
with
19 additions
and
0 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
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 @@ | ||
import contextlib | ||
import os.path | ||
|
||
from apps_exceptions import ValidationErrors | ||
|
||
|
||
def validate_k8s_to_docker_migrations(verrors: ValidationErrors, app_migration_path: str, schema: str): | ||
file_to_check_path = os.path.join(app_migration_path, 'migrate_from_kubernetes') | ||
with contextlib.suppress(FileNotFoundError): | ||
with open(file_to_check_path, 'r') as r: | ||
if not r.readline().startswith('#!'): | ||
verrors.add(schema, 'Migration file should start with shebang line') | ||
|
||
if not os.access(file_to_check_path, os.X_OK): | ||
verrors.add(schema, 'Migration file is not executable') |