Skip to content

Commit

Permalink
fix token
Browse files Browse the repository at this point in the history
  • Loading branch information
vinicvaz committed Nov 1, 2023
1 parent b6b882f commit eace869
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
- dev
- test/*
- chore/update-airflow-pydantic
# - chore/update-airflow-pydantic

jobs:
api-tests:
Expand Down
7 changes: 3 additions & 4 deletions rest/core/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pydantic_settings import BaseSettings
from typing import Optional, Union
from typing import Union
import os
from database.models.enums import RepositorySource

Expand Down Expand Up @@ -39,9 +39,8 @@ class Settings(BaseSettings):
DOMINO_DEFAULT_PIECES_REPOSITORY: str = os.environ.get('DOMINO_DEFAULT_PIECES_REPOSITORY', "Tauffer-Consulting/default_domino_pieces")
DOMINO_DEFAULT_PIECES_REPOSITORY_VERSION: str = os.environ.get('DOMINO_DEFAULT_PIECES_REPOSITORY_VERSION', "0.4.3")
DOMINO_DEFAULT_PIECES_REPOSITORY_SOURCE: str = os.environ.get('DOMINO_DEFAULT_PIECES_REPOSITORY_SOURCE', "github")
DOMINO_DEFAULT_PIECES_REPOSITORY_TOKEN: Union[str, None] = os.environ.get('DOMINO_DEFAULT_PIECES_REPOSITORY_TOKEN', None)
if DOMINO_DEFAULT_PIECES_REPOSITORY_TOKEN.strip() == '':
DOMINO_DEFAULT_PIECES_REPOSITORY_TOKEN = None
DOMINO_DEFAULT_PIECES_REPOSITORY_TOKEN: Union[str, None] = os.environ.get('DOMINO_DEFAULT_PIECES_REPOSITORY_TOKEN', '')

DOMINO_DEFAULT_PIECES_REPOSITORY_URL: str = os.environ.get('DOMINO_DEFAULT_PIECES_REPOSITORY_URL', 'https://github.com/Tauffer-Consulting/default_domino_pieces')

# Default DB mock data
Expand Down
6 changes: 6 additions & 0 deletions rest/services/piece_repository_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def get_piece_repository_releases(self, source: str, path: str, auth_context: Au
self.logger.info(f"Getting releases for repository {path}")

token = auth_context.workspace.github_access_token if auth_context.workspace.github_access_token else settings.DOMINO_DEFAULT_PIECES_REPOSITORY_TOKEN
if not token.strip():
token = None
github_client = GithubRestClient(token=token)
if source == getattr(RepositorySource, 'github').value:
tags = github_client.get_tags(repo_name=path)
Expand All @@ -100,6 +102,8 @@ def get_piece_repository_release_data(self, version: str, source:str, path: str,
self.logger.info(f'Getting release data for repository {path}')

token = auth_context.workspace.github_access_token if auth_context.workspace.github_access_token else settings.DOMINO_DEFAULT_PIECES_REPOSITORY_TOKEN
if not token.strip():
token = None
tag_data = self._read_repository_data(path=path, source=source, version=version, github_access_token=token)
name = tag_data.get('config_toml').get('repository').get("REPOSITORY_NAME")
description = tag_data.get('config_toml').get('repository').get("DESCRIPTION")
Expand Down Expand Up @@ -215,6 +219,8 @@ def create_piece_repository(
raise ConflictException(message=f"Repository {piece_repository_data.path} already exists for this workspace")

token = auth_context.workspace.github_access_token if auth_context.workspace.github_access_token else settings.DOMINO_DEFAULT_PIECES_REPOSITORY_TOKEN
if not token.strip():
token = None
repository_files_metadata = self._read_repository_data(
source=piece_repository_data.source,
path=piece_repository_data.path,
Expand Down

0 comments on commit eace869

Please sign in to comment.