diff --git a/.gitignore b/.gitignore index 862a91fed..87860b72d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,10 @@ src/common/dao/dao.test *.pyc jobservice/test -src/ui/static/dist/ +src/ui/static/*.html +src/ui/static/*.bundle.js +src/ui/static/*.bundle.js.map +src/ui/static/harbor-log.*.png src/ui_ng/coverage/ src/ui_ng/dist/ diff --git a/.travis.yml b/.travis.yml index d552fba28..b0dd4c556 100644 --- a/.travis.yml +++ b/.travis.yml @@ -76,6 +76,8 @@ before_script: script: - sudo mkdir -p /harbor_storage/ca_download - sudo mv ./tests/ca.crt /harbor_storage/ca_download + - sudo mkdir -p /harbor + - sudo mv ./VERSION /harbor/VERSION - sudo service mysql stop - sudo ./tests/testprepare.sh - docker-compose -f ./make/docker-compose.test.yml up -d @@ -98,6 +100,7 @@ script: - sudo make install GOBUILDIMAGE=golang:1.7.3 COMPILETAG=compile_golangimage CLARITYIMAGE=danieljt/harbor-clarity-base:0.8.4 NOTARYFLAG=true - docker ps + - ./tests/notarytest.sh - go run tests/startuptest.go https://localhost/ - go run tests/userlogintest.go -name ${HARBOR_ADMIN} -passwd ${HARBOR_ADMIN_PASSWD} diff --git a/Makefile b/Makefile index 24438977a..08f5a0fde 100644 --- a/Makefile +++ b/Makefile @@ -82,9 +82,9 @@ NOTARYFLAG=false REGISTRYVERSION=2.6.0 NGINXVERSION=1.11.5 PHOTONVERSION=1.0 -NOTARYVERSION=server-0.5.0-fix +NOTARYVERSION=server-0.5.0 NOTARYSIGNERVERSION=signer-0.5.0 -MARIADBVERSION=10.1.10 +MARIADBVERSION=mariadb-10.1.10 HTTPPROXY= #clarity parameters @@ -164,8 +164,8 @@ DOCKERCOMPOSEFILENAME=docker-compose.yml DOCKERCOMPOSENOTARYFILENAME=docker-compose.notary.yml # version prepare -VERSIONFILEPATH=$(SRCPATH)/ui/views/sections -VERSIONFILENAME=header-content.htm +VERSIONFILEPATH=$(CURDIR) +VERSIONFILENAME=VERSION GITCMD=$(shell which git) GITTAG=$(GITCMD) describe --tags ifeq ($(DEVFLAG), true) @@ -189,9 +189,7 @@ REGISTRYUSER=user REGISTRYPASSWORD=default version: - @if [ "$(DEVFLAG)" = "false" ] ; then \ - $(SEDCMD) -i 's/version=\"{{.Version}}\"/version=\"$(VERSIONTAG)\"/' -i $(VERSIONFILEPATH)/$(VERSIONFILENAME) ; \ - fi + @printf $(VERSIONTAG) > $(VERSIONFILEPATH)/$(VERSIONFILENAME); check_environment: @$(MAKEPATH)/$(CHECKENVCMD) @@ -304,10 +302,10 @@ package_offline: compile build modify_composefile @$(DOCKERPULL) registry:$(REGISTRYVERSION) @$(DOCKERPULL) nginx:$(NGINXVERSION) @if [ "$(NOTARYFLAG)" = "true" ] ; then \ - echo "pulling notary and mariadb..."; \ - $(DOCKERPULL) jiangd/notary:$(NOTARYVERSION); \ - $(DOCKERPULL) notary:$(NOTARYSIGNERVERSION); \ - $(DOCKERPULL) mariadb:$(MARIADBVERSION); \ + echo "pulling notary and harbor-notary-db..."; \ + $(DOCKERPULL) vmware/notary-photon:$(NOTARYVERSION); \ + $(DOCKERPULL) vmware/notary-photon:$(NOTARYSIGNERVERSION); \ + $(DOCKERPULL) vmware/harbor-notary-db:$(MARIADBVERSION); \ fi @echo "saving harbor docker image" @@ -319,7 +317,7 @@ package_offline: compile build modify_composefile $(DOCKERIMAGENAME_DB):$(VERSIONTAG) \ $(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG) \ nginx:$(NGINXVERSION) registry:$(REGISTRYVERSION) photon:$(PHOTONVERSION) \ - jiangd/notary:$(NOTARYVERSION) notary:$(NOTARYSIGNERVERSION) mariadb:$(MARIADBVERSION); \ + vmware/notary-photon:$(NOTARYVERSION) vmware/notary-photon:$(NOTARYSIGNERVERSION) vmware/harbor-notary-db:$(MARIADBVERSION); \ else \ $(DOCKERSAVE) -o $(HARBORPKG)/$(DOCKERIMGFILE).$(VERSIONTAG).tgz \ $(DOCKERIMAGENAME_ADMINSERVER):$(VERSIONTAG) \ @@ -420,7 +418,7 @@ cleandockercomposefile: cleanversiontag: @echo "cleaning version TAG" - @$(SEDCMD) -i 's/version=\"$(VERSIONTAG)\"/version=\"{{.Version}}\"/' -i $(VERSIONFILEPATH)/$(VERSIONFILENAME) + @rm -rf $(VERSIONFILEPATH)/$(VERSIONFILENAME) cleanpackage: @echo "cleaning harbor install package" diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..90012116c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +dev \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 697ba33be..2aca69dc6 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -2052,6 +2052,9 @@ definitions: has_ca_root: type: boolean description: Indicate whether there is a ca root cert file ready for download in the file system. + harbor_version: + type: string + description: The build version of Harbor. SystemInfo: type: object properties: diff --git a/make/common/templates/notary/mysql-initdb.d/initial-notaryserver.sql b/make/common/templates/notary/mysql-initdb.d/initial-notaryserver.sql index 0cc1e9b22..ae124ed15 100644 --- a/make/common/templates/notary/mysql-initdb.d/initial-notaryserver.sql +++ b/make/common/templates/notary/mysql-initdb.d/initial-notaryserver.sql @@ -1,7 +1,7 @@ CREATE DATABASE IF NOT EXISTS `notaryserver`; -CREATE USER "server"@"%" IDENTIFIED BY ""; +CREATE USER "server"@"notary-server.%" IDENTIFIED BY ""; GRANT ALL PRIVILEGES ON `notaryserver`.* - TO "server"@"%"; + TO "server"@"notary-server.%" diff --git a/make/common/templates/notary/mysql-initdb.d/initial-notarysigner.sql b/make/common/templates/notary/mysql-initdb.d/initial-notarysigner.sql index 1e985d81c..a3917d508 100644 --- a/make/common/templates/notary/mysql-initdb.d/initial-notarysigner.sql +++ b/make/common/templates/notary/mysql-initdb.d/initial-notarysigner.sql @@ -1,7 +1,7 @@ CREATE DATABASE IF NOT EXISTS `notarysigner`; -CREATE USER "signer"@"%" IDENTIFIED BY ""; +CREATE USER "signer"@"notary-signer.%" IDENTIFIED BY ""; GRANT ALL PRIVILEGES ON `notarysigner`.* - TO "signer"@"%"; + TO "signer"@"notary-signer.%"; diff --git a/make/common/templates/notary/mysql-initdb.d/notary.sql b/make/common/templates/notary/mysql-initdb.d/notary.sql deleted file mode 100644 index c9dcf9051..000000000 --- a/make/common/templates/notary/mysql-initdb.d/notary.sql +++ /dev/null @@ -1,210 +0,0 @@ --- MySQL dump 10.16 Distrib 10.1.10-MariaDB, for debian-linux-gnu (x86_64) --- --- Host: localhost Database: --- ------------------------------------------------------ --- Server version 10.1.10-MariaDB-1~jessie - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; --- --- Current Database: `notaryserver` --- - -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `notaryserver` /*!40100 DEFAULT CHARACTER SET latin1 */; - -USE `notaryserver`; - --- --- Table structure for table `change_category` --- - -DROP TABLE IF EXISTS `change_category`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `change_category` ( - `category` varchar(20) NOT NULL, - PRIMARY KEY (`category`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `change_category` --- - -LOCK TABLES `change_category` WRITE; -/*!40000 ALTER TABLE `change_category` DISABLE KEYS */; -INSERT INTO `change_category` VALUES ('deletion'),('update'); -/*!40000 ALTER TABLE `change_category` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `changefeed` --- - -DROP TABLE IF EXISTS `changefeed`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `changefeed` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `gun` varchar(255) NOT NULL, - `version` int(11) NOT NULL, - `sha256` char(64) DEFAULT NULL, - `category` varchar(20) NOT NULL DEFAULT 'update', - PRIMARY KEY (`id`), - KEY `category` (`category`), - KEY `idx_changefeed_gun` (`gun`), - CONSTRAINT `changefeed_ibfk_1` FOREIGN KEY (`category`) REFERENCES `change_category` (`category`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `changefeed` --- - -LOCK TABLES `changefeed` WRITE; -/*!40000 ALTER TABLE `changefeed` DISABLE KEYS */; -/*!40000 ALTER TABLE `changefeed` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `schema_migrations` --- - -DROP TABLE IF EXISTS `schema_migrations`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `schema_migrations` ( - `version` int(11) NOT NULL, - PRIMARY KEY (`version`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `schema_migrations` --- - -LOCK TABLES `schema_migrations` WRITE; -/*!40000 ALTER TABLE `schema_migrations` DISABLE KEYS */; -INSERT INTO `schema_migrations` VALUES (1),(2),(3),(4),(5); -/*!40000 ALTER TABLE `schema_migrations` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `tuf_files` --- - -DROP TABLE IF EXISTS `tuf_files`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tuf_files` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - `deleted_at` timestamp NULL DEFAULT NULL, - `gun` varchar(255) NOT NULL, - `role` varchar(255) NOT NULL, - `version` int(11) NOT NULL, - `data` longblob NOT NULL, - `sha256` char(64) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `gun` (`gun`,`role`,`version`), - KEY `sha256` (`sha256`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `tuf_files` --- - -LOCK TABLES `tuf_files` WRITE; -/*!40000 ALTER TABLE `tuf_files` DISABLE KEYS */; -/*!40000 ALTER TABLE `tuf_files` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Current Database: `notarysigner` --- - -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `notarysigner` /*!40100 DEFAULT CHARACTER SET latin1 */; - -USE `notarysigner`; - --- --- Table structure for table `private_keys` --- - -DROP TABLE IF EXISTS `private_keys`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `private_keys` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - `deleted_at` timestamp NULL DEFAULT NULL, - `key_id` varchar(255) NOT NULL, - `encryption_alg` varchar(255) NOT NULL, - `keywrap_alg` varchar(255) NOT NULL, - `algorithm` varchar(50) NOT NULL, - `passphrase_alias` varchar(50) NOT NULL, - `public` blob NOT NULL, - `private` blob NOT NULL, - `gun` varchar(255) NOT NULL, - `role` varchar(255) NOT NULL, - `last_used` datetime DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `key_id` (`key_id`), - UNIQUE KEY `key_id_2` (`key_id`,`algorithm`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `private_keys` --- - -LOCK TABLES `private_keys` WRITE; -/*!40000 ALTER TABLE `private_keys` DISABLE KEYS */; -/*!40000 ALTER TABLE `private_keys` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `schema_migrations` --- - -DROP TABLE IF EXISTS `schema_migrations`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `schema_migrations` ( - `version` int(11) NOT NULL, - PRIMARY KEY (`version`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `schema_migrations` --- - -LOCK TABLES `schema_migrations` WRITE; -/*!40000 ALTER TABLE `schema_migrations` DISABLE KEYS */; -INSERT INTO `schema_migrations` VALUES (1),(2); -/*!40000 ALTER TABLE `schema_migrations` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2017-02-14 6:32:48 diff --git a/make/docker-compose.notary.yml b/make/docker-compose.notary.yml index 7738c221f..0b6340366 100644 --- a/make/docker-compose.notary.yml +++ b/make/docker-compose.notary.yml @@ -7,7 +7,7 @@ services: networks: - harbor-notary notary-server: - image: jiangd/notary:server-0.5.0-fix + image: vmware/notary-photon:server-0.5.0 container_name: notary-server networks: - notary-mdb @@ -16,7 +16,7 @@ services: volumes: - ./common/config/notary:/config entrypoint: /usr/bin/env sh - command: -c "notary-server -config=/config/server-config.json -logf=logfmt" + command: -c "/migrations/migrate.sh && notary-server -config=/config/server-config.json -logf=logfmt" depends_on: - notary-db - notary-signer @@ -26,7 +26,7 @@ services: syslog-address: "tcp://127.0.0.1:1514" tag: "notary-server" notary-signer: - image: notary:signer-0.5.0 + image: vmware/notary-photon:signer-0.5.0 container_name: notary-signer networks: notary-mdb: @@ -38,7 +38,7 @@ services: env_file: - ./common/config/notary/signer_env entrypoint: /usr/bin/env sh - command: -c "notary-signer -config=/config/signer-config.json -logf=logfmt" + command: -c "/migrations/migrate.sh && notary-signer -config=/config/signer-config.json -logf=logfmt" depends_on: - notary-db logging: @@ -47,7 +47,7 @@ services: syslog-address: "tcp://127.0.0.1:1514" tag: "notary-signer" notary-db: - image: mariadb:10.1.10 + image: vmware/harbor-notary-db:mariadb-10.1.10 container_name: notary-db networks: notary-mdb: @@ -56,8 +56,6 @@ services: volumes: - ./common/config/notary/mysql-initdb.d:/docker-entrypoint-initdb.d - /data/notary-db:/var/lib/mysql - ports: - - "3306:3306" environment: - TERM=dumb - MYSQL_ALLOW_EMPTY_PASSWORD="true" diff --git a/make/photon/ui/Dockerfile b/make/photon/ui/Dockerfile index 039d1603a..6b1e067c1 100644 --- a/make/photon/ui/Dockerfile +++ b/make/photon/ui/Dockerfile @@ -7,6 +7,7 @@ COPY ./make/dev/ui/harbor_ui /harbor/ COPY ./src/ui/views /harbor/views COPY ./src/ui/static /harbor/static COPY ./src/favicon.ico /harbor/favicon.ico +COPY ./VERSION /harbor/VERSION RUN chmod u+x /harbor/harbor_ui diff --git a/src/ui/api/systeminfo.go b/src/ui/api/systeminfo.go index 073dc246a..88dff92bc 100644 --- a/src/ui/api/systeminfo.go +++ b/src/ui/api/systeminfo.go @@ -1,6 +1,7 @@ package api import ( + "io/ioutil" "net/http" "os" "strings" @@ -20,6 +21,7 @@ type SystemInfoAPI struct { } const defaultRootCert = "/harbor_storage/ca_download/ca.crt" +const harborVersionFile = "/harbor/VERSION" //SystemInfo models for system info. type SystemInfo struct { @@ -42,6 +44,7 @@ type GeneralInfo struct { ProjectCreationRestrict string `json:"project_creation_restriction"` SelfRegistration bool `json:"self_registration"` HasCARoot bool `json:"has_ca_root"` + HarborVersion string `json:"harbor_version"` } // validate for validating user if an admin. @@ -113,6 +116,7 @@ func (sia *SystemInfoAPI) GetGeneralInfo() { registryURL = l[0] } _, caStatErr := os.Stat(defaultRootCert) + harborVersion := sia.getVersion() info := GeneralInfo{ AdmiralEndpoint: cfg[common.AdmiralEndpoint].(string), WithAdmiral: config.WithAdmiral(), @@ -122,7 +126,18 @@ func (sia *SystemInfoAPI) GetGeneralInfo() { SelfRegistration: cfg[common.SelfRegistration].(bool), RegistryURL: registryURL, HasCARoot: caStatErr == nil, + HarborVersion: harborVersion, } sia.Data["json"] = info sia.ServeJSON() } + +// GetVersion gets harbor version. +func (sia *SystemInfoAPI) getVersion() string { + version, err := ioutil.ReadFile(harborVersionFile) + if err != nil { + log.Errorf("Error occured getting harbor version: %v", err) + return "" + } + return string(version[:]) +} diff --git a/src/ui/api/systeminfo_test.go b/src/ui/api/systeminfo_test.go index 80892fd84..26a259ba4 100644 --- a/src/ui/api/systeminfo_test.go +++ b/src/ui/api/systeminfo_test.go @@ -3,8 +3,9 @@ package api import ( "encoding/json" "fmt" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestGetVolumeInfo(t *testing.T) { @@ -49,6 +50,7 @@ func TestGetGeneralInfo(t *testing.T) { assert.Nil(err, fmt.Sprintf("Unexpected Error: %v", err)) assert.Equal(false, g.WithNotary, "with notary should be false") assert.Equal(true, g.HasCARoot, "has ca root should be true") + assert.NotEmpty(g.HarborVersion, "harbor version should not be empty") } func TestGetCert(t *testing.T) { diff --git a/src/ui/router.go b/src/ui/router.go index e6b4bd930..c95fedb69 100644 --- a/src/ui/router.go +++ b/src/ui/router.go @@ -62,7 +62,7 @@ func initRouters() { //API: beego.Router("/api/search", &api.SearchAPI{}) beego.Router("/api/projects/:pid([0-9]+)/members/?:mid", &api.ProjectMemberAPI{}) - beego.Router("/api/projects/", &api.ProjectAPI{}, "get:List;post:Post") + beego.Router("/api/projects/", &api.ProjectAPI{}, "get:List;post:Post;head:Head") beego.Router("/api/projects/:id([0-9]+)", &api.ProjectAPI{}) beego.Router("/api/projects/:id([0-9]+)/publicity", &api.ProjectAPI{}, "put:ToggleProjectPublic") beego.Router("/api/projects/:id([0-9]+)/logs/filter", &api.ProjectAPI{}, "post:FilterAccessLog") diff --git a/src/ui_ng/src/app/account/password/password-setting.component.html b/src/ui_ng/src/app/account/password/password-setting.component.html index 8a48f6d47..0ecc01d30 100644 --- a/src/ui_ng/src/app/account/password/password-setting.component.html +++ b/src/ui_ng/src/app/account/password/password-setting.component.html @@ -7,11 +7,11 @@