背景
关于java中调用Harbor API的文章不多,在开发镜像下载功能时正好要调用该API,在此做下记录
一 pom文件配置
<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.7.18</version> </dependency>
二 yml文件配置
harbor: url: harbor的ip username: xxxxx password: xxxxx project_name: project-test repository_user: user-local repository_data: data-local
三 api操作
1 创建项目
String url = harborUrl+"/projects"; String auth = username + ":" + password; String authHeader = "Basic " + Base64.getEncoder().encodeToString(auth.getBytes(StandardCharsets.US_ASCII)); JSONObject projectHarbor = new JSONObject(); projectHarbor.putOpt(&#