Fix #5956 issue: The APIs should not get chart information when Harbor is not installed with chart repo
This commit is contained in:
Daniel Jiang 2018-09-27 15:41:30 +08:00 committed by GitHub
commit 30950c3f8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 37 deletions

View File

@ -44,8 +44,8 @@ apt:
- google-chrome-stable - google-chrome-stable
- google-chrome-beta - google-chrome-beta
before_install: before_install:
- openssl aes-256-cbc -K $encrypted_ed2284a9ecc3_key -iv $encrypted_ed2284a9ecc3_iv #- openssl aes-256-cbc -K $encrypted_ed2284a9ecc3_key -iv $encrypted_ed2284a9ecc3_iv
-in gskey.sh.enc -out ./gskey.sh -d # -in gskey.sh.enc -out ./gskey.sh -d
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname
-s`-`uname -m` > docker-compose -s`-`uname -m` > docker-compose
- chmod +x docker-compose - chmod +x docker-compose

View File

@ -420,13 +420,15 @@ func (p *ProjectAPI) populateProperties(project *models.Project) {
project.RepoCount = total project.RepoCount = total
// Populate chart count property // Populate chart count property
count, err := chartController.GetCountOfCharts([]string{project.Name}) if config.WithChartMuseum() {
if err != nil { count, err := chartController.GetCountOfCharts([]string{project.Name})
log.Errorf("Failed to get total of charts under project %s: %v", project.Name, err) if err != nil {
p.CustomAbort(http.StatusInternalServerError, "") log.Errorf("Failed to get total of charts under project %s: %v", project.Name, err)
} p.CustomAbort(http.StatusInternalServerError, "")
}
project.ChartCount = count project.ChartCount = count
}
} }
// Put ... // Put ...

View File

@ -1,29 +1,29 @@
#!/bin/bash #!/bin/bash
source gskey.sh #source gskey.sh
sudo gsutil version -l #sudo gsutil version -l
harbor_logs_bucket="harbor-ci-logs" #harbor_logs_bucket="harbor-ci-logs"
# GC credentials # GC credentials
keyfile="/home/travis/harbor-ci-logs.key" #keyfile="/home/travis/harbor-ci-logs.key"
botofile="/home/travis/.boto" #botofile="/home/travis/.boto"
echo -en $GS_PRIVATE_KEY > $keyfile #echo -en $GS_PRIVATE_KEY > $keyfile
sudo chmod 400 $keyfile #sudo chmod 400 $keyfile
echo "[Credentials]" >> $botofile #echo "[Credentials]" >> $botofile
echo "gs_service_key_file = $keyfile" >> $botofile #echo "gs_service_key_file = $keyfile" >> $botofile
echo "gs_service_client_id = $GS_CLIENT_EMAIL" >> $botofile #echo "gs_service_client_id = $GS_CLIENT_EMAIL" >> $botofile
echo "[GSUtil]" >> $botofile #echo "[GSUtil]" >> $botofile
echo "content_language = en" >> $botofile #echo "content_language = en" >> $botofile
echo "default_project_id = $GS_PROJECT_ID" >> $botofile #echo "default_project_id = $GS_PROJECT_ID" >> $botofile
# GS util # GS util
function uploader { #function uploader {
sudo gsutil cp $1 gs://$2/$1 # sudo gsutil cp $1 gs://$2/$1
sudo gsutil -D setacl public-read gs://$2/$1 &> /dev/null # sudo gsutil -D setacl public-read gs://$2/$1 &> /dev/null
} #}
set +e #set +e
docker ps docker ps
# run db auth api cases # run db auth api cases
@ -36,15 +36,15 @@ if [ "$1" = 'LDAP' ]; then
fi fi
## --------------------------------------------- Upload Harbor CI Logs ------------------------------------------- ## --------------------------------------------- Upload Harbor CI Logs -------------------------------------------
outfile="integration_logs_$TRAVIS_BUILD_NUMBER_$TRAVIS_COMMIT.tar.gz" #outfile="integration_logs_$TRAVIS_BUILD_NUMBER_$TRAVIS_COMMIT.tar.gz"
sudo tar -zcvf $outfile output.xml log.html /var/log/harbor/* #sudo tar -zcvf $outfile output.xml log.html /var/log/harbor/*
if [ -f "$outfile" ]; then #if [ -f "$outfile" ]; then
uploader $outfile $harbor_logs_bucket # uploader $outfile $harbor_logs_bucket
echo "----------------------------------------------" # echo "----------------------------------------------"
echo "Download test logs:" # echo "Download test logs:"
echo "https://storage.googleapis.com/harbor-ci-logs/$outfile" # echo "https://storage.googleapis.com/harbor-ci-logs/$outfile"
echo "----------------------------------------------" # echo "----------------------------------------------"
else #else
echo "No log output file to upload" # echo "No log output file to upload"
fi #fi