def synchronize(remote_pk, repository_pk, mirror=False): """ Sync content from the remote repository. Create a new version of the repository that is synchronized with the remote. Args: remote_pk (str): The remote PK. repository_pk (str): The repository PK. mirror (bool): True for mirror mode, False for additive. Raises: ValueError: If the remote does not specify a URL to sync. """ remote = GitRemote.objects.get(pk=remote_pk) repository = AnsibleRepository.objects.get(pk=repository_pk) if not remote.url: raise ValueError( _("A remote must have a url specified to synchronize.")) log.info(_("Synchronizing: repository=%(r)s remote=%(p)s"), { "r": repository.name, "p": remote.name }) first_stage = GitFirstStage(remote) d_version = DeclarativeVersion(first_stage, repository, mirror=mirror) return d_version.create()
def synchronize(remote_pk, repository_pk, mirror): """ Sync content from the remote repository. Create a new version of the repository that is synchronized with the remote. Args: remote_pk (str): The remote PK. repository_pk (str): The repository PK. mirror (bool): True for mirror mode, False for additive. Raises: ValueError: If the remote does not specify a URL to sync. """ remote = FileRemote.objects.get(pk=remote_pk) repository = Repository.objects.get(pk=repository_pk) if not remote.url: raise ValueError( _('A remote must have a url specified to synchronize.')) first_stage = FileFirstStage(remote) download = (remote.policy == Remote.IMMEDIATE ) # Interpret policy to download Artifacts or not dv = DeclarativeVersion(first_stage, repository, mirror=mirror, download_artifacts=download) dv.create()
def synchronize(remote_pk, repository_pk, mirror): """ Sync content from the remote repository. Create a new version of the repository that is synchronized with the remote. Args: remote_pk (str): The remote PK. repository_pk (str): The repository PK. mirror (bool): True for mirror mode, False for additive. Raises: ValueError: If the remote does not specify a URL to sync. """ remote = FileRemote.objects.get(pk=remote_pk) repository = FileRepository.objects.get(pk=repository_pk) if not remote.url: raise ValueError( _("A remote must have a url specified to synchronize.")) first_stage = FileFirstStage(remote) dv = DeclarativeVersion(first_stage, repository, mirror=mirror) return dv.create()
def sync(remote_pk, repository_pk, mirror): """ Sync content from the remote repository. Create a new version of the repository that is synchronized with the remote. Args: remote_pk (str): The remote PK. repository_pk (str): The repository PK. mirror (boolean): True for mirror mode, False for additive mode. Raises: serializers: ValidationError """ remote = PythonRemote.objects.get(pk=remote_pk) repository = Repository.objects.get(pk=repository_pk) if not remote.url: raise serializers.ValidationError( detail=_("A remote must have a url attribute to sync.") ) first_stage = PythonBanderStage(remote) DeclarativeVersion(first_stage, repository, mirror).create()
def synchronize(remote_pk, repository_pk, mirror=False): """ Sync content from the remote repository. Create a new version of the repository that is synchronized with the remote. Args: remote_pk (str): The remote PK. repository_pk (str): The repository PK. mirror (bool): True for mirror mode, False for additive. Raises: ValueError: If the remote does not specify a URL to sync """ remote = NpmRemote.objects.get(pk=remote_pk) repository = Repository.objects.get(pk=repository_pk) if not remote.url: raise ValueError( _("A remote must have a url specified to synchronize.")) # Interpret policy to download Artifacts or not deferred_download = remote.policy != Remote.IMMEDIATE first_stage = NpmFirstStage(remote, deferred_download) DeclarativeVersion(first_stage, repository, mirror=mirror).create()
def synchronize(remote_pk, repository_pk, mirror): """ Sync content from the remote repository. Create a new version of the repository that is synchronized with the remote. Args: remote_pk (str): The remote PK. repository_pk (str): The repository PK. mirror (bool): True for mirror mode, False for additive. Raises: ValueError: If the remote does not specify a URL to sync. """ remote = FileRemote.objects.get(pk=remote_pk) repository = FileRepository.objects.get(pk=repository_pk) if not remote.url: raise ValueError( _("A remote must have a url specified to synchronize.")) first_stage = FileFirstStage(remote) dv = DeclarativeVersion(first_stage, repository, mirror=mirror) rv = dv.create() if rv and mirror: # TODO: this is awful, we really should rewrite the DeclarativeVersion API to # accomodate this use case global metadata_files with FilePublication.create(rv, pass_through=True) as publication: (mdfile_path, relative_path) = metadata_files.pop() PublishedMetadata.create_from_file( file=File(open(mdfile_path, "rb")), relative_path=relative_path, publication=publication, ) publication.manifest = relative_path publication.save() log.info( _("Publication: {publication} created").format( publication=publication.pk)) return rv
def synchronize(remote_pk, repository_pk): """ Create a new version of the repository that is synchronized with the remote as specified by the remote. Args: remote_pk (str): The remote PK. repository_pk (str): The repository PK. Raises: ValueError: When url is empty. """ remote = FileRemote.objects.get(pk=remote_pk) repository = Repository.objects.get(pk=repository_pk) if not remote.url: raise ValueError( _('A remote must have a url specified to synchronize.')) first_stage = FileFirstStage(remote) DeclarativeVersion(first_stage, repository).create()
def synchronize(remote_pk, repository_pk): """ Sync content from the remote repository. Create a new version of the repository that is synchronized with the remote. Args: remote_pk (str): The remote PK. repository_pk (str): The repository PK. Raises: ValueError: If the remote does not specify a URL to sync """ remote = PluginTemplateRemote.objects.get(pk=remote_pk) repository = Repository.objects.get(pk=repository_pk) if not remote.url: raise ValueError(_('A remote must have a url specified to synchronize.')) first_stage = PluginTemplateFirstStage(remote) DeclarativeVersion(first_stage, repository).create()