def config_source_control(resource_group_name, name, repo_url, repository_type=None, branch=None, git_token=None, manual_integration=None, slot=None): from azure.mgmt.web.models import SiteSourceControl, SourceControl client = web_client_factory() location = _get_location_from_webapp(client, resource_group_name, name) if git_token: sc = SourceControl(location, name='GitHub', token=git_token) client.update_source_control('GitHub', sc) source_control = SiteSourceControl( location, repo_url=repo_url, branch=branch, is_manual_integration=manual_integration, is_mercurial=(repository_type != 'git')) poller = _generic_site_operation(resource_group_name, name, 'create_or_update_source_control', slot, source_control) return AppServiceLongRunningOperation()(poller)
def update_git_token(git_token=None): ''' Update source control token cached in Azure app service. If no token is provided, the command will clean up existing token. ''' client = web_client_factory() from azure.mgmt.web.models import SourceControl sc = SourceControl('not-really-needed', name='GitHub', token=git_token or '') return client.update_source_control('GitHub', sc)
def test_set_source_control_token(self, client_factory_mock): client_factory_mock.return_value = self.client self.client._client = mock.MagicMock() sc = SourceControl('not-really-needed', name='GitHub', token='veryNiceToken') self.client._client.send.return_value = FakedResponse(200) self.client._deserialize = mock.MagicMock() self.client._deserialize.return_value = sc # action result = update_git_token('veryNiceToken') # assert things gets wired up self.assertEqual(result.token, 'veryNiceToken')
def config_source_control(resource_group_name, name, repo_url, repository_type=None, branch=None, git_token=None, manual_integration=None, slot=None, cd_provider=None, cd_app_type=None, cd_account=None, cd_account_must_exist=None): client = web_client_factory() location = _get_location_from_webapp(client, resource_group_name, name) if cd_provider == 'vsts': create_account = not cd_account_must_exist vsts_provider = VstsContinuousDeliveryProvider() status = vsts_provider.setup_continuous_delivery( resource_group_name, name, repo_url, branch, git_token, slot, cd_app_type, cd_account, create_account, location) logger.warning(status.status_message) return status else: from azure.mgmt.web.models import SiteSourceControl, SourceControl if git_token: sc = SourceControl(location, name='GitHub', token=git_token) client.update_source_control('GitHub', sc) source_control = SiteSourceControl( location, repo_url=repo_url, branch=branch, is_manual_integration=manual_integration, is_mercurial=(repository_type != 'git')) return _generic_site_operation(resource_group_name, name, 'create_or_update_source_control', slot, source_control)