/// <inheritdoc />
        public async Task UpdateApplicationAuthorizationPolicyAsync(
            string org,
            string app,
            string shortCommitId,
            EnvironmentModel deploymentEnvironment)
        {
            GiteaFileContent policyFile = await GetAuthorizationPolicyFileFromGitea(org, app, shortCommitId);

            byte[] data = Convert.FromBase64String(policyFile.Content);
            string policyFileContent = Encoding.UTF8.GetString(data);
            await _authorizationPolicyClient.SavePolicy(org, app, policyFileContent, deploymentEnvironment);
        }
        private async Task <Application> GetApplicationMetadataFileFromRepository()
        {
            string           filePath = GetApplicationMetadataFilePath();
            GiteaFileContent file     = await _giteaApiWrapper.GetFileAsync(_org, _app, filePath, _shortCommitId);

            if (string.IsNullOrEmpty(file.Content))
            {
                throw new NotFoundHttpRequestException($"There is no file in {filePath}.");
            }

            byte[]      data        = Convert.FromBase64String(file.Content);
            Application appMetadata = data.Deserialize <Application>();

            return(appMetadata);
        }
Esempio n. 3
0
        /// <inheritdoc/>
        public async Task UpdateTextResourcesAsync(string org, string app, string shortCommitId, EnvironmentModel environmentModel)
        {
            string textResourcesPath       = GetTextResourceDirectoryPath();
            List <GiteaFileContent> folder = await _giteaApiWrapper.GetDirectoryAsync(org, app, textResourcesPath, shortCommitId);

            if (folder != null)
            {
                folder.ForEach(async textResourceFromRepo =>
                {
                    GiteaFileContent populatedFile = await _giteaApiWrapper.GetFileAsync(org, app, textResourceFromRepo.Path, shortCommitId);
                    byte[] data                      = Convert.FromBase64String(populatedFile.Content);
                    TextResource content             = data.Deserialize <TextResource>();
                    TextResource textResourceStorage = await GetTextResourceFromStorage(org, app, content.Language, environmentModel);
                    if (textResourceStorage == null)
                    {
                        await _storageTextResourceClient.Create(org, app, content, environmentModel);
                    }
                    else
                    {
                        await _storageTextResourceClient.Update(org, app, content, environmentModel);
                    }
                });
            }
        }