feat: proxy download image
This commit is contained in:
		
							
								
								
									
										16
									
								
								front/.editorconfig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								front/.editorconfig
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| # Editor configuration, see https://editorconfig.org | ||||
| root = true | ||||
|  | ||||
| [*] | ||||
| charset = utf-8 | ||||
| indent_style = space | ||||
| indent_size = 2 | ||||
| insert_final_newline = true | ||||
| trim_trailing_whitespace = true | ||||
|  | ||||
| [*.ts] | ||||
| quote_type = single | ||||
|  | ||||
| [*.md] | ||||
| max_line_length = off | ||||
| trim_trailing_whitespace = false | ||||
							
								
								
									
										42
									
								
								front/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								front/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| # See http://help.github.com/ignore-files/ for more about ignoring files. | ||||
|  | ||||
| # Compiled output | ||||
| /dist | ||||
| /tmp | ||||
| /out-tsc | ||||
| /bazel-out | ||||
|  | ||||
| # Node | ||||
| /node_modules | ||||
| npm-debug.log | ||||
| yarn-error.log | ||||
|  | ||||
| # IDEs and editors | ||||
| .idea/ | ||||
| .project | ||||
| .classpath | ||||
| .c9/ | ||||
| *.launch | ||||
| .settings/ | ||||
| *.sublime-workspace | ||||
|  | ||||
| # Visual Studio Code | ||||
| .vscode/* | ||||
| !.vscode/settings.json | ||||
| !.vscode/tasks.json | ||||
| !.vscode/launch.json | ||||
| !.vscode/extensions.json | ||||
| .history/* | ||||
|  | ||||
| # Miscellaneous | ||||
| /.angular/cache | ||||
| .sass-cache/ | ||||
| /connect.lock | ||||
| /coverage | ||||
| /libpeerconnection.log | ||||
| testem.log | ||||
| /typings | ||||
|  | ||||
| # System files | ||||
| .DS_Store | ||||
| Thumbs.db | ||||
							
								
								
									
										27
									
								
								front/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								front/README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| # Front | ||||
|  | ||||
| This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.3.4. | ||||
|  | ||||
| ## Development server | ||||
|  | ||||
| Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files. | ||||
|  | ||||
| ## Code scaffolding | ||||
|  | ||||
| Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. | ||||
|  | ||||
| ## Build | ||||
|  | ||||
| Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. | ||||
|  | ||||
| ## Running unit tests | ||||
|  | ||||
| Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). | ||||
|  | ||||
| ## Running end-to-end tests | ||||
|  | ||||
| Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. | ||||
|  | ||||
| ## Further help | ||||
|  | ||||
| To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. | ||||
							
								
								
									
										110
									
								
								front/angular.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								front/angular.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,110 @@ | ||||
| { | ||||
|   "$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||||
|   "version": 1, | ||||
|   "cli": { | ||||
|     "packageManager": "pnpm", | ||||
|     "analytics": false | ||||
|   }, | ||||
|   "newProjectRoot": "projects", | ||||
|   "projects": { | ||||
|     "front": { | ||||
|       "projectType": "application", | ||||
|       "schematics": { | ||||
|         "@schematics/angular:component": { | ||||
|           "style": "scss" | ||||
|         } | ||||
|       }, | ||||
|       "root": "", | ||||
|       "sourceRoot": "src", | ||||
|       "prefix": "app", | ||||
|       "architect": { | ||||
|         "build": { | ||||
|           "builder": "@angular-devkit/build-angular:application", | ||||
|           "options": { | ||||
|             "outputPath": "dist/front", | ||||
|             "index": "src/index.html", | ||||
|             "browser": "src/main.ts", | ||||
|             "polyfills": [ | ||||
|               "zone.js" | ||||
|             ], | ||||
|             "tsConfig": "tsconfig.app.json", | ||||
|             "inlineStyleLanguage": "scss", | ||||
|             "assets": [ | ||||
|               "src/favicon.ico", | ||||
|               "src/assets" | ||||
|             ], | ||||
|             "styles": [ | ||||
|               "@angular/material/prebuilt-themes/indigo-pink.css", | ||||
|               "src/styles.scss" | ||||
|             ], | ||||
|             "scripts": [] | ||||
|           }, | ||||
|           "configurations": { | ||||
|             "production": { | ||||
|               "budgets": [ | ||||
|                 { | ||||
|                   "type": "initial", | ||||
|                   "maximumWarning": "500kb", | ||||
|                   "maximumError": "1mb" | ||||
|                 }, | ||||
|                 { | ||||
|                   "type": "anyComponentStyle", | ||||
|                   "maximumWarning": "2kb", | ||||
|                   "maximumError": "4kb" | ||||
|                 } | ||||
|               ], | ||||
|               "outputHashing": "all" | ||||
|             }, | ||||
|             "development": { | ||||
|               "optimization": false, | ||||
|               "extractLicenses": false, | ||||
|               "sourceMap": true | ||||
|             } | ||||
|           }, | ||||
|           "defaultConfiguration": "production" | ||||
|         }, | ||||
|         "serve": { | ||||
|           "builder": "@angular-devkit/build-angular:dev-server", | ||||
|           "options": { | ||||
|             "proxyConfig": "src/proxy.conf.json" | ||||
|           }, | ||||
|           "configurations": { | ||||
|             "production": { | ||||
|               "buildTarget": "front:build:production" | ||||
|             }, | ||||
|             "development": { | ||||
|               "buildTarget": "front:build:development" | ||||
|             } | ||||
|           }, | ||||
|           "defaultConfiguration": "development" | ||||
|         }, | ||||
|         "extract-i18n": { | ||||
|           "builder": "@angular-devkit/build-angular:extract-i18n", | ||||
|           "options": { | ||||
|             "buildTarget": "front:build" | ||||
|           } | ||||
|         }, | ||||
|         "test": { | ||||
|           "builder": "@angular-devkit/build-angular:karma", | ||||
|           "options": { | ||||
|             "polyfills": [ | ||||
|               "zone.js", | ||||
|               "zone.js/testing" | ||||
|             ], | ||||
|             "tsConfig": "tsconfig.spec.json", | ||||
|             "inlineStyleLanguage": "scss", | ||||
|             "assets": [ | ||||
|               "src/favicon.ico", | ||||
|               "src/assets" | ||||
|             ], | ||||
|             "styles": [ | ||||
|               "@angular/material/prebuilt-themes/indigo-pink.css", | ||||
|               "src/styles.scss" | ||||
|             ], | ||||
|             "scripts": [] | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
							
								
								
									
										41
									
								
								front/package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								front/package.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| { | ||||
|   "name": "front", | ||||
|   "version": "0.0.0", | ||||
|   "scripts": { | ||||
|     "ng": "ng", | ||||
|     "start": "ng serve", | ||||
|     "build": "ng build", | ||||
|     "watch": "ng build --watch --configuration development", | ||||
|     "test": "ng test" | ||||
|   }, | ||||
|   "private": true, | ||||
|   "dependencies": { | ||||
|     "@angular/animations": "^17.3.0", | ||||
|     "@angular/cdk": "17.3.4", | ||||
|     "@angular/common": "^17.3.0", | ||||
|     "@angular/compiler": "^17.3.0", | ||||
|     "@angular/core": "^17.3.0", | ||||
|     "@angular/forms": "^17.3.0", | ||||
|     "@angular/material": "17.3.4", | ||||
|     "@angular/material-experimental": "17.3.4", | ||||
|     "@angular/platform-browser": "^17.3.0", | ||||
|     "@angular/platform-browser-dynamic": "^17.3.0", | ||||
|     "@angular/router": "^17.3.0", | ||||
|     "rxjs": "~7.8.0", | ||||
|     "tslib": "^2.3.0", | ||||
|     "zone.js": "~0.14.3" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@angular-devkit/build-angular": "^17.3.4", | ||||
|     "@angular/cli": "^17.3.4", | ||||
|     "@angular/compiler-cli": "^17.3.0", | ||||
|     "@types/jasmine": "~5.1.0", | ||||
|     "jasmine-core": "~5.1.0", | ||||
|     "karma": "~6.4.0", | ||||
|     "karma-chrome-launcher": "~3.2.0", | ||||
|     "karma-coverage": "~2.2.0", | ||||
|     "karma-jasmine": "~5.1.0", | ||||
|     "karma-jasmine-html-reporter": "~2.1.0", | ||||
|     "typescript": "~5.4.2" | ||||
|   } | ||||
| } | ||||
							
								
								
									
										8107
									
								
								front/pnpm-lock.yaml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										8107
									
								
								front/pnpm-lock.yaml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										97
									
								
								front/src/app/app.component.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								front/src/app/app.component.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,97 @@ | ||||
| <div> | ||||
|   <mat-toolbar color="primary"> | ||||
|     <button mat-icon-button class="favorite-icon" aria-label="icon-button with heart icon"> | ||||
|       <mat-icon>favorite</mat-icon> | ||||
|     </button> | ||||
|     <span>NF Repo</span> | ||||
|  | ||||
|     <div style="margin-left:auto;"> | ||||
|       <button mat-icon-button matTooltip="帮我下载镜像" (click)="downloadImage()"> | ||||
|         <mat-icon>cloud_download</mat-icon> | ||||
|       </button> | ||||
|     </div> | ||||
|   </mat-toolbar> | ||||
| </div> | ||||
| <div> | ||||
|  | ||||
|   <mat-form-field class="search-field" appearance="outline" subscriptSizing="dynamic"> | ||||
|     <mat-label>搜索镜像</mat-label> | ||||
|     <input matInput type="text" [formControl]="keyword" (change)="search()"> | ||||
|     <button matSuffix mat-icon-button matTooltip="搜索" (click)="search()"> | ||||
|       <mat-icon>search</mat-icon> | ||||
|     </button> | ||||
|   </mat-form-field> | ||||
|  | ||||
|   <table mat-table [dataSource]="repo_svc.catalog().list" multiTemplateDataRows> | ||||
|  | ||||
|     <ng-container matColumnDef="expand"> | ||||
|       <th mat-header-cell *matHeaderCellDef aria-label="row actions"> </th> | ||||
|       <td mat-cell *matCellDef="let element"> | ||||
|         <button mat-icon-button aria-label="expand row" (click)="showTags($event, element)"> | ||||
|           @if (expandedElement === element) { | ||||
|             <mat-icon>keyboard_arrow_up</mat-icon> | ||||
|           } @else { | ||||
|             <mat-icon>keyboard_arrow_down</mat-icon> | ||||
|           } | ||||
|         </button> | ||||
|       </td> | ||||
|     </ng-container> | ||||
|  | ||||
|     <ng-container matColumnDef="id"> | ||||
|       <th mat-header-cell *matHeaderCellDef>ID</th> | ||||
|       <td mat-cell *matCellDef="let element"> {{ element.id }}</td> | ||||
|     </ng-container> | ||||
|  | ||||
|     <ng-container matColumnDef="updated_at"> | ||||
|       <th mat-header-cell *matHeaderCellDef>更新时间</th> | ||||
|       <td mat-cell *matCellDef="let element"> {{ element.updated_at | date:'yy-MM-dd HH:mm:ss' }}</td> | ||||
|     </ng-container> | ||||
|  | ||||
|     <ng-container matColumnDef="repo"> | ||||
|       <th mat-header-cell *matHeaderCellDef>镜像</th> | ||||
|       <td mat-cell *matCellDef="let element"> {{ element.repo }}</td> | ||||
|     </ng-container> | ||||
|  | ||||
|     <ng-container matColumnDef="tag"> | ||||
|       <th mat-header-cell *matHeaderCellDef>标签</th> | ||||
|       <td mat-cell *matCellDef="let element"> {{ element.tag }}</td> | ||||
|     </ng-container> | ||||
|  | ||||
|     <ng-container matColumnDef="size"> | ||||
|       <th mat-header-cell *matHeaderCellDef>占用</th> | ||||
|       <td mat-cell *matCellDef="let element"> {{ element.size | capacity }}</td> | ||||
|     </ng-container> | ||||
|  | ||||
|     <ng-container matColumnDef="operation"> | ||||
|       <th mat-header-cell *matHeaderCellDef>操作</th> | ||||
|       <td mat-cell *matCellDef="let element" style="padding-left: 4px !important;"> | ||||
|         <button mat-icon-button matTooltip="复制镜像地址" (click)="copyImageCommand(element)"> | ||||
|           <mat-icon>file_copy</mat-icon> | ||||
|         </button> | ||||
|       </td> | ||||
|     </ng-container> | ||||
|  | ||||
|  | ||||
|     <ng-container matColumnDef="expandedDetail"> | ||||
|       <td mat-cell *matCellDef="let element" [attr.colspan]="columnsToDisplayWithExpand.length"> | ||||
|         <div class="repo-element-detail" | ||||
|              [@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'"> | ||||
|           @if (element.Tags) { | ||||
|             @for (tag of element.Tags.list; track tag) { | ||||
|               <mat-chip-option color="primary">{{ tag.tag }}</mat-chip-option> | ||||
|             } | ||||
|           } | ||||
|         </div> | ||||
|       </td> | ||||
|     </ng-container> | ||||
|  | ||||
|  | ||||
|     <tr mat-header-row *matHeaderRowDef="columnsToDisplayWithExpand"></tr> | ||||
|     <tr mat-row *matRowDef="let element; columns: columnsToDisplayWithExpand;" | ||||
|         class="repo-element-row" | ||||
|         [class.repo-expanded-row]="expandedElement === element" | ||||
|         (click)="expandedElement = expandedElement === element ? null : element"> | ||||
|     </tr> | ||||
|     <tr mat-row *matRowDef="let row; columns: ['expandedDetail']" class="repo-detail-row"></tr> | ||||
|   </table> | ||||
| </div> | ||||
							
								
								
									
										36
									
								
								front/src/app/app.component.scss
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								front/src/app/app.component.scss
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | ||||
| mat-form-field.search-field { | ||||
|   margin-top: 1rem; | ||||
|   margin-left: 1rem; | ||||
|   min-width: 40rem; | ||||
| } | ||||
|  | ||||
| table { | ||||
|   width: 100%; | ||||
| } | ||||
|  | ||||
| tr.repo-detail-row { | ||||
|   height: 0; | ||||
| } | ||||
|  | ||||
| tr.repo-element-row:not(.repo-expanded-row):hover { | ||||
|   background: whitesmoke; | ||||
| } | ||||
|  | ||||
| tr.repo-element-row:not(.repo-expanded-row):active { | ||||
|   background: #efefef; | ||||
| } | ||||
|  | ||||
| .repo-element-row td { | ||||
|   border-bottom-width: 0; | ||||
| } | ||||
|  | ||||
| .repo-element-detail { | ||||
|   overflow: hidden; | ||||
|   display: flex; | ||||
| } | ||||
|  | ||||
| mat-chip-option { | ||||
|   margin-bottom: 1rem; | ||||
|   margin-right: 1rem; | ||||
| } | ||||
|  | ||||
							
								
								
									
										29
									
								
								front/src/app/app.component.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								front/src/app/app.component.spec.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| import { TestBed } from '@angular/core/testing'; | ||||
| import { AppComponent } from './app.component'; | ||||
|  | ||||
| describe('AppComponent', () => { | ||||
|   beforeEach(async () => { | ||||
|     await TestBed.configureTestingModule({ | ||||
|       imports: [AppComponent], | ||||
|     }).compileComponents(); | ||||
|   }); | ||||
|  | ||||
|   it('should create the app', () => { | ||||
|     const fixture = TestBed.createComponent(AppComponent); | ||||
|     const app = fixture.componentInstance; | ||||
|     expect(app).toBeTruthy(); | ||||
|   }); | ||||
|  | ||||
|   it(`should have the 'front' title`, () => { | ||||
|     const fixture = TestBed.createComponent(AppComponent); | ||||
|     const app = fixture.componentInstance; | ||||
|     expect(app.title).toEqual('front'); | ||||
|   }); | ||||
|  | ||||
|   it('should render title', () => { | ||||
|     const fixture = TestBed.createComponent(AppComponent); | ||||
|     fixture.detectChanges(); | ||||
|     const compiled = fixture.nativeElement as HTMLElement; | ||||
|     expect(compiled.querySelector('h1')?.textContent).toContain('Hello, front'); | ||||
|   }); | ||||
| }); | ||||
							
								
								
									
										100
									
								
								front/src/app/app.component.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										100
									
								
								front/src/app/app.component.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,100 @@ | ||||
| import {Component} from '@angular/core'; | ||||
| import {Repo} from "./interface/repo"; | ||||
| import {RepoService} from "./service/repo.service"; | ||||
| import {FormControl, ReactiveFormsModule} from "@angular/forms"; | ||||
| import {MatToolbar} from "@angular/material/toolbar"; | ||||
| import {MatIconButton} from "@angular/material/button"; | ||||
| import {MatFormField, MatLabel, MatSuffix} from "@angular/material/form-field"; | ||||
| import {MatTooltip} from "@angular/material/tooltip"; | ||||
| import {MatIcon} from "@angular/material/icon"; | ||||
| import {MatInput} from "@angular/material/input"; | ||||
| import {Clipboard} from '@angular/cdk/clipboard'; | ||||
| import { | ||||
|   MatCell, | ||||
|   MatCellDef, | ||||
|   MatColumnDef, | ||||
|   MatHeaderCell, | ||||
|   MatHeaderCellDef, | ||||
|   MatHeaderRow, MatHeaderRowDef, MatRow, MatRowDef, | ||||
|   MatTable | ||||
| } from "@angular/material/table"; | ||||
| import {DatePipe} from "@angular/common"; | ||||
| import {animate, state, style, transition, trigger} from "@angular/animations"; | ||||
| import {MatChipOption} from "@angular/material/chips"; | ||||
| import {MatDialog} from "@angular/material/dialog"; | ||||
| import {DownloadImageComponent} from "./component/download-image/download-image.component"; | ||||
| import {CapacityPipe} from "./pipe/capacity.pipe"; | ||||
|  | ||||
| @Component({ | ||||
|   selector: 'app-root', | ||||
|   standalone: true, | ||||
|   imports: [ | ||||
|     MatToolbar, | ||||
|     MatIconButton, | ||||
|     MatSuffix, | ||||
|     MatTooltip, | ||||
|     MatIcon, | ||||
|     MatFormField, | ||||
|     MatInput, | ||||
|     ReactiveFormsModule, | ||||
|     MatTable, | ||||
|     MatColumnDef, | ||||
|     MatHeaderCell, | ||||
|     MatHeaderCellDef, | ||||
|     MatCell, | ||||
|     MatCellDef, | ||||
|     MatHeaderRow, | ||||
|     MatRow, | ||||
|     MatHeaderRowDef, | ||||
|     MatRowDef, | ||||
|     MatLabel, | ||||
|     DatePipe, | ||||
|     MatChipOption, | ||||
|     CapacityPipe, | ||||
|   ], | ||||
|   templateUrl: './app.component.html', | ||||
|   styleUrl: './app.component.scss', | ||||
|   animations: [ | ||||
|     trigger('detailExpand', [ | ||||
|       state('collapsed', style({height: '0px', minHeight: '0'})), | ||||
|       state('expanded', style({height: '*'})), | ||||
|       transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')), | ||||
|     ]), | ||||
|   ], | ||||
| }) | ||||
| export class AppComponent { | ||||
|   title = 'front'; | ||||
|   columnsToDisplay: string[] = ['id', 'updated_at', "repo", "tag", 'size', 'operation']; | ||||
|   columnsToDisplayWithExpand = ['expand', ...this.columnsToDisplay]; | ||||
|   expandedElement: Repo | null = null; | ||||
|   keyword = new FormControl(''); | ||||
|  | ||||
|   constructor( | ||||
|     public repo_svc: RepoService, | ||||
|     private clipboard: Clipboard, | ||||
|     public dialog: MatDialog, | ||||
|   ) { | ||||
|     this.downloadImage() | ||||
|   } | ||||
|  | ||||
|   search(limit: number = 20, last: number = 0) { | ||||
|     this.repo_svc.GetCatalog(limit, last, this.keyword.value ?? '') | ||||
|   } | ||||
|  | ||||
|   showTags(event: Event, element: Repo) { | ||||
|     if (!(this.expandedElement === element)) { | ||||
|       this.repo_svc.GetTags(element.repo) | ||||
|     } | ||||
|  | ||||
|     this.expandedElement = this.expandedElement === element ? null : element; | ||||
|     event.stopPropagation() | ||||
|   } | ||||
|  | ||||
|   copyImageCommand(item: Repo) { | ||||
|     this.clipboard.copy(`docker pull ${this.repo_svc.settings().base_address}/${item.repo}:${item.tag}`) | ||||
|   } | ||||
|  | ||||
|   downloadImage() { | ||||
|     this.dialog.open(DownloadImageComponent, {data: {}}) | ||||
|   } | ||||
| } | ||||
							
								
								
									
										19
									
								
								front/src/app/app.config.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								front/src/app/app.config.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| import {ApplicationConfig} from '@angular/core'; | ||||
| import {provideRouter} from '@angular/router'; | ||||
|  | ||||
| import {routes} from './app.routes'; | ||||
| import {alerterInterceptor} from "./interceptor/alerter.interceptor"; | ||||
| import {HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi} from "@angular/common/http"; | ||||
| import {provideAnimations} from "@angular/platform-browser/animations"; | ||||
|  | ||||
|  | ||||
| export const appConfig: ApplicationConfig = { | ||||
|   providers: [ | ||||
|     provideRouter(routes), | ||||
|     provideHttpClient(withInterceptorsFromDi()), { | ||||
|       provide: HTTP_INTERCEPTORS, useClass: alerterInterceptor, multi: true | ||||
|     }, | ||||
|     provideAnimations(), | ||||
|   ] | ||||
| }; | ||||
|  | ||||
							
								
								
									
										3
									
								
								front/src/app/app.routes.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								front/src/app/app.routes.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| import { Routes } from '@angular/router'; | ||||
|  | ||||
| export const routes: Routes = []; | ||||
| @@ -0,0 +1,36 @@ | ||||
| <h2 mat-dialog-title>{{ title }}</h2> | ||||
| <div class="content"> | ||||
|   <div [class]="inProgress? 'download-overlay in-progress':'download-overlay'"> | ||||
|     <mat-spinner></mat-spinner> | ||||
|   </div> | ||||
|   <div [class]="inProgress? 'forms in-progress':'forms'"> | ||||
|     <mat-dialog-content class="mat-typography"> | ||||
|       <p> | ||||
|         <mat-form-field appearance="outline"> | ||||
|           <mat-label>云上镜像名称</mat-label> | ||||
|           <input matInput placeholder="golang:1.22.2-alpine3.19" [(ngModel)]="source"> | ||||
|           <mat-icon matSuffix>clear</mat-icon> | ||||
|         </mat-form-field> | ||||
|       </p> | ||||
|       <p> | ||||
|         <mat-form-field appearance="outline"> | ||||
|           <mat-label style="margin-left: 1.5rem">本地镜像名称</mat-label> | ||||
|           <span matTextPrefix>{{ repo_svc.settings().base_address + '/ ' }}</span> | ||||
|           <input matInput placeholder="external/golang:latest" [(ngModel)]="target"> | ||||
|           <mat-icon matSuffix>clear</mat-icon> | ||||
|         </mat-form-field> | ||||
|       </p> | ||||
|       <p> | ||||
|         <mat-form-field appearance="outline"> | ||||
|           <mat-label>代理</mat-label> | ||||
|           <input matInput placeholder="socks5://127.0.0.1:7890" [(ngModel)]="proxy"> | ||||
|           <mat-icon matSuffix>clear</mat-icon> | ||||
|         </mat-form-field> | ||||
|       </p> | ||||
|     </mat-dialog-content> | ||||
|     <mat-dialog-actions align="end"> | ||||
|       <button mat-button mat-dialog-close>取消</button> | ||||
|       <button mat-button cdkFocusInitial color="primary" (click)="proxyDownload()">下载</button> | ||||
|     </mat-dialog-actions> | ||||
|   </div> | ||||
| </div> | ||||
| @@ -0,0 +1,38 @@ | ||||
| mat-dialog-content { | ||||
|   min-width: 40rem; | ||||
|  | ||||
|   p { | ||||
|     width: 100%; | ||||
|   } | ||||
|  | ||||
|   mat-form-field { | ||||
|     width: 100%; | ||||
|   } | ||||
| } | ||||
|  | ||||
| div.content { | ||||
|   position: relative; | ||||
|  | ||||
|   div.download-overlay { | ||||
|     position: absolute; | ||||
|     width: 100%; | ||||
|     height: 100%; | ||||
|     display: none; | ||||
|     align-items: center; | ||||
|     justify-content: center; | ||||
|     margin-top: -2rem; | ||||
|     z-index: 1000; | ||||
|  | ||||
|     &.in-progress { | ||||
|       display: flex; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   div.forms { | ||||
|     opacity: 1; | ||||
|  | ||||
|     &.in-progress { | ||||
|       opacity: .3; | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @@ -0,0 +1,23 @@ | ||||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||||
|  | ||||
| import { DownloadImageComponent } from './download-image.component'; | ||||
|  | ||||
| describe('DownloadImageComponent', () => { | ||||
|   let component: DownloadImageComponent; | ||||
|   let fixture: ComponentFixture<DownloadImageComponent>; | ||||
|  | ||||
|   beforeEach(async () => { | ||||
|     await TestBed.configureTestingModule({ | ||||
|       imports: [DownloadImageComponent] | ||||
|     }) | ||||
|     .compileComponents(); | ||||
|      | ||||
|     fixture = TestBed.createComponent(DownloadImageComponent); | ||||
|     component = fixture.componentInstance; | ||||
|     fixture.detectChanges(); | ||||
|   }); | ||||
|  | ||||
|   it('should create', () => { | ||||
|     expect(component).toBeTruthy(); | ||||
|   }); | ||||
| }); | ||||
| @@ -0,0 +1,106 @@ | ||||
| import {Component} from '@angular/core'; | ||||
| import { | ||||
|   MatDialogActions, | ||||
|   MatDialogClose, | ||||
|   MatDialogContent, | ||||
|   MatDialogRef, | ||||
|   MatDialogTitle | ||||
| } from "@angular/material/dialog"; | ||||
| import {MatButton} from "@angular/material/button"; | ||||
| import {MatFormField, MatLabel, MatPrefix, MatSuffix} from "@angular/material/form-field"; | ||||
| import {MatInput} from "@angular/material/input"; | ||||
| import {MatIcon} from "@angular/material/icon"; | ||||
| import {RepoService} from "../../service/repo.service"; | ||||
| import {HttpClient} from "@angular/common/http"; | ||||
| import {FormsModule} from "@angular/forms"; | ||||
| import {CdkConnectedOverlay, CdkOverlayOrigin} from "@angular/cdk/overlay"; | ||||
| import {MatProgressSpinner} from "@angular/material/progress-spinner"; | ||||
| import {MsgService} from "../../service/msg.service"; | ||||
|  | ||||
| @Component({ | ||||
|   selector: 'app-download-image', | ||||
|   standalone: true, | ||||
|   imports: [ | ||||
|     MatDialogTitle, | ||||
|     MatDialogContent, | ||||
|     MatDialogActions, | ||||
|     MatDialogClose, | ||||
|     MatButton, | ||||
|     MatLabel, | ||||
|     MatInput, | ||||
|     MatSuffix, | ||||
|     MatIcon, | ||||
|     MatFormField, | ||||
|     MatPrefix, | ||||
|     FormsModule, | ||||
|     CdkConnectedOverlay, | ||||
|     MatProgressSpinner, | ||||
|     CdkOverlayOrigin | ||||
|   ], | ||||
|   templateUrl: './download-image.component.html', | ||||
|   styleUrl: './download-image.component.scss' | ||||
| }) | ||||
| export class DownloadImageComponent { | ||||
|  | ||||
|   target = '' | ||||
|   source = '' | ||||
|   proxy = '' | ||||
|   title = '下载云上镜像' | ||||
|   inProgress = false | ||||
|  | ||||
|   readonly url_proxy_download = '/api/repo/proxy' | ||||
|  | ||||
|   constructor( | ||||
|     public repo_svc: RepoService, | ||||
|     private dialogRef: MatDialogRef<DownloadImageComponent>, | ||||
|     private msg_svc: MsgService, | ||||
|   ) { | ||||
|     let evt = new EventSource(this.url_proxy_download) | ||||
|     evt.onmessage = (ev: MessageEvent) => { | ||||
|       console.log('[D] event source on message =', ev) | ||||
|     } | ||||
|     evt.onerror = (ev: Event) => { | ||||
|       console.log('[D] event source on error=', ev) | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   async proxyDownload() { | ||||
|     const response = await fetch(this.url_proxy_download, { | ||||
|       method: "POST", | ||||
|       body: JSON.stringify({target: this.target, source: this.source, proxy: this.proxy}), | ||||
|       headers: {"Content-Type": "application/json"}, | ||||
|     }) | ||||
|     const reader = response.body?.pipeThrough(new TextDecoderStream()).getReader() | ||||
|     if (reader) { | ||||
|       this.inProgress = true | ||||
|       while (true) { | ||||
|         const {value, done} = await reader.read() | ||||
|         if (done) { | ||||
|           break; | ||||
|         } | ||||
|  | ||||
|         if (value) { | ||||
|           const msgs = value.split('\n') | ||||
|           if (msgs.length > 2) { | ||||
|             const sse_type = msgs[0].slice(6) | ||||
|             const sse_data = msgs[1].slice(5) | ||||
|             const sse_json = JSON.parse(sse_data) | ||||
|             if (sse_json['msg']) { | ||||
|               this.title = sse_json['msg'] | ||||
|             } | ||||
|  | ||||
|             if (sse_json['action'] && sse_json['action'] === 'done') { | ||||
|               this.repo_svc.GetCatalog(this.repo_svc.catalog().limit, this.repo_svc.catalog().last, this.repo_svc.catalog().keyword) | ||||
|               this.msg_svc.success('获取镜像成功') | ||||
|               this.dialogRef.close() | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|  | ||||
|     } | ||||
|  | ||||
|     this.inProgress = false | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										52
									
								
								front/src/app/interceptor/alerter.interceptor.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								front/src/app/interceptor/alerter.interceptor.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| import { | ||||
|   HttpEvent, | ||||
|   HttpHandler, | ||||
|   HttpInterceptor, | ||||
|   HttpRequest, | ||||
|   HttpResponse | ||||
| } from '@angular/common/http'; | ||||
| import {map, Observable} from "rxjs"; | ||||
| import {Response} from "../interface/response"; | ||||
| import {MsgService} from "../service/msg.service"; | ||||
| import {Router} from "@angular/router"; | ||||
| import {Injectable} from "@angular/core"; | ||||
|  | ||||
| // import {MsgService} from "../service/msg.service"; | ||||
|  | ||||
|  | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
| }) | ||||
| export class alerterInterceptor implements HttpInterceptor { | ||||
|   constructor( | ||||
|     private msg_srv: MsgService, | ||||
|     private router: Router, | ||||
|   ) { | ||||
|   } | ||||
|  | ||||
|   intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | ||||
|     // const nr = req.clone().headers.set("Authorization", localStorage.getItem("ult-token")) | ||||
|     req = req.clone({headers: req.headers.append("Authorization", localStorage.getItem("ult-token") ?? "")}) | ||||
|     return next.handle(req).pipe( | ||||
|       map((event) => { | ||||
|         if (event instanceof HttpResponse) { | ||||
|           try { | ||||
|             const rs = (event.body) as Response<any> | ||||
|             console.log(`[D] ${req.method} - ${req.url} =>`, rs) | ||||
|             if (rs.status > 200) { | ||||
|               this.msg_srv.error(rs.msg) | ||||
|             } | ||||
|  | ||||
|             if (rs.status === 401) { | ||||
|               this.router.navigate(['login']) | ||||
|             } | ||||
|           } catch (e) { | ||||
|            console.warn('[E] http err=',e) | ||||
|             this.msg_srv.error('无法连接服务器') | ||||
|           } | ||||
|         } | ||||
|         return event | ||||
|       }) | ||||
|     ); | ||||
|   } | ||||
| } | ||||
							
								
								
									
										21
									
								
								front/src/app/interface/repo.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								front/src/app/interface/repo.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| export interface Repo { | ||||
|   id: number | ||||
|   created_at: number | ||||
|   updated_at: number | ||||
|   digest_id: number | ||||
|   digest: string | ||||
|   size: number | ||||
|   repo: string | ||||
|   tag: string | ||||
|   Tags: { | ||||
|     list: Repo[] | ||||
|     total: number | ||||
|     limit: number | ||||
|     last: number | ||||
|     keyword: string | ||||
|   } | ||||
| } | ||||
|  | ||||
| export interface Settings { | ||||
|   base_address: string | ||||
| } | ||||
							
								
								
									
										5
									
								
								front/src/app/interface/response.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								front/src/app/interface/response.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| export interface Response<T> { | ||||
|   status: number; | ||||
|   msg: string; | ||||
|   data: T; | ||||
| } | ||||
							
								
								
									
										8
									
								
								front/src/app/pipe/capacity.pipe.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								front/src/app/pipe/capacity.pipe.spec.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| import { CapacityPipe } from './capacity.pipe'; | ||||
|  | ||||
| describe('CapacityPipe', () => { | ||||
|   it('create an instance', () => { | ||||
|     const pipe = new CapacityPipe(); | ||||
|     expect(pipe).toBeTruthy(); | ||||
|   }); | ||||
| }); | ||||
							
								
								
									
										20
									
								
								front/src/app/pipe/capacity.pipe.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								front/src/app/pipe/capacity.pipe.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| import { Pipe, PipeTransform } from '@angular/core'; | ||||
|  | ||||
| @Pipe({ | ||||
|   name: 'capacity', | ||||
|   standalone: true | ||||
| }) | ||||
| export class CapacityPipe implements PipeTransform { | ||||
|  | ||||
|   transform(value: number, ...args: unknown[]): string { | ||||
|     if (value === 0) { | ||||
|       return '0 Bytes'; | ||||
|     } | ||||
|  | ||||
|     const k = 1024; | ||||
|     const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; | ||||
|     const i = Math.floor(Math.log(value) / Math.log(k)); | ||||
|  | ||||
|     return parseFloat((value / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										214
									
								
								front/src/app/service/msg.service.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										214
									
								
								front/src/app/service/msg.service.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,214 @@ | ||||
| import { Injectable, Inject } from '@angular/core'; | ||||
| import { Component } from '@angular/core'; | ||||
| import { MAT_SNACK_BAR_DATA } from '@angular/material/snack-bar'; | ||||
| import { | ||||
|   MatSnackBar, | ||||
|   MatSnackBarHorizontalPosition, | ||||
|   MatSnackBarVerticalPosition, | ||||
| } from '@angular/material/snack-bar'; | ||||
| import {MatIconModule} from "@angular/material/icon"; | ||||
|  | ||||
| interface SnackMessage { | ||||
|   type: "success" | "error" | "warning" | "info" | ||||
|   duration: number | ||||
|   data: string | ||||
| } | ||||
|  | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
| }) | ||||
| export class MsgService { | ||||
|   horizontalPosition: MatSnackBarHorizontalPosition = 'center'; | ||||
|   verticalPosition: MatSnackBarVerticalPosition = 'top'; | ||||
|  | ||||
|   constructor( | ||||
|     private _snackBar: MatSnackBar | ||||
|   ) { } | ||||
|  | ||||
|  | ||||
|   success(data: string) { | ||||
|     this.open({ type: "success", duration: 1500, data: data }) | ||||
|   } | ||||
|  | ||||
|   info(data: string) { | ||||
|     this.open({ type: "info", duration: 2000, data: data }) | ||||
|   } | ||||
|  | ||||
|   warning(data: string) { | ||||
|     this.open({ type: "warning", duration: 3000, data: data }) | ||||
|   } | ||||
|  | ||||
|   error(data: string) { | ||||
|     this.open({ type: "error", duration: 3500, data: data }) | ||||
|   } | ||||
|  | ||||
|   open(msg: SnackMessage) { | ||||
|     switch (msg.type) { | ||||
|       case "success": | ||||
|         this._snackBar.openFromComponent(SnackMessageSuccess, { | ||||
|           data: msg.data, | ||||
|           duration: msg.duration, | ||||
|           horizontalPosition: this.horizontalPosition, | ||||
|           verticalPosition: this.verticalPosition, | ||||
|           panelClass: ['success-snackbar'], | ||||
|         }) | ||||
|         break; | ||||
|       case "info": | ||||
|         this._snackBar.openFromComponent(SnackMessageInfo, { | ||||
|           data: msg.data, | ||||
|           duration: msg.duration, | ||||
|           horizontalPosition: this.horizontalPosition, | ||||
|           verticalPosition: this.verticalPosition, | ||||
|           panelClass: ['info-snackbar'], | ||||
|         }) | ||||
|         break | ||||
|       case "warning": | ||||
|         this._snackBar.openFromComponent(SnackMessageWarning, { | ||||
|           data: msg.data, | ||||
|           duration: msg.duration, | ||||
|           horizontalPosition: this.horizontalPosition, | ||||
|           verticalPosition: this.verticalPosition, | ||||
|           panelClass: ['warning-snackbar'], | ||||
|         }) | ||||
|         break | ||||
|       case "error": | ||||
|         this._snackBar.openFromComponent(SnackMessageError, { | ||||
|           data: msg.data, | ||||
|           duration: msg.duration, | ||||
|           horizontalPosition: this.horizontalPosition, | ||||
|           verticalPosition: this.verticalPosition, | ||||
|           panelClass: ['error-snackbar'], | ||||
|         }) | ||||
|         break | ||||
|       default: | ||||
|         this._snackBar.openFromComponent(SnackMessageInfo, { | ||||
|           data: msg.data, | ||||
|           duration: msg.duration, | ||||
|           horizontalPosition: this.horizontalPosition, | ||||
|           verticalPosition: this.verticalPosition, | ||||
|           panelClass: ['info-snackbar'], | ||||
|         }) | ||||
|         break; | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
|  | ||||
| @Component({ | ||||
|   selector: 'snack-message-success', | ||||
|   template: ` | ||||
|       <div class="snack-message-success snack-message"> | ||||
|           <div> | ||||
|               <mat-icon>cancel</mat-icon> | ||||
|           </div> | ||||
|           <div class="snack-message-content"> | ||||
|               {{ data }} | ||||
|           </div> | ||||
|       </div> | ||||
|   `, | ||||
|   standalone: true, | ||||
|   imports: [ | ||||
|     MatIconModule | ||||
|   ], | ||||
|   styles: [` | ||||
|     .snack-message-success { | ||||
|     } | ||||
|   `] | ||||
| }) | ||||
| export class SnackMessageSuccess { | ||||
|   constructor( | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public data: string, | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public duration: number, | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public horizontalPosition: MatSnackBarHorizontalPosition, | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public verticalPosition: MatSnackBarVerticalPosition, | ||||
|   ) { } | ||||
| } | ||||
|  | ||||
|  | ||||
| @Component({ | ||||
|   selector: 'snack-message-info', | ||||
|   template: ` | ||||
|       <div class="snack-message-info snack-message"> | ||||
|           <div> | ||||
|               <mat-icon>cancel</mat-icon> | ||||
|           </div> | ||||
|           <div class="snack-message-content"> | ||||
|               {{ data }} | ||||
|           </div> | ||||
|       </div> | ||||
|   `, | ||||
|   standalone: true, | ||||
|   imports: [ | ||||
|     MatIconModule | ||||
|   ], | ||||
|   styles: [` | ||||
|     .snack-message-info { | ||||
|     } | ||||
|   `] | ||||
| }) | ||||
| export class SnackMessageInfo { | ||||
|   constructor( | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public data: string, | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public duration: number, | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public horizontalPosition: MatSnackBarHorizontalPosition, | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public verticalPosition: MatSnackBarVerticalPosition, | ||||
|   ) { } | ||||
| } | ||||
|  | ||||
| @Component({ | ||||
|   selector: 'snack-message-warning', | ||||
|   template: ` | ||||
|       <div class="snack-message-warning snack-message"> | ||||
|           <div> | ||||
|               <mat-icon>cancel</mat-icon> | ||||
|           </div> | ||||
|           <div class="snack-message-content"> | ||||
|               {{ data }} | ||||
|           </div> | ||||
|       </div> | ||||
|   `, | ||||
|   standalone: true, | ||||
|   imports: [ | ||||
|     MatIconModule | ||||
|   ], | ||||
|   styles: [` | ||||
|     .snack-message-warning { | ||||
|     } | ||||
|   `] | ||||
| }) | ||||
| export class SnackMessageWarning { | ||||
|   constructor( | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public data: string, | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public duration: number, | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public horizontalPosition: MatSnackBarHorizontalPosition, | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public verticalPosition: MatSnackBarVerticalPosition, | ||||
|   ) { } | ||||
| } | ||||
|  | ||||
| @Component({ | ||||
|   selector: 'snack-message-error', | ||||
|   template: ` | ||||
|       <div class="snack-message-error snack-message"> | ||||
|           <div> | ||||
|               <mat-icon>cancel</mat-icon> | ||||
|           </div> | ||||
|           <div class="snack-message-content"> | ||||
|               {{ data }} | ||||
|           </div> | ||||
|     </div> | ||||
|   `, | ||||
|   standalone: true, | ||||
|   imports: [ | ||||
|     MatIconModule | ||||
|   ], | ||||
|   styles: [` | ||||
|   `] | ||||
| }) | ||||
| export class SnackMessageError { | ||||
|   constructor( | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public data: string, | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public duration: number, | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public horizontalPosition: MatSnackBarHorizontalPosition, | ||||
|     @Inject(MAT_SNACK_BAR_DATA) public verticalPosition: MatSnackBarVerticalPosition, | ||||
|   ) { } | ||||
| } | ||||
							
								
								
									
										16
									
								
								front/src/app/service/repo.service.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								front/src/app/service/repo.service.spec.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| import { TestBed } from '@angular/core/testing'; | ||||
|  | ||||
| import { RepoService } from './repo.service'; | ||||
|  | ||||
| describe('RepoService', () => { | ||||
|   let service: RepoService; | ||||
|  | ||||
|   beforeEach(() => { | ||||
|     TestBed.configureTestingModule({}); | ||||
|     service = TestBed.inject(RepoService); | ||||
|   }); | ||||
|  | ||||
|   it('should be created', () => { | ||||
|     expect(service).toBeTruthy(); | ||||
|   }); | ||||
| }); | ||||
							
								
								
									
										101
									
								
								front/src/app/service/repo.service.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								front/src/app/service/repo.service.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,101 @@ | ||||
| import {Injectable, signal, WritableSignal} from '@angular/core'; | ||||
| import {Repo, Settings} from '../interface/repo' | ||||
| import {Response} from "../interface/response"; | ||||
| import {HttpClient} from "@angular/common/http"; | ||||
| import {MsgService} from "./msg.service"; | ||||
|  | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
| }) | ||||
| export class RepoService { | ||||
|  | ||||
|   readonly init_catalog = [ | ||||
|     {id: 1, created_at: 1713164091576, updated_at: 1713164091576, digest_id: 1, repo: "external/golang", tag: "latest"}, | ||||
|     {id: 2, created_at: 1713164091576, updated_at: 1713164091576, digest_id: 2, repo: "external/alpine", tag: "latest"}, | ||||
|     {id: 3, created_at: 1713164091576, updated_at: 1713164091576, digest_id: 3, repo: "external/nginx", tag: "latest"}, | ||||
|   ] as Repo[] | ||||
|  | ||||
|   readonly url_settings = '/api/repo/settings' | ||||
|   readonly url_catalog = '/api/repo/list' | ||||
|   readonly url_tag = '/api/repo/tag/list' | ||||
|  | ||||
|   settings = signal({} as Settings) | ||||
|  | ||||
|   catalog = signal({ | ||||
|     total: 0, | ||||
|     limit: 0, | ||||
|     last: 0, | ||||
|     keyword: '', | ||||
|     list: [] as Repo[], | ||||
|   }) | ||||
|  | ||||
|   constructor( | ||||
|     private http: HttpClient, | ||||
|     private msg_svc: MsgService, | ||||
|   ) { | ||||
|     this.GetSettings() | ||||
|     this.GetCatalog() | ||||
|   } | ||||
|  | ||||
|   GetSettings() { | ||||
|     this.http.get<Response<Settings>>(this.url_settings).subscribe(res => { | ||||
|       if (res.status === 200) { | ||||
|         this.settings.update(v => res.data) | ||||
|         return | ||||
|       } | ||||
|  | ||||
|       this.msg_svc.error(res.msg) | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   GetCatalog(limit: number = 20, last: number = 0, keyword: string = '') { | ||||
|     this.http.get<Response<{ total: number, list: Repo[] }>>(this.url_catalog, { | ||||
|       params: { | ||||
|         n: limit, | ||||
|         last: last, | ||||
|         keyword: keyword | ||||
|       } | ||||
|     }).subscribe(res => { | ||||
|       if (res.status === 200) { | ||||
|         this.catalog.update(v => { | ||||
|           return {...v, limit: limit, last: last, keyword: keyword, list: res.data.list, total: res.data.total} | ||||
|         }) | ||||
|  | ||||
|         return | ||||
|       } | ||||
|  | ||||
|       this.msg_svc.error(res.msg) | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   GetTags(repo: string, limit: number = 20, last: number = 0, keyword: string = '') { | ||||
|     console.log(`[D] GetTags: repo=${repo} limit=${limit} last=${last} keyword=${keyword}`) | ||||
|  | ||||
|     this.http.get<Response<{ total: number, list: Repo[] }>>(this.url_tag, { | ||||
|       params: { | ||||
|         repo: repo, | ||||
|         n: limit, | ||||
|         last: last, | ||||
|         keyword: keyword | ||||
|       } | ||||
|     }).subscribe(res => { | ||||
|       if (res.status === 200) { | ||||
|         this.catalog().list.forEach(v => { | ||||
|           if (v.repo === repo) { | ||||
|             v.Tags = { | ||||
|               list: res.data.list, | ||||
|               total: res.data.total, | ||||
|               limit: limit, | ||||
|               last: last, | ||||
|               keyword: keyword, | ||||
|             } | ||||
|           } | ||||
|         }) | ||||
|  | ||||
|         return | ||||
|       } | ||||
|  | ||||
|       this.msg_svc.error(res.msg) | ||||
|     }) | ||||
|   } | ||||
| } | ||||
							
								
								
									
										0
									
								
								front/src/assets/.gitkeep
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								front/src/assets/.gitkeep
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										
											BIN
										
									
								
								front/src/favicon.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								front/src/favicon.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 15 KiB | 
							
								
								
									
										15
									
								
								front/src/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								front/src/index.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| <!doctype html> | ||||
| <html lang="en"> | ||||
| <head> | ||||
|   <meta charset="utf-8"> | ||||
|   <title>Front</title> | ||||
|   <base href="/"> | ||||
|   <meta name="viewport" content="width=device-width, initial-scale=1"> | ||||
|   <link rel="icon" type="image/x-icon" href="favicon.ico"> | ||||
|   <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet"> | ||||
|   <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> | ||||
| </head> | ||||
| <body class="mat-typography"> | ||||
|   <app-root></app-root> | ||||
| </body> | ||||
| </html> | ||||
							
								
								
									
										6
									
								
								front/src/main.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								front/src/main.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| import { bootstrapApplication } from '@angular/platform-browser'; | ||||
| import { appConfig } from './app/app.config'; | ||||
| import { AppComponent } from './app/app.component'; | ||||
|  | ||||
| bootstrapApplication(AppComponent, appConfig) | ||||
|   .catch((err) => console.error(err)); | ||||
							
								
								
									
										6
									
								
								front/src/proxy.conf.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								front/src/proxy.conf.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| { | ||||
|   "/api": { | ||||
|     "target": "https://repo.me", | ||||
|     "secure": false | ||||
|   } | ||||
| } | ||||
							
								
								
									
										72
									
								
								front/src/styles.scss
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								front/src/styles.scss
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,72 @@ | ||||
| :root { | ||||
|   --primary-color: rgb(63, 81, 181); | ||||
|   --my-primary-color: rgb(67, 80, 175); | ||||
|   --my-success-text-color: rgb(94, 140, 117); | ||||
|   --my-success-backgroud-color: rgb(203, 228, 216); | ||||
|   --my-warning-text-color: rgb(132, 113, 56); | ||||
|   --my-warning-backgroud-color: rgb(254, 243, 200); | ||||
|   --my-error-text-color: rgb(136, 52, 61); | ||||
|   --my-error-backgroud-color: rgb(246, 209, 213); | ||||
|   --my-info-text-color: rgb(60, 64, 69); | ||||
|   --my-info-backgroud-color: rgb(222, 223, 225); | ||||
|  | ||||
|   font-size: 8px; | ||||
| } | ||||
|  | ||||
| html, body { | ||||
|   margin: 0; | ||||
|   padding: 0; | ||||
|   height: 100vh; | ||||
|   max-height: 100vh; | ||||
| } | ||||
|  | ||||
| html, body { | ||||
|   height: 100%; | ||||
| } | ||||
|  | ||||
| body { | ||||
|   margin: 0; | ||||
|   font-family: Roboto, "Helvetica Neue", sans-serif; | ||||
| } | ||||
|  | ||||
| .mat-mdc-snack-bar-container { | ||||
|  | ||||
|   &.info-snackbar { | ||||
|     --mdc-snackbar-container-color: var(--my-info-backgroud-color); | ||||
|     --mdc-snackbar-supporting-text-color: var(--my-info-text-color); | ||||
|   } | ||||
|  | ||||
|   &.success-snackbar { | ||||
|     --mdc-snackbar-container-color: var(--my-success-backgroud-color); | ||||
|     --mdc-snackbar-supporting-text-color: var(--my-success-text-color); | ||||
|   } | ||||
|  | ||||
|   &.warning-snackbar { | ||||
|     --mdc-snackbar-container-color: var(--my-warning-backgroud-color); | ||||
|     --mdc-snackbar-supporting-text-color: var(--my-warning-text-color); | ||||
|   } | ||||
|  | ||||
|   &.error-snackbar { | ||||
|     --mdc-snackbar-container-color: var(--my-error-backgroud-color); | ||||
|     --mdc-snackbar-supporting-text-color: var(--my-error-text-color); | ||||
|   } | ||||
| } | ||||
|  | ||||
| .snack-message { | ||||
|   display: flex; | ||||
|   align-items: center; | ||||
|   height: 100%; | ||||
|  | ||||
|   div { | ||||
|     height: 100%; | ||||
|     display: flex; | ||||
|     align-items: center; | ||||
|  | ||||
|     &.snack-message-content { | ||||
|       margin-left: 1rem; | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| html, body { height: 100%; } | ||||
| body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } | ||||
							
								
								
									
										14
									
								
								front/tsconfig.app.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								front/tsconfig.app.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| /* To learn more about this file see: https://angular.io/config/tsconfig. */ | ||||
| { | ||||
|   "extends": "./tsconfig.json", | ||||
|   "compilerOptions": { | ||||
|     "outDir": "./out-tsc/app", | ||||
|     "types": [] | ||||
|   }, | ||||
|   "files": [ | ||||
|     "src/main.ts" | ||||
|   ], | ||||
|   "include": [ | ||||
|     "src/**/*.d.ts" | ||||
|   ] | ||||
| } | ||||
							
								
								
									
										32
									
								
								front/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								front/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | ||||
| /* To learn more about this file see: https://angular.io/config/tsconfig. */ | ||||
| { | ||||
|   "compileOnSave": false, | ||||
|   "compilerOptions": { | ||||
|     "outDir": "./dist/out-tsc", | ||||
|     "strict": true, | ||||
|     "noImplicitOverride": true, | ||||
|     "noPropertyAccessFromIndexSignature": true, | ||||
|     "noImplicitReturns": true, | ||||
|     "noFallthroughCasesInSwitch": true, | ||||
|     "skipLibCheck": true, | ||||
|     "esModuleInterop": true, | ||||
|     "sourceMap": true, | ||||
|     "declaration": false, | ||||
|     "experimentalDecorators": true, | ||||
|     "moduleResolution": "node", | ||||
|     "importHelpers": true, | ||||
|     "target": "ES2022", | ||||
|     "module": "ES2022", | ||||
|     "useDefineForClassFields": false, | ||||
|     "lib": [ | ||||
|       "ES2022", | ||||
|       "dom" | ||||
|     ] | ||||
|   }, | ||||
|   "angularCompilerOptions": { | ||||
|     "enableI18nLegacyMessageIdFormat": false, | ||||
|     "strictInjectionParameters": true, | ||||
|     "strictInputAccessModifiers": true, | ||||
|     "strictTemplates": true | ||||
|   } | ||||
| } | ||||
							
								
								
									
										14
									
								
								front/tsconfig.spec.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								front/tsconfig.spec.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| /* To learn more about this file see: https://angular.io/config/tsconfig. */ | ||||
| { | ||||
|   "extends": "./tsconfig.json", | ||||
|   "compilerOptions": { | ||||
|     "outDir": "./out-tsc/spec", | ||||
|     "types": [ | ||||
|       "jasmine" | ||||
|     ] | ||||
|   }, | ||||
|   "include": [ | ||||
|     "src/**/*.spec.ts", | ||||
|     "src/**/*.d.ts" | ||||
|   ] | ||||
| } | ||||
							
								
								
									
										81
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										81
									
								
								go.mod
									
									
									
									
									
								
							| @@ -1,26 +1,95 @@ | ||||
| module nf-repo | ||||
|  | ||||
| go 1.20 | ||||
| go 1.22 | ||||
|  | ||||
| require ( | ||||
| 	github.com/containers/image/v5 v5.30.0 | ||||
| 	github.com/glebarez/sqlite v1.11.0 | ||||
| 	github.com/google/go-containerregistry v0.19.1 | ||||
| 	github.com/loveuer/nf v0.1.6 | ||||
| 	github.com/google/go-containerregistry v0.19.0 | ||||
| 	github.com/loveuer/nf v0.1.7 | ||||
| 	github.com/opencontainers/go-digest v1.0.0 | ||||
| 	github.com/samber/lo v1.39.0 | ||||
| 	github.com/sirupsen/logrus v1.9.3 | ||||
| 	gorm.io/gorm v1.25.9 | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| 	dario.cat/mergo v1.0.0 // indirect | ||||
| 	github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect | ||||
| 	github.com/BurntSushi/toml v1.3.2 // indirect | ||||
| 	github.com/Microsoft/go-winio v0.6.1 // indirect | ||||
| 	github.com/Microsoft/hcsshim v0.12.0-rc.3 // indirect | ||||
| 	github.com/containerd/cgroups/v3 v3.0.2 // indirect | ||||
| 	github.com/containerd/errdefs v0.1.0 // indirect | ||||
| 	github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect | ||||
| 	github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect | ||||
| 	github.com/containers/ocicrypt v1.1.9 // indirect | ||||
| 	github.com/containers/storage v1.53.0 // indirect | ||||
| 	github.com/cyphar/filepath-securejoin v0.2.4 // indirect | ||||
| 	github.com/distribution/reference v0.5.0 // indirect | ||||
| 	github.com/docker/cli v25.0.3+incompatible // indirect | ||||
| 	github.com/docker/distribution v2.8.3+incompatible // indirect | ||||
| 	github.com/docker/docker v25.0.3+incompatible // indirect | ||||
| 	github.com/docker/docker-credential-helpers v0.8.1 // indirect | ||||
| 	github.com/docker/go-connections v0.5.0 // indirect | ||||
| 	github.com/docker/go-units v0.5.0 // indirect | ||||
| 	github.com/dustin/go-humanize v1.0.1 // indirect | ||||
| 	github.com/felixge/httpsnoop v1.0.4 // indirect | ||||
| 	github.com/glebarez/go-sqlite v1.21.2 // indirect | ||||
| 	github.com/google/uuid v1.3.0 // indirect | ||||
| 	github.com/go-logr/logr v1.4.1 // indirect | ||||
| 	github.com/go-logr/stdr v1.2.2 // indirect | ||||
| 	github.com/gogo/protobuf v1.3.2 // indirect | ||||
| 	github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | ||||
| 	github.com/google/go-intervals v0.0.2 // indirect | ||||
| 	github.com/google/uuid v1.6.0 // indirect | ||||
| 	github.com/gorilla/mux v1.8.1 // indirect | ||||
| 	github.com/hashicorp/errwrap v1.1.0 // indirect | ||||
| 	github.com/hashicorp/go-multierror v1.1.1 // indirect | ||||
| 	github.com/jinzhu/inflection v1.0.0 // indirect | ||||
| 	github.com/jinzhu/now v1.1.5 // indirect | ||||
| 	github.com/json-iterator/go v1.1.12 // indirect | ||||
| 	github.com/klauspost/compress v1.17.7 // indirect | ||||
| 	github.com/klauspost/pgzip v1.2.6 // indirect | ||||
| 	github.com/kr/pretty v0.3.1 // indirect | ||||
| 	github.com/mattn/go-isatty v0.0.17 // indirect | ||||
| 	github.com/mattn/go-shellwords v1.0.12 // indirect | ||||
| 	github.com/mattn/go-sqlite3 v1.14.22 // indirect | ||||
| 	github.com/mistifyio/go-zfs/v3 v3.0.1 // indirect | ||||
| 	github.com/mitchellh/go-homedir v1.1.0 // indirect | ||||
| 	github.com/moby/sys/mountinfo v0.7.1 // indirect | ||||
| 	github.com/moby/sys/user v0.1.0 // indirect | ||||
| 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||||
| 	github.com/modern-go/reflect2 v1.0.2 // indirect | ||||
| 	github.com/opencontainers/image-spec v1.1.0 // indirect | ||||
| 	github.com/opencontainers/runtime-spec v1.2.0 // indirect | ||||
| 	github.com/opencontainers/selinux v1.11.0 // indirect | ||||
| 	github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f // indirect | ||||
| 	github.com/pkg/errors v0.9.1 // indirect | ||||
| 	github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect | ||||
| 	golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect | ||||
| 	golang.org/x/sys v0.15.0 // indirect | ||||
| 	github.com/rogpeppe/go-internal v1.12.0 // indirect | ||||
| 	github.com/sylabs/sif/v2 v2.15.1 // indirect | ||||
| 	github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect | ||||
| 	github.com/tchap/go-patricia/v2 v2.3.1 // indirect | ||||
| 	github.com/ulikunitz/xz v0.5.11 // indirect | ||||
| 	github.com/vbatts/tar-split v0.11.5 // indirect | ||||
| 	go.opencensus.io v0.24.0 // indirect | ||||
| 	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect | ||||
| 	go.opentelemetry.io/otel v1.25.0 // indirect | ||||
| 	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0 // indirect | ||||
| 	go.opentelemetry.io/otel/metric v1.25.0 // indirect | ||||
| 	go.opentelemetry.io/otel/sdk v1.25.0 // indirect | ||||
| 	go.opentelemetry.io/otel/trace v1.25.0 // indirect | ||||
| 	go.opentelemetry.io/proto/otlp v1.2.0 // indirect | ||||
| 	golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect | ||||
| 	golang.org/x/mod v0.15.0 // indirect | ||||
| 	golang.org/x/sync v0.6.0 // indirect | ||||
| 	golang.org/x/sys v0.18.0 // indirect | ||||
| 	golang.org/x/time v0.3.0 // indirect | ||||
| 	golang.org/x/tools v0.18.0 // indirect | ||||
| 	google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect | ||||
| 	google.golang.org/grpc v1.63.0 // indirect | ||||
| 	google.golang.org/protobuf v1.33.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| 	modernc.org/libc v1.22.5 // indirect | ||||
| 	modernc.org/mathutil v1.5.0 // indirect | ||||
| 	modernc.org/memory v1.5.0 // indirect | ||||
|   | ||||
							
								
								
									
										329
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										329
									
								
								go.sum
									
									
									
									
									
								
							| @@ -1,49 +1,354 @@ | ||||
| cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= | ||||
| dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= | ||||
| dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= | ||||
| github.com/14rcole/gopopulate v0.0.0-20180821133914-b175b219e774 h1:SCbEWT58NSt7d2mcFdvxC9uyrdcTfvBbPLThhkDmXzg= | ||||
| github.com/14rcole/gopopulate v0.0.0-20180821133914-b175b219e774/go.mod h1:6/0dYRLLXyJjbkIPeeGyoJ/eKOSI0eU6eTlCBYibgd0= | ||||
| github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= | ||||
| github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= | ||||
| github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= | ||||
| github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= | ||||
| github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= | ||||
| github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= | ||||
| github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= | ||||
| github.com/Microsoft/hcsshim v0.12.0-rc.3 h1:5GNGrobGs/sN/0nFO21W9k4lFn+iXXZAE8fCZbmdRak= | ||||
| github.com/Microsoft/hcsshim v0.12.0-rc.3/go.mod h1:WuNfcaYNaw+KpCEsZCIM6HCEmu0c5HfXpi+dDSmveP0= | ||||
| github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= | ||||
| github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= | ||||
| github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= | ||||
| github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= | ||||
| github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= | ||||
| github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= | ||||
| github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= | ||||
| github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= | ||||
| github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= | ||||
| github.com/containerd/cgroups/v3 v3.0.2 h1:f5WFqIVSgo5IZmtTT3qVBo6TzI1ON6sycSBKkymb9L0= | ||||
| github.com/containerd/cgroups/v3 v3.0.2/go.mod h1:JUgITrzdFqp42uI2ryGA+ge0ap/nxzYgkGmIcetmErE= | ||||
| github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM= | ||||
| github.com/containerd/errdefs v0.1.0/go.mod h1:YgWiiHtLmSeBrvpw+UfPijzbLaB77mEG1WwJTDETIV0= | ||||
| github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= | ||||
| github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= | ||||
| github.com/containerd/stargz-snapshotter/estargz v0.15.1 h1:eXJjw9RbkLFgioVaTG+G/ZW/0kEe2oEKCdS/ZxIyoCU= | ||||
| github.com/containerd/stargz-snapshotter/estargz v0.15.1/go.mod h1:gr2RNwukQ/S9Nv33Lt6UC7xEx58C+LHRdoqbEKjz1Kk= | ||||
| github.com/containers/image/v5 v5.30.0 h1:CmHeSwI6W2kTRWnUsxATDFY5TEX4b58gPkaQcEyrLIA= | ||||
| github.com/containers/image/v5 v5.30.0/go.mod h1:gSD8MVOyqBspc0ynLsuiMR9qmt8UQ4jpVImjmK0uXfk= | ||||
| github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 h1:Qzk5C6cYglewc+UyGf6lc8Mj2UaPTHy/iF2De0/77CA= | ||||
| github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY= | ||||
| github.com/containers/ocicrypt v1.1.9 h1:2Csfba4jse85Raxk5HIyEk8OwZNjRvfkhEGijOjIdEM= | ||||
| github.com/containers/ocicrypt v1.1.9/go.mod h1:dTKx1918d8TDkxXvarscpNVY+lyPakPNFN4jwA9GBys= | ||||
| github.com/containers/storage v1.53.0 h1:VSES3C/u1pxjTJIXvLrSmyP7OBtDky04oGu07UvdTEA= | ||||
| github.com/containers/storage v1.53.0/go.mod h1:pujcoOSc+upx15Jirdkebhtd8uJiLwbSd/mYT6zDJK8= | ||||
| github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= | ||||
| github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= | ||||
| github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= | ||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= | ||||
| github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= | ||||
| github.com/docker/cli v25.0.3+incompatible h1:KLeNs7zws74oFuVhgZQ5ONGZiXUUdgsdy6/EsX/6284= | ||||
| github.com/docker/cli v25.0.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= | ||||
| github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= | ||||
| github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= | ||||
| github.com/docker/docker v25.0.3+incompatible h1:D5fy/lYmY7bvZa0XTZ5/UJPljor41F+vdyJG5luQLfQ= | ||||
| github.com/docker/docker v25.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= | ||||
| github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo= | ||||
| github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= | ||||
| github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= | ||||
| github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= | ||||
| github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQV8= | ||||
| github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHzueweSI3Vw= | ||||
| github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= | ||||
| github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= | ||||
| github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= | ||||
| github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= | ||||
| github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= | ||||
| github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= | ||||
| github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= | ||||
| github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= | ||||
| github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= | ||||
| github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= | ||||
| github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo= | ||||
| github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k= | ||||
| github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw= | ||||
| github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ= | ||||
| github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= | ||||
| github.com/google/go-containerregistry v0.19.1 h1:yMQ62Al6/V0Z7CqIrrS1iYoA5/oQCm88DeNujc7C1KY= | ||||
| github.com/google/go-containerregistry v0.19.1/go.mod h1:YCMFNQeeXeLF+dnhhWkqDItx/JSkH01j1Kis4PsjzFI= | ||||
| github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= | ||||
| github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= | ||||
| github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= | ||||
| github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= | ||||
| github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= | ||||
| github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= | ||||
| github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= | ||||
| github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= | ||||
| github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= | ||||
| github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= | ||||
| github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= | ||||
| github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= | ||||
| github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= | ||||
| github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= | ||||
| github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= | ||||
| github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= | ||||
| github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= | ||||
| github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= | ||||
| github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= | ||||
| github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= | ||||
| github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= | ||||
| github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= | ||||
| github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= | ||||
| github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= | ||||
| github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= | ||||
| github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= | ||||
| github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||||
| github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||||
| github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||||
| github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||||
| github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | ||||
| github.com/google/go-containerregistry v0.19.0 h1:uIsMRBV7m/HDkDxE/nXMnv1q+lOOSPlQ/ywc5JbB8Ic= | ||||
| github.com/google/go-containerregistry v0.19.0/go.mod h1:u0qB2l7mvtWVR5kNcbFIhFY1hLbf8eeGapA+vbFDCtQ= | ||||
| github.com/google/go-intervals v0.0.2 h1:FGrVEiUnTRKR8yE04qzXYaJMtnIYqobR5QbblK3ixcM= | ||||
| github.com/google/go-intervals v0.0.2/go.mod h1:MkaR3LNRfeKLPmqgJYs4E66z5InYjmCjbbr4TQlcT6Y= | ||||
| github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= | ||||
| github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ= | ||||
| github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= | ||||
| github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= | ||||
| github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= | ||||
| github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= | ||||
| github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= | ||||
| github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= | ||||
| github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= | ||||
| github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= | ||||
| github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= | ||||
| github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= | ||||
| github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= | ||||
| github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= | ||||
| github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= | ||||
| github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= | ||||
| github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= | ||||
| github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= | ||||
| github.com/loveuer/nf v0.1.6 h1:YIhrQm1iIMkTqP6EOdQ7OsNoFXCD0/i7oi3yjaMtpCU= | ||||
| github.com/loveuer/nf v0.1.6/go.mod h1:uKsKYym27ravyTXSBSnxU86V7osxx9cM6DJ+dVBfJ1Q= | ||||
| github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= | ||||
| github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= | ||||
| github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= | ||||
| github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | ||||
| github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= | ||||
| github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= | ||||
| github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU= | ||||
| github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= | ||||
| github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= | ||||
| github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= | ||||
| github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= | ||||
| github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= | ||||
| github.com/loveuer/nf v0.1.7 h1:4e2TeumY0RPmXHtTGlNzvwFgbXAgjq39IZ/KBK9Q0K4= | ||||
| github.com/loveuer/nf v0.1.7/go.mod h1:uKsKYym27ravyTXSBSnxU86V7osxx9cM6DJ+dVBfJ1Q= | ||||
| github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= | ||||
| github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= | ||||
| github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk= | ||||
| github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y= | ||||
| github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= | ||||
| github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= | ||||
| github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= | ||||
| github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= | ||||
| github.com/mistifyio/go-zfs/v3 v3.0.1 h1:YaoXgBePoMA12+S1u/ddkv+QqxcfiZK4prI6HPnkFiU= | ||||
| github.com/mistifyio/go-zfs/v3 v3.0.1/go.mod h1:CzVgeB0RvF2EGzQnytKVvVSDwmKJXxkOTUGbNrTja/k= | ||||
| github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= | ||||
| github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= | ||||
| github.com/moby/sys/mountinfo v0.7.1 h1:/tTvQaSJRr2FshkhXiIpux6fQ2Zvc4j7tAhMTStAG2g= | ||||
| github.com/moby/sys/mountinfo v0.7.1/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= | ||||
| github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg= | ||||
| github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU= | ||||
| github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= | ||||
| github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= | ||||
| github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= | ||||
| github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= | ||||
| github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= | ||||
| github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= | ||||
| github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= | ||||
| github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= | ||||
| github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= | ||||
| github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= | ||||
| github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= | ||||
| github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= | ||||
| github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= | ||||
| github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= | ||||
| github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= | ||||
| github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaLpt7tQ7oU= | ||||
| github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec= | ||||
| github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f h1:/UDgs8FGMqwnHagNDPGOlts35QkhAZ8by3DR7nMih7M= | ||||
| github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f/go.mod h1:J6OG6YJVEWopen4avK3VNQSnALmmjvniMmni/YFYAwc= | ||||
| github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= | ||||
| github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= | ||||
| github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= | ||||
| github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | ||||
| github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= | ||||
| github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= | ||||
| github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= | ||||
| github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= | ||||
| github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= | ||||
| github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= | ||||
| github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= | ||||
| github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= | ||||
| github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= | ||||
| github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= | ||||
| github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= | ||||
| github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= | ||||
| github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= | ||||
| github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= | ||||
| github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= | ||||
| github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA= | ||||
| github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= | ||||
| github.com/sebdah/goldie/v2 v2.5.3 h1:9ES/mNN+HNUbNWpVAlrzuZ7jE+Nrczbj8uFRjM7624Y= | ||||
| github.com/sebdah/goldie/v2 v2.5.3/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI= | ||||
| github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= | ||||
| github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= | ||||
| github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= | ||||
| github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= | ||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||||
| github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= | ||||
| github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= | ||||
| github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= | ||||
| github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM= | ||||
| golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= | ||||
| github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= | ||||
| github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= | ||||
| github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= | ||||
| github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | ||||
| github.com/sylabs/sif/v2 v2.15.1 h1:75BcunPOY11fVhe02/WHuNLTfDd3OHH0ex0MuuNMYX0= | ||||
| github.com/sylabs/sif/v2 v2.15.1/go.mod h1:YiwCUdZOhiohnPbyxuxvCZa+03HwAaiC+vfAKZPR8nQ= | ||||
| github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI= | ||||
| github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= | ||||
| github.com/tchap/go-patricia/v2 v2.3.1 h1:6rQp39lgIYZ+MHmdEq4xzuk1t7OdC35z/xm0BGhTkes= | ||||
| github.com/tchap/go-patricia/v2 v2.3.1/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k= | ||||
| github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= | ||||
| github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= | ||||
| github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts= | ||||
| github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk= | ||||
| github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | ||||
| github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | ||||
| go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= | ||||
| go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= | ||||
| go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 h1:x8Z78aZx8cOF0+Kkazoc7lwUNMGy0LrzEMxTm4BbTxg= | ||||
| go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0/go.mod h1:62CPTSry9QZtOaSsE3tOzhx6LzDhHnXJ6xHeMNNiM6Q= | ||||
| go.opentelemetry.io/otel v1.25.0 h1:gldB5FfhRl7OJQbUHt/8s0a7cE8fbsPAtdpRaApKy4k= | ||||
| go.opentelemetry.io/otel v1.25.0/go.mod h1:Wa2ds5NOXEMkCmUou1WA7ZBfLTHWIsp034OVD7AO+Vg= | ||||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0 h1:dT33yIHtmsqpixFsSQPwNeY5drM9wTcoL8h0FWF4oGM= | ||||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0/go.mod h1:h95q0LBGh7hlAC08X2DhSeyIG02YQ0UyioTCVAqRPmc= | ||||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg= | ||||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU= | ||||
| go.opentelemetry.io/otel/metric v1.25.0 h1:LUKbS7ArpFL/I2jJHdJcqMGxkRdxpPHE0VU/D4NuEwA= | ||||
| go.opentelemetry.io/otel/metric v1.25.0/go.mod h1:rkDLUSd2lC5lq2dFNrX9LGAbINP5B7WBkC78RXCpH5s= | ||||
| go.opentelemetry.io/otel/sdk v1.25.0 h1:PDryEJPC8YJZQSyLY5eqLeafHtG+X7FWnf3aXMtxbqo= | ||||
| go.opentelemetry.io/otel/sdk v1.25.0/go.mod h1:oFgzCM2zdsxKzz6zwpTZYLLQsFwc+K0daArPdIhuxkw= | ||||
| go.opentelemetry.io/otel/trace v1.25.0 h1:tqukZGLwQYRIFtSQM2u2+yfMVTgGVeqRLPUYx1Dq6RM= | ||||
| go.opentelemetry.io/otel/trace v1.25.0/go.mod h1:hCCs70XM/ljO+BeQkyFnbK28SBIJ/Emuha+ccrCRT7I= | ||||
| go.opentelemetry.io/proto/otlp v1.2.0 h1:pVeZGk7nXDC9O2hncA6nHldxEjm6LByfA2aN8IOkz94= | ||||
| go.opentelemetry.io/proto/otlp v1.2.0/go.mod h1:gGpR8txAl5M03pDhMC79G6SdqNV26naRm/KDsgaHD8A= | ||||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||||
| golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||||
| golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | ||||
| golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= | ||||
| golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= | ||||
| golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= | ||||
| golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= | ||||
| golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= | ||||
| golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= | ||||
| golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | ||||
| golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | ||||
| golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= | ||||
| golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= | ||||
| golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | ||||
| golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | ||||
| golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | ||||
| golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||||
| golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||||
| golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||||
| golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||||
| golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | ||||
| golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | ||||
| golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= | ||||
| golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= | ||||
| golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | ||||
| golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= | ||||
| golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | ||||
| golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
| golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
| golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= | ||||
| golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||||
| golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= | ||||
| golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||||
| golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||
| golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||||
| golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= | ||||
| golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= | ||||
| golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= | ||||
| golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
| golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
| golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= | ||||
| golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= | ||||
| golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= | ||||
| golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
| golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= | ||||
| golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= | ||||
| golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= | ||||
| golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= | ||||
| golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= | ||||
| google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= | ||||
| google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= | ||||
| google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= | ||||
| google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= | ||||
| google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= | ||||
| google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0= | ||||
| google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8= | ||||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= | ||||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= | ||||
| google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= | ||||
| google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= | ||||
| google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= | ||||
| google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= | ||||
| google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= | ||||
| google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= | ||||
| google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= | ||||
| google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= | ||||
| google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= | ||||
| google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= | ||||
| google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= | ||||
| google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= | ||||
| google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= | ||||
| google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= | ||||
| google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= | ||||
| google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= | ||||
| google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= | ||||
| google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= | ||||
| gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= | ||||
| gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
| gorm.io/gorm v1.25.9 h1:wct0gxZIELDk8+ZqF/MVnHLkA1rvYlBWUMv2EdsK1g8= | ||||
| gorm.io/gorm v1.25.9/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= | ||||
| gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= | ||||
| gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= | ||||
| gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= | ||||
| gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= | ||||
| honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= | ||||
| honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= | ||||
| modernc.org/libc v1.22.5 h1:91BNch/e5B0uPbJFgqbxXuOnxBQjlS//icfQEGmvyjE= | ||||
| modernc.org/libc v1.22.5/go.mod h1:jj+Z7dTNX8fBScMVNRAYZ/jF91K8fdT2hYMThc3YjBY= | ||||
| modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ= | ||||
|   | ||||
| @@ -21,5 +21,13 @@ func NewApi( | ||||
| 		api.Any("/*path", handler.Root(bh, uh, mh)) | ||||
| 	} | ||||
|  | ||||
| 	{ | ||||
| 		api := app.Group("/api/repo") | ||||
| 		api.Get("/settings", handler.RepoSettings) | ||||
| 		api.Get("/list", handler.RepoList(mh)) | ||||
| 		api.Get("/tag/list", handler.TagList(mh)) | ||||
| 		api.Post("/proxy", handler.ProxyDownloadImage(mh, bh)) | ||||
| 	} | ||||
|  | ||||
| 	return app | ||||
| } | ||||
|   | ||||
| @@ -29,7 +29,7 @@ func handleCatalog(ctx *nf.Ctx, m interfaces.ManifestHandler) error { | ||||
| 		list *model.Catalog | ||||
| 	) | ||||
|  | ||||
| 	if list, re = m.Catelog(ctx.Request.Context(), n, 0); re != nil { | ||||
| 	if list, re = m.Catalog(ctx.Request.Context(), n, 0, ""); re != nil { | ||||
| 		return rerr.Error(ctx, re) | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -86,13 +86,24 @@ func handleManifest(ctx *nf.Ctx, m interfaces.ManifestHandler) error { | ||||
| 		return ctx.SendStatus(http.StatusOK) | ||||
|  | ||||
| 	case http.MethodPut: | ||||
| 		b := &bytes.Buffer{} | ||||
| 		io.Copy(b, ctx.Request.Body) | ||||
| 		h, _, _ := model.SHA256(bytes.NewReader(b.Bytes())) | ||||
| 		digest := h.String() | ||||
| 		var ( | ||||
| 			err  error | ||||
| 			buf  = &bytes.Buffer{} | ||||
| 			hash model.Hash | ||||
| 		) | ||||
|  | ||||
| 		mf := model.Manifest{ | ||||
| 			Blob:        b.Bytes(), | ||||
| 		if _, err = io.Copy(buf, ctx.Request.Body); err != nil { | ||||
| 			return rerr.Error(ctx, rerr.ErrInternal(err)) | ||||
| 		} | ||||
|  | ||||
| 		if hash, _, err = model.SHA256(bytes.NewReader(buf.Bytes())); err != nil { | ||||
| 			return rerr.Error(ctx, rerr.ErrInternal(err)) | ||||
| 		} | ||||
|  | ||||
| 		digest := hash.String() | ||||
|  | ||||
| 		mf := model.RepoSimpleManifest{ | ||||
| 			Blob:        buf.Bytes(), | ||||
| 			ContentType: ctx.Get("Content-Type"), | ||||
| 		} | ||||
|  | ||||
| @@ -104,7 +115,7 @@ func handleManifest(ctx *nf.Ctx, m interfaces.ManifestHandler) error { | ||||
| 			WithField("target", target). | ||||
| 			WithField("digest", digest). | ||||
| 			WithField("content-type", ctx.Get("Content-Type")). | ||||
| 			WithField("content", b.String()). | ||||
| 			WithField("content", buf.String()). | ||||
| 			Debug() | ||||
|  | ||||
| 		if err := m.Put(ctx.Request.Context(), repo, target, digest, &mf); err != nil { | ||||
|   | ||||
							
								
								
									
										307
									
								
								internal/handler/repo.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										307
									
								
								internal/handler/repo.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,307 @@ | ||||
| package handler | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"github.com/google/go-containerregistry/pkg/name" | ||||
| 	"github.com/google/go-containerregistry/pkg/v1" | ||||
| 	"github.com/google/go-containerregistry/pkg/v1/remote" | ||||
| 	"github.com/loveuer/nf" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"io" | ||||
| 	"net/http" | ||||
| 	"net/url" | ||||
| 	"nf-repo/internal/interfaces" | ||||
| 	"nf-repo/internal/model" | ||||
| 	"nf-repo/internal/opt" | ||||
| 	"nf-repo/internal/util/r" | ||||
| 	"nf-repo/internal/util/rerr" | ||||
| 	"strings" | ||||
| ) | ||||
|  | ||||
| func RepoSettings(c *nf.Ctx) error { | ||||
| 	return r.Resp200(c, nf.Map{ | ||||
| 		"base_address": opt.BaseAddress, | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| func RepoList(mh interfaces.ManifestHandler) nf.HandlerFunc { | ||||
| 	return func(c *nf.Ctx) error { | ||||
| 		type Req struct { | ||||
| 			Keyword string `json:"keyword" query:"keyword"` | ||||
| 			N       int    `json:"n" query:"n"` | ||||
| 			Last    int    `json:"last" query:"last"` | ||||
| 		} | ||||
|  | ||||
| 		var ( | ||||
| 			err     error | ||||
| 			re      *rerr.RepositoryError | ||||
| 			req     = new(Req) | ||||
| 			catalog *model.Catalog | ||||
| 		) | ||||
|  | ||||
| 		if err = c.QueryParser(req); err != nil { | ||||
| 			return r.Resp400(c, err.Error()) | ||||
| 		} | ||||
|  | ||||
| 		if req.N == 0 { | ||||
| 			req.N = 20 | ||||
| 		} | ||||
|  | ||||
| 		if req.N > 1000 { | ||||
| 			return r.Resp400(c, "limit invalid: too big") | ||||
| 		} | ||||
|  | ||||
| 		if catalog, re = mh.Catalog(c.Request.Context(), req.N, req.Last, req.Keyword); re != nil { | ||||
| 			return r.Resp(c, uint32(re.Status), "", re.Code, re.Message) | ||||
| 		} | ||||
|  | ||||
| 		return r.Resp200(c, nf.Map{"list": catalog.Repos, "total": 0}) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TagList(mh interfaces.ManifestHandler) nf.HandlerFunc { | ||||
| 	return func(c *nf.Ctx) error { | ||||
| 		type Req struct { | ||||
| 			Repo    string `json:"repo" query:"repo"` | ||||
| 			Keyword string `json:"keyword" query:"keyword"` | ||||
| 			N       int    `json:"n" query:"n"` | ||||
| 			Last    int    `json:"last" query:"last"` | ||||
| 		} | ||||
|  | ||||
| 		var ( | ||||
| 			err error | ||||
| 			req = new(Req) | ||||
| 			tag *model.Tag | ||||
| 			re  *rerr.RepositoryError | ||||
| 		) | ||||
|  | ||||
| 		if err = c.QueryParser(req); err != nil { | ||||
| 			return r.Resp400(c, err.Error()) | ||||
| 		} | ||||
|  | ||||
| 		if req.Repo == "" { | ||||
| 			return r.Resp400(c, "repo invalid") | ||||
| 		} | ||||
|  | ||||
| 		if req.N <= 0 { | ||||
| 			req.N = 20 | ||||
| 		} | ||||
|  | ||||
| 		if req.N > 1000 { | ||||
| 			return r.Resp400(c, "limit invalid: too big") | ||||
| 		} | ||||
|  | ||||
| 		if tag, re = mh.Tags(c.Request.Context(), req.Repo, req.N, req.Last, req.Keyword); re != nil { | ||||
| 			return r.Resp(c, uint32(re.Status), "", re.Code, re.Message) | ||||
| 		} | ||||
|  | ||||
| 		return r.Resp200(c, nf.Map{"list": tag.RepoTags, "total": tag.Tags}) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func ProxyDownloadImage(mh interfaces.ManifestHandler, bh interfaces.BlobHandler) nf.HandlerFunc { | ||||
| 	return func(c *nf.Ctx) error { | ||||
| 		type Req struct { | ||||
| 			Source string `json:"source"` | ||||
| 			Target string `json:"target"` | ||||
| 			Proxy  string `json:"proxy"` | ||||
| 		} | ||||
|  | ||||
| 		type Msg struct { | ||||
| 			Target string `json:"target"` | ||||
| 			Action string `json:"action"` | ||||
| 			Msg    string `json:"msg"` | ||||
| 			Data   any    `json:"data"` | ||||
| 		} | ||||
|  | ||||
| 		var ( | ||||
| 			err       error | ||||
| 			req       = new(Req) | ||||
| 			puller    *remote.Puller | ||||
| 			tn        name.Tag | ||||
| 			des       *remote.Descriptor | ||||
| 			transport = &http.Transport{} | ||||
| 			img       v1.Image | ||||
| 			manifest  *v1.Manifest | ||||
| 			bs        []byte | ||||
| 			mhash     model.Hash | ||||
| 			//progressCh = make(chan v1.Update, 16) | ||||
| 		) | ||||
|  | ||||
| 		if err = c.BodyParser(req); err != nil { | ||||
| 			return r.Resp400(c, err.Error()) | ||||
| 		} | ||||
|  | ||||
| 		if req.Target == "" { | ||||
| 			return r.Resp400(c, "target invalid") | ||||
| 		} | ||||
|  | ||||
| 		repoTags := strings.Split(req.Target, ":") | ||||
| 		if len(repoTags) != 2 { | ||||
| 			return r.Resp400(c, "target invalid: should only contain one ':'") | ||||
| 		} | ||||
|  | ||||
| 		repo, tag := repoTags[0], repoTags[1] | ||||
| 		repo = strings.TrimPrefix(repo, opt.BaseAddress) | ||||
| 		repo = strings.Trim(repo, "/") | ||||
|  | ||||
| 		if req.Source == "" { | ||||
| 			return r.Resp400(c, "source invalid") | ||||
| 		} | ||||
|  | ||||
| 		imageName := fmt.Sprintf("%s/%s:%s", opt.BaseAddress, repo, tag) | ||||
| 		_ = imageName | ||||
|  | ||||
| 		logrus. | ||||
| 			WithField("path", "handler.ProxyDownloadImage"). | ||||
| 			WithField("req", *req). | ||||
| 			WithField("repo", repo). | ||||
| 			Debug() | ||||
|  | ||||
| 		if req.Proxy != "" { | ||||
| 			var pu *url.URL | ||||
| 			if pu, err = url.Parse(req.Proxy); err != nil { | ||||
| 				return r.Resp400(c, err.Error()) | ||||
| 			} | ||||
|  | ||||
| 			transport.Proxy = http.ProxyURL(pu) | ||||
| 		} | ||||
|  | ||||
| 		if puller, err = remote.NewPuller( | ||||
| 			remote.WithTransport(transport), | ||||
| 		); err != nil { | ||||
| 			return r.Resp500(c, err.Error()) | ||||
| 		} | ||||
|  | ||||
| 		if tn, err = name.NewTag(req.Source); err != nil { | ||||
| 			return r.Resp400(c, err.Error()) | ||||
| 		} | ||||
|  | ||||
| 		_ = c.SSEvent("pull", Msg{ | ||||
| 			Target: req.Target, | ||||
| 			Action: "get", | ||||
| 			Msg:    "开始获取镜像信息", | ||||
| 		}) | ||||
| 		_ = c.Flush() | ||||
|  | ||||
| 		if des, err = puller.Get(c.Request.Context(), tn); err != nil { | ||||
| 			return r.Resp500(c, err.Error()) | ||||
| 		} | ||||
|  | ||||
| 		if img, err = des.Image(); err != nil { | ||||
| 			return r.Resp500(c, err.Error()) | ||||
| 		} | ||||
|  | ||||
| 		if manifest, err = img.Manifest(); err != nil { | ||||
| 			return r.Resp500(c, err.Error()) | ||||
| 		} | ||||
|  | ||||
| 		total := model.ManifestCountSize(manifest) | ||||
| 		size := 0 | ||||
|  | ||||
| 		_ = c.SSEvent("pull", Msg{ | ||||
| 			Target: req.Target, | ||||
| 			Action: "layer", | ||||
| 			Msg:    "正在获取镜像数据: 0.00%", | ||||
| 			Data:   map[string]any{"total": total, "size": size, "index_total": len(manifest.Layers) + 1, "index_size": 0}, | ||||
| 		}) | ||||
| 		_ = c.Flush() | ||||
|  | ||||
| 		var ( | ||||
| 			tly     v1.Layer | ||||
| 			tdigest v1.Hash | ||||
| 			treader io.ReadCloser | ||||
| 		) | ||||
|  | ||||
| 		if tly, err = img.LayerByDigest(manifest.Config.Digest); err != nil { | ||||
| 			return r.Resp500(c, err.Error()) | ||||
| 		} | ||||
|  | ||||
| 		if tdigest, err = tly.Digest(); err != nil { | ||||
| 			return r.Resp500(c, err.Error()) | ||||
| 		} | ||||
|  | ||||
| 		if treader, err = tly.Uncompressed(); err != nil { | ||||
| 			return r.Resp500(c, err.Error()) | ||||
| 		} | ||||
| 		defer treader.Close() | ||||
|  | ||||
| 		if err = bh.Put( | ||||
| 			c.Request.Context(), | ||||
| 			repo, | ||||
| 			model.Hash{Algorithm: tdigest.Algorithm, Hex: tdigest.Hex}, | ||||
| 			treader, | ||||
| 		); err != nil { | ||||
| 			return r.Resp500(c, err.Error()) | ||||
| 		} | ||||
|  | ||||
| 		size = size + int(manifest.Config.Size) | ||||
| 		_ = c.SSEvent("pull", Msg{ | ||||
| 			Target: req.Target, | ||||
| 			Action: "layer", | ||||
| 			Msg:    fmt.Sprintf("正在获取镜像数据: %.2f%%", float64(size)/float64(total)*100), | ||||
| 			Data:   map[string]any{"total": model.ManifestCountSize(manifest), "size": size, "index_total": len(manifest.Layers) + 1, "index_size": 1}, | ||||
| 		}) | ||||
| 		_ = c.Flush() | ||||
|  | ||||
| 		if bs, err = json.Marshal(manifest); err != nil { | ||||
| 			return r.Resp500(c, err.Error()) | ||||
| 		} | ||||
|  | ||||
| 		if mhash, _, err = model.SHA256(bytes.NewReader(bs)); err != nil { | ||||
| 			return r.Resp500(c, err.Error()) | ||||
| 		} | ||||
|  | ||||
| 		for idx := range manifest.Layers { | ||||
| 			var ( | ||||
| 				reader io.ReadCloser | ||||
| 				lyHash v1.Hash | ||||
| 				ly     v1.Layer | ||||
| 			) | ||||
|  | ||||
| 			lyHash = manifest.Layers[idx].Digest | ||||
|  | ||||
| 			if ly, err = img.LayerByDigest(manifest.Layers[idx].Digest); err != nil { | ||||
| 				return r.Resp500(c, err.Error()) | ||||
| 			} | ||||
|  | ||||
| 			if reader, err = ly.Compressed(); err != nil { | ||||
| 				return r.Resp500(c, err.Error()) | ||||
| 			} | ||||
| 			defer reader.Close() | ||||
|  | ||||
| 			if err = bh.Put(c.Request.Context(), repo, model.Hash{Algorithm: lyHash.Algorithm, Hex: lyHash.Hex}, reader); err != nil { | ||||
| 				return r.Resp500(c, err.Error()) | ||||
| 			} | ||||
|  | ||||
| 			size = size + int(manifest.Layers[idx].Size) | ||||
| 			_ = c.SSEvent("pull", Msg{ | ||||
| 				Target: req.Target, | ||||
| 				Action: "layer", | ||||
| 				Msg:    fmt.Sprintf("正在获取镜像数据: %.2f%%", float64(size)/float64(total)*100), | ||||
| 				Data:   map[string]any{"total": model.ManifestCountSize(manifest), "size": size, "index_total": len(manifest.Layers) + 1, "index_size": 2 + idx}, | ||||
| 			}) | ||||
| 			_ = c.Flush() | ||||
| 		} | ||||
|  | ||||
| 		var re *rerr.RepositoryError | ||||
|  | ||||
| 		if re = mh.Put(c.Request.Context(), repo, tag, mhash.String(), &model.RepoSimpleManifest{ | ||||
| 			ContentType: string(manifest.MediaType), | ||||
| 			Blob:        bs, | ||||
| 		}); re != nil { | ||||
| 			return r.Resp(c, uint32(re.Status), re.Message, re.Code, nil) | ||||
| 		} | ||||
|  | ||||
| 		_ = c.SSEvent("pull", Msg{ | ||||
| 			Target: req.Target, | ||||
| 			Action: "done", | ||||
| 			Msg:    "获取成功", | ||||
| 			Data:   manifest, | ||||
| 		}) | ||||
|  | ||||
| 		return c.Flush() | ||||
| 	} | ||||
| } | ||||
| @@ -42,7 +42,11 @@ func handleTags(ctx *nf.Ctx, m interfaces.ManifestHandler) error { | ||||
| 		}) | ||||
| 	} | ||||
|  | ||||
| 	if list, re = m.Tags(ctx.Request.Context(), repo, req.N, req.Last); err != nil { | ||||
| 	if req.N <= 0 { | ||||
| 		req.N = 100 | ||||
| 	} | ||||
|  | ||||
| 	if list, re = m.Tags(ctx.Request.Context(), repo, req.N, req.Last, ""); err != nil { | ||||
| 		return rerr.Error(ctx, re) | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	"nf-repo/internal/interfaces" | ||||
| 	"nf-repo/internal/model" | ||||
| 	"nf-repo/internal/opt" | ||||
| 	"nf-repo/internal/verify" | ||||
| 	"os" | ||||
| 	"path" | ||||
| 	"sync" | ||||
| @@ -48,12 +49,13 @@ func (l *localHandler) Stat(ctx context.Context, repo string, hash model.Hash) ( | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		info os.FileInfo | ||||
| 		sp   = l.path(hash) | ||||
| 	) | ||||
|  | ||||
| 	l.Lock() | ||||
| 	defer l.Unlock() | ||||
|  | ||||
| 	if info, err = os.Stat(l.path(hash)); err != nil { | ||||
| 	if info, err = os.Stat(sp); err != nil { | ||||
| 		if errors.Is(err, os.ErrNotExist) { | ||||
| 			return 0, opt.ErrNotFound | ||||
| 		} | ||||
| @@ -68,11 +70,17 @@ func (l *localHandler) Put(ctx context.Context, repo string, hash model.Hash, rc | ||||
| 	var ( | ||||
| 		err error | ||||
| 		f   *os.File | ||||
| 		nrc io.ReadCloser | ||||
| 	) | ||||
|  | ||||
| 	l.Lock() | ||||
| 	defer l.Unlock() | ||||
|  | ||||
| 	if nrc, err = verify.ReadCloser(rc, verify.SizeUnknown, hash); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer nrc.Close() | ||||
|  | ||||
| 	if f, err = os.OpenFile(l.path(hash), os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0644); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										11
									
								
								internal/interfaces/enum.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								internal/interfaces/enum.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| package interfaces | ||||
|  | ||||
| type Enum interface { | ||||
| 	Value() int64 | ||||
| 	Code() string | ||||
| 	Label() string | ||||
|  | ||||
| 	MarshalJSON() ([]byte, error) | ||||
|  | ||||
| 	All() []Enum | ||||
| } | ||||
| @@ -9,10 +9,10 @@ import ( | ||||
|  | ||||
| type ManifestHandler interface { | ||||
| 	Get(ctx context.Context, repo string, target string) (io.ReadCloser, string, *rerr.RepositoryError) | ||||
| 	Put(ctx context.Context, repo string, target string, digest string, mf *model.Manifest) *rerr.RepositoryError | ||||
| 	Put(ctx context.Context, repo string, target string, digest string, mf *model.RepoSimpleManifest) *rerr.RepositoryError | ||||
| 	Delete(ctx context.Context, repo string, target string) *rerr.RepositoryError | ||||
|  | ||||
| 	Catelog(ctx context.Context, limit int, last int) (*model.Catalog, *rerr.RepositoryError) | ||||
| 	Tags(ctx context.Context, repo string, limit, last int) (*model.Tag, *rerr.RepositoryError) | ||||
| 	Catalog(ctx context.Context, limit int, last int, keyword string) (*model.Catalog, *rerr.RepositoryError) | ||||
| 	Tags(ctx context.Context, repo string, limit, last int, keyword string) (*model.Tag, *rerr.RepositoryError) | ||||
| 	Referrers(ctx context.Context, repo string, target string) (*model.IndexManifest, *rerr.RepositoryError) | ||||
| } | ||||
|   | ||||
| @@ -9,6 +9,7 @@ import ( | ||||
| 	"github.com/samber/lo" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"gorm.io/gorm" | ||||
| 	"gorm.io/gorm/clause" | ||||
| 	"io" | ||||
| 	"net/http" | ||||
| 	"nf-repo/internal/interfaces" | ||||
| @@ -17,16 +18,10 @@ import ( | ||||
| 	"nf-repo/internal/util/tools" | ||||
| ) | ||||
|  | ||||
| type PackageManifest struct { | ||||
| 	Id        uint64 `json:"id" gorm:"primaryKey;column:id"` | ||||
| 	CreatedAt int64  `json:"created_at" gorm:"column:created_at;autoCreateTime:milli"` | ||||
| 	UpdatedAt int64  `json:"updated_at" gorm:"column:updated_at;autoUpdateTime:milli"` | ||||
|  | ||||
| 	Repo        string `json:"repo" gorm:"uniqueIndex:repo_tag_idx;column:repo"` | ||||
| 	Target      string `json:"target" gorm:"uniqueIndex:repo_tag_idx;column:target"` | ||||
| 	Digest      string `json:"digest" gorm:"unique;column:digest"` | ||||
| 	ContentType string `json:"content_type" gorm:"column:content_type"` | ||||
| 	Content     []byte `json:"content" gorm:"column:content;type:bytes"` | ||||
| type pm struct { | ||||
| 	model.PackageManifest | ||||
| 	Digest string `json:"digest" gorm:"column:digest"` | ||||
| 	Size   int    `json:"size" gorm:"column:size"` | ||||
| } | ||||
|  | ||||
| type dbManifests struct { | ||||
| @@ -35,20 +30,38 @@ type dbManifests struct { | ||||
|  | ||||
| func (m *dbManifests) Get(ctx context.Context, repo string, target string) (io.ReadCloser, string, *rerr.RepositoryError) { | ||||
| 	var ( | ||||
| 		err error | ||||
| 		pm  = new(PackageManifest) | ||||
| 		h   model.Hash | ||||
| 		tx  = m.db.TX(tools.Timeout(5)).Model(pm) | ||||
| 		err  error | ||||
| 		hash model.Hash | ||||
| 		pd   = new(model.PackageDigest) | ||||
| 	) | ||||
|  | ||||
| 	if h, err = model.NewHash(target); err == nil { | ||||
| 		tx = tx.Where("digest", h.String()) | ||||
| 	} else { | ||||
| 		tx = tx.Where("repo", repo). | ||||
| 			Where("target", target) | ||||
| 	if hash, err = model.NewHash(target); err == nil { | ||||
| 		if err = m.db.TX(tools.Timeout(5)). | ||||
| 			Model(&model.PackageDigest{}). | ||||
| 			Where("digest", hash.String()). | ||||
| 			Take(pd). | ||||
| 			Error; err != nil { | ||||
|  | ||||
| 			if errors.Is(err, gorm.ErrRecordNotFound) { | ||||
| 				return nil, "", &rerr.RepositoryError{ | ||||
| 					Status:  http.StatusNotFound, | ||||
| 					Code:    "NAME_UNKNOWN", | ||||
| 					Message: fmt.Sprintf("Unknown name: %s@%s", repo, target), | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			return nil, "", rerr.ErrInternal(err) | ||||
| 		} | ||||
|  | ||||
| 		return io.NopCloser(bytes.NewReader(pd.Content)), pd.ContentType, nil | ||||
| 	} | ||||
|  | ||||
| 	if err = tx. | ||||
| 	var pm = new(model.PackageManifest) | ||||
|  | ||||
| 	if err = m.db.TX(tools.Timeout(5)). | ||||
| 		Model(&model.PackageManifest{}). | ||||
| 		Where("repo", repo). | ||||
| 		Where("tag", target). | ||||
| 		Take(pm). | ||||
| 		Error; err != nil { | ||||
| 		if errors.Is(err, gorm.ErrRecordNotFound) { | ||||
| @@ -62,39 +75,85 @@ func (m *dbManifests) Get(ctx context.Context, repo string, target string) (io.R | ||||
| 		return nil, "", rerr.ErrInternal(err) | ||||
| 	} | ||||
|  | ||||
| 	return io.NopCloser(bytes.NewReader(pm.Content)), pm.ContentType, nil | ||||
| 	if err = m.db.TX(tools.Timeout(5)). | ||||
| 		Model(&model.PackageDigest{}). | ||||
| 		Where("id", pm.DigestId). | ||||
| 		Take(pd). | ||||
| 		Error; err != nil { | ||||
| 		logrus. | ||||
| 			WithField("path", "dbManifests.Get"). | ||||
| 			WithField("digest", pm.DigestId). | ||||
| 			WithField("err", err.Error()). | ||||
| 			Error() | ||||
| 		return nil, "", rerr.ErrInternal(err) | ||||
| 	} | ||||
|  | ||||
| 	return io.NopCloser(bytes.NewReader(pd.Content)), pd.ContentType, nil | ||||
| } | ||||
|  | ||||
| func (m *dbManifests) Put(ctx context.Context, repo string, target string, digest string, mf *model.Manifest) *rerr.RepositoryError { | ||||
| func (m *dbManifests) Put(ctx context.Context, repo string, tag string, digest string, mf *model.RepoSimpleManifest) *rerr.RepositoryError { | ||||
|  | ||||
| 	var ( | ||||
| 		err error | ||||
| 		pm  = &PackageManifest{ | ||||
| 			Repo:        repo, | ||||
| 			Target:      target, | ||||
| 		pm  = &model.PackageManifest{ | ||||
| 			Repo: repo, | ||||
| 			Tag:  tag, | ||||
| 		} | ||||
|  | ||||
| 		pd = &model.PackageDigest{ | ||||
| 			Digest:      digest, | ||||
| 			ContentType: mf.ContentType, | ||||
| 			Content:     mf.Blob, | ||||
| 		} | ||||
|  | ||||
| 		blob = new(model.RepoSimpleManifestBlob) | ||||
| 	) | ||||
|  | ||||
| 	// todo on conflict | ||||
| 	if err = json.Unmarshal(mf.Blob, blob); err != nil { | ||||
| 		return rerr.ErrInternal(err) | ||||
| 	} | ||||
|  | ||||
| 	pd.Size = blob.CountSize() | ||||
|  | ||||
| 	if err = m.db.TX(tools.Timeout(5)). | ||||
| 		Clauses(clause.Returning{}). | ||||
| 		Clauses(clause.OnConflict{ | ||||
| 			Columns: []clause.Column{{Name: "digest"}}, | ||||
| 			DoUpdates: clause.Set{ | ||||
| 				{ | ||||
| 					Column: clause.Column{Name: "content_type"}, | ||||
| 					Value:  mf.ContentType, | ||||
| 				}, | ||||
| 				{ | ||||
| 					Column: clause.Column{Name: "content"}, | ||||
| 					Value:  mf.Blob, | ||||
| 				}, | ||||
| 				{ | ||||
| 					Column: clause.Column{Name: "size"}, | ||||
| 					Value:  pd.Size, | ||||
| 				}, | ||||
| 			}}). | ||||
| 		Create(pd). | ||||
| 		Error; err != nil { | ||||
| 		logrus. | ||||
| 			WithField("path", "dbManifests.Put.Create"). | ||||
| 			WithField("err", err.Error()). | ||||
| 			Error() | ||||
| 		return rerr.ErrInternal(err) | ||||
| 	} | ||||
|  | ||||
| 	pm.DigestId = pd.Id | ||||
|  | ||||
| 	if err = m.db.TX(tools.Timeout(5)).Create(pm).Error; err == nil { | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	logrus. | ||||
| 		WithField("path", "dbManifests.Put.Create"). | ||||
| 		WithField("err", err.Error()). | ||||
| 		Trace() | ||||
|  | ||||
| 	if err = m.db.TX(tools.Timeout(5)).Model(&PackageManifest{}). | ||||
| 		Where("(repo = ? AND target = ?) OR (digest = ?)", repo, target, digest). | ||||
| 	if err = m.db.TX(tools.Timeout(5)).Model(&model.PackageManifest{}). | ||||
| 		Where("(repo = ? AND tag = ?)", repo, tag). | ||||
| 		Updates(map[string]any{ | ||||
| 			"repo":         repo, | ||||
| 			"target":       target, | ||||
| 			"digest":       digest, | ||||
| 			"content_type": mf.ContentType, | ||||
| 			"content":      mf.Blob, | ||||
| 			"repo":      repo, | ||||
| 			"tag":       tag, | ||||
| 			"digest_id": pm.DigestId, | ||||
| 		}). | ||||
| 		Error; err != nil { | ||||
| 		logrus. | ||||
| @@ -115,7 +174,7 @@ func (m *dbManifests) Delete(ctx context.Context, repo string, target string) *r | ||||
| 	if err = m.db.TX(tools.Timeout(5)). | ||||
| 		Where("repo", repo). | ||||
| 		Where("target", target). | ||||
| 		Delete(&PackageManifest{}). | ||||
| 		Delete(&model.PackageManifest{}). | ||||
| 		Error; err != nil { | ||||
| 		return rerr.ErrInternal(err) | ||||
| 	} | ||||
| @@ -123,14 +182,23 @@ func (m *dbManifests) Delete(ctx context.Context, repo string, target string) *r | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *dbManifests) Catelog(ctx context.Context, limit int, last int) (*model.Catalog, *rerr.RepositoryError) { | ||||
| func (m *dbManifests) Catalog(ctx context.Context, limit int, last int, keyword string) (*model.Catalog, *rerr.RepositoryError) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		list = make([]*PackageManifest, 0) | ||||
| 		list = make([]*pm, 0) | ||||
| 		tx   = m.db.TX(tools.Timeout(5)) | ||||
| 	) | ||||
|  | ||||
| 	if err = m.db.TX(tools.Timeout(5)).Model(&PackageManifest{}). | ||||
| 		Order("updated_at"). | ||||
| 	tx = tx.Model(&model.PackageManifest{}). | ||||
| 		Select("\"package_manifests\".*", "\"pd\".\"digest\" as digest", "\"pd\".\"size\" as size") | ||||
| 	if keyword != "" { | ||||
| 		k := fmt.Sprintf("%%%s%%", keyword) | ||||
| 		tx = tx.Where("package_manifests.repo like ?", k) | ||||
| 	} | ||||
|  | ||||
| 	if err = tx.Group("\"package_manifests\".\"repo\""). | ||||
| 		Joins("LEFT JOIN package_digests pd on \"pd\".\"id\" = \"package_manifests\".\"digest_id\""). | ||||
| 		Order("updated_at DESC, tag = 'latest' DESC"). | ||||
| 		Offset(last). | ||||
| 		Limit(limit). | ||||
| 		Find(&list). | ||||
| @@ -139,20 +207,39 @@ func (m *dbManifests) Catelog(ctx context.Context, limit int, last int) (*model. | ||||
| 	} | ||||
|  | ||||
| 	return &model.Catalog{ | ||||
| 		Repos: lo.Map(list, func(item *PackageManifest, index int) string { | ||||
| 		Repositories: lo.Map(list, func(item *pm, index int) string { | ||||
| 			return item.Repo | ||||
| 		}), | ||||
| 		Repos: lo.Map(list, func(item *pm, index int) *model.PackageManifest { | ||||
| 			item.PackageManifest.Digest = item.Digest | ||||
| 			item.PackageManifest.Size = item.Size | ||||
| 			return &item.PackageManifest | ||||
| 		}), | ||||
| 	}, nil | ||||
| } | ||||
|  | ||||
| func (m *dbManifests) Tags(ctx context.Context, repo string, limit, last int) (*model.Tag, *rerr.RepositoryError) { | ||||
| func (m *dbManifests) Tags(ctx context.Context, repo string, limit, last int, keyword string) (*model.Tag, *rerr.RepositoryError) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		list = make([]*PackageManifest, 0) | ||||
| 		err   error | ||||
| 		list  = make([]*pm, 0) | ||||
| 		tx    = m.db.TX(tools.Timeout(5)).Model(&model.PackageManifest{}).Select("\"package_manifests\".*", "\"pd\".\"digest\" as digest") | ||||
| 		txc   = m.db.TX(tools.Timeout(5)).Model(&model.PackageManifest{}).Select("COUNT(id)") | ||||
| 		total int | ||||
| 	) | ||||
|  | ||||
| 	if err = m.db.TX(tools.Timeout(5)).Model(&PackageManifest{}). | ||||
| 		Where("repo", repo). | ||||
| 	if keyword != "" { | ||||
| 		k := fmt.Sprintf("%%%s%%", keyword) | ||||
| 		tx = tx.Where("\"package_manifests\".\"tag\" like ?", k) | ||||
| 		txc = txc.Where("tag like ?", k) | ||||
| 	} | ||||
|  | ||||
| 	if err = txc.Find(&total).Error; err != nil { | ||||
| 		return nil, rerr.ErrInternal(err) | ||||
| 	} | ||||
|  | ||||
| 	if err = tx. | ||||
| 		Where("package_manifests.repo", repo). | ||||
| 		Joins("LEFT JOIN package_digests pd on \"pd\".\"id\" = \"package_manifests\".\"digest_id\""). | ||||
| 		Order("updated_at"). | ||||
| 		Offset(last). | ||||
| 		Limit(limit). | ||||
| @@ -163,49 +250,90 @@ func (m *dbManifests) Tags(ctx context.Context, repo string, limit, last int) (* | ||||
|  | ||||
| 	return &model.Tag{ | ||||
| 		Name: repo, | ||||
| 		Tags: lo.Map(list, func(item *PackageManifest, index int) string { | ||||
| 			return item.Target | ||||
| 		Tags: lo.Map(list, func(item *pm, index int) string { | ||||
| 			return item.Tag | ||||
| 		}), | ||||
| 		RepoTags: lo.Map(list, func(item *pm, index int) *model.PackageManifest { | ||||
| 			item.PackageManifest.Digest = item.Digest | ||||
| 			return &item.PackageManifest | ||||
| 		}), | ||||
| 		Total: total, | ||||
| 	}, nil | ||||
| } | ||||
|  | ||||
| func (m *dbManifests) Referrers(ctx context.Context, repo string, target string) (*model.IndexManifest, *rerr.RepositoryError) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		pm       = new(PackageManifest) | ||||
| 		pm       = new(model.PackageManifest) | ||||
| 		pd       = new(model.PackageDigest) | ||||
| 		manifest = &model.IndexManifest{} | ||||
| 		tx       = m.db.TX(tools.Timeout(5)).Model(pm) | ||||
| 		tx       = m.db.TX(tools.Timeout(5)) | ||||
| 		hash     model.Hash | ||||
| 	) | ||||
|  | ||||
| 	h, err := model.NewHash(target) | ||||
| 	if err != nil { | ||||
| 		tx = tx.Where("repo", repo).Where("digest", h.String()) | ||||
| 	} else { | ||||
| 		tx = tx.Where("repo", repo).Where("target", target) | ||||
| 	} | ||||
| 	if hash, err = model.NewHash(target); err == nil { | ||||
| 		if err = tx.Model(&model.PackageDigest{}). | ||||
| 			Where("repo", repo). | ||||
| 			Where("digest", hash.String()). | ||||
| 			Take(pd). | ||||
| 			Error; err != nil { | ||||
|  | ||||
| 	if err = m.db.TX(tools.Timeout(5)).Model(pm). | ||||
| 		Take(pm). | ||||
| 		Error; err != nil { | ||||
| 		if errors.Is(err, gorm.ErrRecordNotFound) { | ||||
| 			return nil, &rerr.RepositoryError{ | ||||
| 				Status:  http.StatusNotFound, | ||||
| 				Code:    "NAME_UNKNOWN", | ||||
| 				Message: fmt.Sprintf("Unknown name: %s@%s", repo, target), | ||||
| 			if errors.Is(err, gorm.ErrRecordNotFound) { | ||||
| 				return nil, &rerr.RepositoryError{ | ||||
| 					Status:  http.StatusNotFound, | ||||
| 					Code:    "NAME_UNKNOWN", | ||||
| 					Message: fmt.Sprintf("Unknown name: %s@%s", repo, target), | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			logrus. | ||||
| 				WithField("path", "dbManifests.Referrers.Take"). | ||||
| 				WithField("repo", repo). | ||||
| 				WithField("target", target). | ||||
| 				WithField("err", err.Error()). | ||||
| 				Debug() | ||||
|  | ||||
| 			return nil, rerr.ErrInternal(err) | ||||
| 		} | ||||
| 	} else { | ||||
| 		if err = tx.Model(&model.PackageManifest{}). | ||||
| 			Where("repo", repo). | ||||
| 			Where("tag", target). | ||||
| 			Take(pd). | ||||
| 			Error; err != nil { | ||||
| 			if errors.Is(err, gorm.ErrRecordNotFound) { | ||||
| 				return nil, &rerr.RepositoryError{ | ||||
| 					Status:  http.StatusNotFound, | ||||
| 					Code:    "NAME_UNKNOWN", | ||||
| 					Message: fmt.Sprintf("Unknown name: %s@%s", repo, target), | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			logrus. | ||||
| 				WithField("path", "dbManifests.Referrers.Take"). | ||||
| 				WithField("repo", repo). | ||||
| 				WithField("target", target). | ||||
| 				Error() | ||||
|  | ||||
| 			return nil, rerr.ErrInternal(err) | ||||
| 		} | ||||
|  | ||||
| 		logrus. | ||||
| 			WithField("path", "dbManifests.Referrers.Take"). | ||||
| 			WithField("repo", repo). | ||||
| 			WithField("target", target). | ||||
| 			WithField("err", err.Error()). | ||||
| 			Debug() | ||||
| 		if err = tx.Model(&model.PackageDigest{}). | ||||
| 			Where("digest_id", pm.DigestId). | ||||
| 			Take(pd). | ||||
| 			Error; err != nil { | ||||
|  | ||||
| 		return nil, rerr.ErrInternal(err) | ||||
| 			logrus. | ||||
| 				WithField("path", "dbManifests.Referrers.Take"). | ||||
| 				WithField("repo", repo). | ||||
| 				WithField("target", target). | ||||
| 				Error() | ||||
|  | ||||
| 			return nil, rerr.ErrInternal(err) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if err = json.Unmarshal(pm.Content, manifest); err != nil { | ||||
| 	if err = json.Unmarshal(pd.Content, manifest); err != nil { | ||||
| 		logrus. | ||||
| 			WithField("path", "dbManifests.Referrers.Unmarshal"). | ||||
| 			WithField("repo", repo). | ||||
| @@ -223,7 +351,10 @@ func NewManifestDBHandler(tx interfaces.Database) interfaces.ManifestHandler { | ||||
| 		err error | ||||
| 	) | ||||
|  | ||||
| 	if err = tx.TX(tools.Timeout(5)).AutoMigrate(&PackageManifest{}); err != nil { | ||||
| 	if err = tx.TX(tools.Timeout(5)).AutoMigrate( | ||||
| 		&model.PackageManifest{}, | ||||
| 		&model.PackageDigest{}, | ||||
| 	); err != nil { | ||||
| 		logrus. | ||||
| 			WithField("path", "NewManifestDBHandler"). | ||||
| 			WithField("method", "AutoMigrate"). | ||||
|   | ||||
| @@ -19,7 +19,7 @@ import ( | ||||
|  | ||||
| type memManifest struct { | ||||
| 	sync.RWMutex | ||||
| 	m map[string]map[string]*model.Manifest | ||||
| 	m map[string]map[string]*model.RepoSimpleManifest | ||||
| } | ||||
|  | ||||
| func (m *memManifest) Referrers(ctx context.Context, repo string, target string) (*model.IndexManifest, *rerr.RepositoryError) { | ||||
| @@ -81,7 +81,7 @@ func (m *memManifest) Referrers(ctx context.Context, repo string, target string) | ||||
| 	return im, nil | ||||
| } | ||||
|  | ||||
| func (m *memManifest) Tags(ctx context.Context, repo string, limit int, last int) (*model.Tag, *rerr.RepositoryError) { | ||||
| func (m *memManifest) Tags(ctx context.Context, repo string, limit int, last int, keyword string) (*model.Tag, *rerr.RepositoryError) { | ||||
| 	m.RLock() | ||||
| 	defer m.RUnlock() | ||||
|  | ||||
| @@ -96,10 +96,20 @@ func (m *memManifest) Tags(ctx context.Context, repo string, limit int, last int | ||||
|  | ||||
| 	var tags []string | ||||
| 	for tag := range c { | ||||
| 		if !strings.Contains(tag, "sha256:") { | ||||
| 		if strings.Contains(tag, "sha256:") { | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		if keyword == "" { | ||||
| 			tags = append(tags, tag) | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		if strings.Contains(tag, keyword) { | ||||
| 			tags = append(tags, tag) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	sort.Strings(tags) | ||||
|  | ||||
| 	// https://github.com/opencontainers/distribution-spec/blob/b505e9cc53ec499edbd9c1be32298388921bb705/detail.md#tags-paginated | ||||
| @@ -134,7 +144,7 @@ func (m *memManifest) Tags(ctx context.Context, repo string, limit int, last int | ||||
| 	return tagsToList, nil | ||||
| } | ||||
|  | ||||
| func (m *memManifest) Catelog(ctx context.Context, limit, last int) (*model.Catalog, *rerr.RepositoryError) { | ||||
| func (m *memManifest) Catalog(ctx context.Context, limit, last int, keyword string) (*model.Catalog, *rerr.RepositoryError) { | ||||
| 	m.RLock() | ||||
| 	defer m.RUnlock() | ||||
|  | ||||
| @@ -146,23 +156,24 @@ func (m *memManifest) Catelog(ctx context.Context, limit, last int) (*model.Cata | ||||
| 		if countRepos >= limit { | ||||
| 			break | ||||
| 		} | ||||
|  | ||||
| 		if keyword != "" && !strings.Contains(key, keyword) { | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		countRepos++ | ||||
|  | ||||
| 		repos = append(repos, key) | ||||
| 	} | ||||
|  | ||||
| 	repositoriesToList := &model.Catalog{ | ||||
| 		Repos: repos, | ||||
| 		Repositories: repos, | ||||
| 	} | ||||
|  | ||||
| 	return repositoriesToList, nil | ||||
| } | ||||
|  | ||||
| func (m *memManifest) Put(ctx context.Context, repo string, target string, digest string, mf *model.Manifest) *rerr.RepositoryError { | ||||
| 	// If the manifest | ||||
| 	// list's constituent manifests are already uploaded. | ||||
| 	// This isn't strictly required by the registry API, but some | ||||
| 	// registries require this. | ||||
| func (m *memManifest) Put(ctx context.Context, repo string, target string, digest string, mf *model.RepoSimpleManifest) *rerr.RepositoryError { | ||||
| 	if types.MediaType(mf.ContentType).IsIndex() { | ||||
| 		if err := func() *rerr.RepositoryError { | ||||
| 			m.RLock() | ||||
| @@ -205,7 +216,7 @@ func (m *memManifest) Put(ctx context.Context, repo string, target string, diges | ||||
| 	defer m.Unlock() | ||||
|  | ||||
| 	if _, ok := m.m[repo]; !ok { | ||||
| 		m.m[repo] = make(map[string]*model.Manifest, 2) | ||||
| 		m.m[repo] = make(map[string]*model.RepoSimpleManifest, 2) | ||||
| 	} | ||||
|  | ||||
| 	// Allow future references by target (tag) and immutable digest. | ||||
| @@ -274,5 +285,5 @@ func (m *memManifest) Get(ctx context.Context, repo string, target string) (io.R | ||||
| } | ||||
|  | ||||
| func NewManifestMemHandler() interfaces.ManifestHandler { | ||||
| 	return &memManifest{m: make(map[string]map[string]*model.Manifest)} | ||||
| 	return &memManifest{m: make(map[string]map[string]*model.RepoSimpleManifest)} | ||||
| } | ||||
|   | ||||
| @@ -6,6 +6,9 @@ import ( | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"gorm.io/gorm" | ||||
| 	"nf-repo/internal/interfaces" | ||||
| 	"nf-repo/internal/opt" | ||||
| 	"os" | ||||
| 	"path" | ||||
| ) | ||||
|  | ||||
| type tx struct { | ||||
| @@ -13,7 +16,13 @@ type tx struct { | ||||
| } | ||||
|  | ||||
| func (t *tx) TX(ctx context.Context) *gorm.DB { | ||||
| 	return t.db.Session(&gorm.Session{}).WithContext(ctx) | ||||
| 	db := t.db.Session(&gorm.Session{}).WithContext(ctx) | ||||
|  | ||||
| 	if opt.Debug { | ||||
| 		db = db.Debug() | ||||
| 	} | ||||
|  | ||||
| 	return db | ||||
| } | ||||
|  | ||||
| func newTX(db *gorm.DB) interfaces.Database { | ||||
| @@ -39,6 +48,10 @@ func Must(database interfaces.Database, err error) interfaces.Database { | ||||
| } | ||||
|  | ||||
| func NewSqliteTX(filepath string) (interfaces.Database, error) { | ||||
| 	if err := os.MkdirAll(path.Dir(filepath), 0755); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	db, err := gorm.Open(sqlite.Open(filepath), &gorm.Config{}) | ||||
| 	return newTX(db), err | ||||
| } | ||||
|   | ||||
| @@ -96,6 +96,12 @@ func (l *localUploader) Done(ctx context.Context, bh interfaces.BlobHandler, id | ||||
| 	} | ||||
| 	defer vrc.Close() | ||||
|  | ||||
| 	logrus. | ||||
| 		WithField("path", "localUploader.Done"). | ||||
| 		WithField("id", id). | ||||
| 		WithField("size", size). | ||||
| 		Error() | ||||
|  | ||||
| 	if err := bh.Put(ctx, repo, hash, vrc); err != nil { | ||||
| 		if errors.As(err, &verify.Error{}) { | ||||
| 			logrus. | ||||
|   | ||||
| @@ -1,5 +1,12 @@ | ||||
| package model | ||||
|  | ||||
| type Catalog struct { | ||||
| 	Repos []string `json:"repositories"` | ||||
| type Repo struct { | ||||
| 	Name      string | ||||
| 	CreatedAt int64 | ||||
| 	UpdatedAt int64 | ||||
| } | ||||
| type Catalog struct { | ||||
| 	Repositories []string           `json:"repositories"` | ||||
| 	Repos        []*PackageManifest `json:"repos"` | ||||
| 	Total        int                `json:"total"` | ||||
| } | ||||
|   | ||||
| @@ -2,15 +2,55 @@ package model | ||||
|  | ||||
| import ( | ||||
| 	"encoding/json" | ||||
| 	v1 "github.com/google/go-containerregistry/pkg/v1" | ||||
| 	"github.com/samber/lo" | ||||
| 	"io" | ||||
| 	"nf-repo/internal/model/types" | ||||
| ) | ||||
|  | ||||
| type Manifest struct { | ||||
| type RepoSimpleManifestLayer struct { | ||||
| 	MediaType string `json:"mediaType"` | ||||
| 	Size      int    `json:"size"` | ||||
| 	Digest    string `json:"digest"` | ||||
| } | ||||
|  | ||||
| type RepoSimpleManifestBlob struct { | ||||
| 	SchemaVersion int    `json:"schemaVersion"` | ||||
| 	MediaType     string `json:"mediaType"` | ||||
| 	Config        struct { | ||||
| 		MediaType string `json:"mediaType"` | ||||
| 		Size      int    `json:"size"` | ||||
| 		Digest    string `json:"digest"` | ||||
| 	} `json:"config"` | ||||
| 	Layers []RepoSimpleManifestLayer `json:"layers"` | ||||
| } | ||||
|  | ||||
| func (b *RepoSimpleManifestBlob) CountSize() int { | ||||
| 	return b.Config.Size + lo.Sum(lo.Map(b.Layers, func(item RepoSimpleManifestLayer, _ int) int { | ||||
| 		return item.Size | ||||
| 	})) | ||||
| } | ||||
|  | ||||
| func ManifestCountSize(m *v1.Manifest) int { | ||||
| 	return int(m.Config.Size) + lo.Sum(lo.Map(m.Layers, func(item v1.Descriptor, _ int) int { | ||||
| 		return int(item.Size) | ||||
| 	})) | ||||
| } | ||||
|  | ||||
| type RepoSimpleManifest struct { | ||||
| 	Blob        []byte `json:"blob"` | ||||
| 	ContentType string `json:"content_type"` | ||||
| } | ||||
|  | ||||
| type Manifest struct { | ||||
| 	SchemaVersion int64             `json:"schemaVersion"` | ||||
| 	MediaType     types.MediaType   `json:"mediaType,omitempty"` | ||||
| 	Config        Descriptor        `json:"config"` | ||||
| 	Layers        []Descriptor      `json:"layers"` | ||||
| 	Annotations   map[string]string `json:"annotations,omitempty"` | ||||
| 	Subject       *Descriptor       `json:"subject,omitempty"` | ||||
| } | ||||
|  | ||||
| type Descriptor struct { | ||||
| 	MediaType    types.MediaType   `json:"mediaType"` | ||||
| 	Size         int64             `json:"size"` | ||||
| @@ -37,3 +77,34 @@ func ParseIndexManifest(r io.Reader) (*IndexManifest, error) { | ||||
| 	} | ||||
| 	return &im, nil | ||||
| } | ||||
|  | ||||
| type PackageManifest struct { | ||||
| 	Id        uint64 `json:"id" gorm:"primaryKey;column:id"` | ||||
| 	CreatedAt int64  `json:"created_at" gorm:"column:created_at;autoCreateTime:milli"` | ||||
| 	UpdatedAt int64  `json:"updated_at" gorm:"column:updated_at;autoUpdateTime:milli"` | ||||
|  | ||||
| 	DigestId uint64 `json:"digest_id" gorm:"column:digest_id"` | ||||
| 	Digest   string `json:"digest" gorm:"-"` | ||||
| 	Size     int    `json:"size" gorm:"-"` | ||||
| 	Repo     string `json:"repo" gorm:"uniqueIndex:repo_tag_idx;column:repo"` | ||||
| 	Tag      string `json:"tag" gorm:"uniqueIndex:repo_tag_idx;column:tag"` | ||||
| } | ||||
|  | ||||
| type PackageDigest struct { | ||||
| 	Id        uint64 `json:"id" gorm:"primaryKey;column:id"` | ||||
| 	CreatedAt int64  `json:"created_at" gorm:"column:created_at;autoCreateTime:milli"` | ||||
| 	UpdatedAt int64  `json:"updated_at" gorm:"column:updated_at;autoUpdateTime:milli"` | ||||
|  | ||||
| 	Digest      string `json:"digest" gorm:"uniqueIndex;column:digest"` | ||||
| 	Size        int    `json:"size" gorm:"column:size;default:0"` | ||||
| 	ContentType string `json:"content_type" gorm:"column:content_type"` | ||||
| 	Content     []byte `json:"content" gorm:"column:content;type:bytes"` | ||||
| } | ||||
|  | ||||
| func ParseManifest(r io.Reader) (*Manifest, error) { | ||||
| 	m := Manifest{} | ||||
| 	if err := json.NewDecoder(r).Decode(&m); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return &m, nil | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| package model | ||||
|  | ||||
| type Tag struct { | ||||
| 	Name string   `json:"name"` | ||||
| 	Tags []string `json:"tags"` | ||||
| 	Name     string             `json:"name"` | ||||
| 	Tags     []string           `json:"tags"` | ||||
| 	RepoTags []*PackageManifest `json:"repo_tags"` | ||||
| 	Total    int                `json:"total"` | ||||
| } | ||||
|   | ||||
| @@ -5,8 +5,11 @@ import "errors" | ||||
| const ( | ||||
| 	DefaultMaxSize   = 32 * 1024 * 1024 | ||||
| 	ReferrersEnabled = true | ||||
|  | ||||
| 	BaseAddress = "repo.me" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	Debug       = false | ||||
| 	ErrNotFound = errors.New("not found") | ||||
| ) | ||||
|   | ||||
							
								
								
									
										136
									
								
								internal/util/r/resp.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								internal/util/r/resp.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,136 @@ | ||||
| package r | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"github.com/loveuer/nf" | ||||
| 	"strings" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| 	MSG200 = "请求成功" | ||||
| 	MSG202 = "请求成功, 请稍后..." | ||||
| 	MSG400 = "请求参数错误" | ||||
| 	MSG401 = "登录已过期, 请重新登录" | ||||
| 	MSG403 = "请求权限不足" | ||||
| 	MSG404 = "请求资源未找到" | ||||
| 	MSG429 = "请求过于频繁, 请稍后再试" | ||||
| 	MSG500 = "服务器开小差了, 请稍后再试" | ||||
| 	MSG501 = "功能开发中, 尽情期待" | ||||
| ) | ||||
|  | ||||
| func handleEmptyMsg(status uint32, msg string) string { | ||||
| 	if msg == "" { | ||||
| 		switch status { | ||||
| 		case 200: | ||||
| 			msg = MSG200 | ||||
| 		case 202: | ||||
| 			msg = MSG202 | ||||
| 		case 400: | ||||
| 			msg = MSG400 | ||||
| 		case 401: | ||||
| 			msg = MSG401 | ||||
| 		case 403: | ||||
| 			msg = MSG403 | ||||
| 		case 404: | ||||
| 			msg = MSG404 | ||||
| 		case 429: | ||||
| 			msg = MSG429 | ||||
| 		case 500: | ||||
| 			msg = MSG500 | ||||
| 		case 501: | ||||
| 			msg = MSG501 | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return msg | ||||
| } | ||||
|  | ||||
| func Resp(c *nf.Ctx, status uint32, msg string, err string, data any) error { | ||||
| 	msg = handleEmptyMsg(status, msg) | ||||
|  | ||||
| 	if data == nil { | ||||
| 		return c.Status(int(status)).JSON(nf.Map{"status": status, "msg": msg, "err": err}) | ||||
| 	} | ||||
|  | ||||
| 	return c.Status(int(status)).JSON(nf.Map{"status": status, "msg": msg, "err": err, "data": data}) | ||||
| } | ||||
|  | ||||
| func Resp200(c *nf.Ctx, data any, msgs ...string) error { | ||||
| 	msg := MSG200 | ||||
|  | ||||
| 	if len(msgs) > 0 && msgs[0] != "" { | ||||
| 		msg = fmt.Sprintf("%s: %s", msg, strings.Join(msgs, "; ")) | ||||
| 	} | ||||
|  | ||||
| 	return Resp(c, 200, msg, "", data) | ||||
| } | ||||
|  | ||||
| func Resp202(c *nf.Ctx, data any, msgs ...string) error { | ||||
| 	msg := MSG202 | ||||
|  | ||||
| 	if len(msgs) > 0 && msgs[0] != "" { | ||||
| 		msg = fmt.Sprintf("%s: %s", msg, strings.Join(msgs, "; ")) | ||||
| 	} | ||||
|  | ||||
| 	return Resp(c, 202, msg, "", data) | ||||
| } | ||||
|  | ||||
| func Resp400(c *nf.Ctx, data any, msgs ...string) error { | ||||
| 	msg := MSG400 | ||||
| 	err := "" | ||||
|  | ||||
| 	if len(msgs) > 0 && msgs[0] != "" { | ||||
| 		msg = fmt.Sprintf("%s: %s", msg, strings.Join(msgs, "; ")) | ||||
| 		err = msg | ||||
| 	} | ||||
|  | ||||
| 	return Resp(c, 400, msg, err, data) | ||||
| } | ||||
|  | ||||
| func Resp401(c *nf.Ctx, data any, msgs ...string) error { | ||||
| 	msg := MSG401 | ||||
| 	err := "" | ||||
|  | ||||
| 	if len(msgs) > 0 && msgs[0] != "" { | ||||
| 		msg = fmt.Sprintf("%s: %s", msg, strings.Join(msgs, "; ")) | ||||
| 		err = msg | ||||
| 	} | ||||
|  | ||||
| 	return Resp(c, 401, msg, err, data) | ||||
| } | ||||
|  | ||||
| func Resp403(c *nf.Ctx, data any, msgs ...string) error { | ||||
| 	msg := MSG403 | ||||
| 	err := "" | ||||
|  | ||||
| 	if len(msgs) > 0 && msgs[0] != "" { | ||||
| 		msg = fmt.Sprintf("%s: %s", msg, strings.Join(msgs, "; ")) | ||||
| 		err = msg | ||||
| 	} | ||||
|  | ||||
| 	return Resp(c, 403, msg, err, data) | ||||
| } | ||||
|  | ||||
| func Resp429(c *nf.Ctx, data any, msgs ...string) error { | ||||
| 	msg := MSG429 | ||||
| 	err := "" | ||||
|  | ||||
| 	if len(msgs) > 0 && msgs[0] != "" { | ||||
| 		msg = fmt.Sprintf("%s: %s", msg, strings.Join(msgs, "; ")) | ||||
| 		err = "" | ||||
| 	} | ||||
|  | ||||
| 	return Resp(c, 429, msg, err, data) | ||||
| } | ||||
|  | ||||
| func Resp500(c *nf.Ctx, data any, msgs ...string) error { | ||||
| 	msg := MSG500 | ||||
| 	err := "" | ||||
|  | ||||
| 	if len(msgs) > 0 && msgs[0] != "" { | ||||
| 		msg = fmt.Sprintf("%s: %s", msg, strings.Join(msgs, "; ")) | ||||
| 		err = msg | ||||
| 	} | ||||
|  | ||||
| 	return Resp(c, 500, msg, err, data) | ||||
| } | ||||
| @@ -1,147 +1,69 @@ | ||||
| // Copyright 2020 Google LLC All Rights Reserved. | ||||
| // | ||||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| // you may not use this file except in compliance with the License. | ||||
| // You may obtain a copy of the License at | ||||
| // | ||||
| //    http://www.apache.org/licenses/LICENSE-2.0 | ||||
| // | ||||
| // Unless required by applicable law or agreed to in writing, software | ||||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| // See the License for the specific language governing permissions and | ||||
| // limitations under the License. | ||||
|  | ||||
| package verify | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"errors" | ||||
| 	"crypto/sha256" | ||||
| 	"encoding/hex" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"strings" | ||||
| 	"nf-repo/internal/model" | ||||
| 	"os" | ||||
| 	"testing" | ||||
|  | ||||
| 	v1 "github.com/google/go-containerregistry/pkg/v1" | ||||
| ) | ||||
|  | ||||
| func mustHash(s string, t *testing.T) v1.Hash { | ||||
| 	h, _, err := v1.SHA256(strings.NewReader(s)) | ||||
| func TestVerify(t *testing.T) { | ||||
| 	bs := []byte(`{"architecture":"amd64","config":{"Hostname":"","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh"],"Image":"sha256:9a5ce069f40cfe0f2270eafbff0a0f2fa08f1add73571af9f78209e96bb8a5e9","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":null},"container":"4189cbc534955765760c227f328ec1cdd52e8550681c2bf9f8f990b27b644f9c","container_config":{"Hostname":"4189cbc53495","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh","-c","#(nop) ","CMD [\"/bin/sh\"]"],"Image":"sha256:9a5ce069f40cfe0f2270eafbff0a0f2fa08f1add73571af9f78209e96bb8a5e9","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":{}},"created":"2024-01-27T00:30:48.743965523Z","docker_version":"20.10.23","history":[{"created":"2024-01-27T00:30:48.624602109Z","created_by":"/bin/sh -c #(nop) ADD file:37a76ec18f9887751cd8473744917d08b7431fc4085097bb6a09d81b41775473 in / "},{"created":"2024-01-27T00:30:48.743965523Z","created_by":"/bin/sh -c #(nop)  CMD [\"/bin/sh\"]","empty_layer":true}],"os":"linux","rootfs":{"type":"layers","diff_ids":["sha256:d4fc045c9e3a848011de66f34b81f052d4f2c15a17bb196d637e526349601820"]}}`) | ||||
| 	//hash, _ := model.NewHash("sha256:05455a08881ea9cf0e752bc48e61bbd71a34c029bb13df01e40e3e70e0d007bd") | ||||
| 	badHash, _ := model.NewHash("sha256:12455a08881ea9cf0e7f2bc48e61bbd71a34c029bb13df01e40e3e70e0d007bd") | ||||
| 	nrc, err := ReadCloser(io.NopCloser(bytes.NewReader(bs)), -1, badHash) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("v1.SHA256(%s) = %v", s, err) | ||||
| 		t.Error(1, err) | ||||
| 		return | ||||
| 	} | ||||
| 	t.Logf("Hashed: %q -> %q", s, h) | ||||
| 	return h | ||||
| } | ||||
|  | ||||
| func TestVerificationFailure(t *testing.T) { | ||||
| 	want := "This is the input string." | ||||
| 	buf := bytes.NewBufferString(want) | ||||
|  | ||||
| 	verified, err := ReadCloser(io.NopCloser(buf), int64(len(want)), mustHash("not the same", t)) | ||||
| 	nbs, err := io.ReadAll(nrc) | ||||
| 	if err != nil { | ||||
| 		t.Fatal("ReadCloser() =", err) | ||||
| 		t.Error(2, err) | ||||
| 	} | ||||
| 	if b, err := io.ReadAll(verified); err == nil { | ||||
| 		t.Errorf("ReadAll() = %q; want verification error", string(b)) | ||||
|  | ||||
| 	if string(nbs) != string(bs) { | ||||
| 		t.Error(3, "not same") | ||||
| 	} | ||||
|  | ||||
| 	t.Log("new bytes:", string(nbs)) | ||||
| } | ||||
|  | ||||
| func TestVerification(t *testing.T) { | ||||
| 	want := "This is the input string." | ||||
| 	buf := bytes.NewBufferString(want) | ||||
|  | ||||
| 	verified, err := ReadCloser(io.NopCloser(buf), int64(len(want)), mustHash(want, t)) | ||||
| func TestVerify2(t *testing.T) { | ||||
| 	name := "4a666f159bd07f62aa19ce8eceac018931223de67c4bd19ded87b83eb7b103ca" | ||||
| 	f, err := os.Open(name) | ||||
| 	if err != nil { | ||||
| 		t.Fatal("ReadCloser() =", err) | ||||
| 		t.Error(1, err) | ||||
| 		return | ||||
| 	} | ||||
| 	if _, err := io.ReadAll(verified); err != nil { | ||||
| 		t.Error("ReadAll() =", err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestVerificationSizeUnknown(t *testing.T) { | ||||
| 	want := "This is the input string." | ||||
| 	buf := bytes.NewBufferString(want) | ||||
|  | ||||
| 	verified, err := ReadCloser(io.NopCloser(buf), SizeUnknown, mustHash(want, t)) | ||||
| 	bs, err := io.ReadAll(f) | ||||
| 	if err != nil { | ||||
| 		t.Fatal("ReadCloser() =", err) | ||||
| 		t.Error(2, err) | ||||
| 	} | ||||
| 	if _, err := io.ReadAll(verified); err != nil { | ||||
| 		t.Error("ReadAll() =", err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestBadHash(t *testing.T) { | ||||
| 	h := v1.Hash{ | ||||
| 		Algorithm: "fake256", | ||||
| 		Hex:       "whatever", | ||||
| 	} | ||||
| 	_, err := ReadCloser(io.NopCloser(strings.NewReader("hi")), 0, h) | ||||
| 	if err == nil { | ||||
| 		t.Errorf("ReadCloser() = %v, wanted err", err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestBadSize(t *testing.T) { | ||||
| 	want := "This is the input string." | ||||
|  | ||||
| 	// having too much content or expecting too much content returns an error. | ||||
| 	for _, size := range []int64{3, 100} { | ||||
| 		t.Run(fmt.Sprintf("expecting size %d", size), func(t *testing.T) { | ||||
| 			buf := bytes.NewBufferString(want) | ||||
| 			rc, err := ReadCloser(io.NopCloser(buf), size, mustHash(want, t)) | ||||
| 			if err != nil { | ||||
| 				t.Fatal("ReadCloser() =", err) | ||||
| 			} | ||||
| 			if b, err := io.ReadAll(rc); err == nil { | ||||
| 				t.Errorf("ReadAll() = %q; want verification error", string(b)) | ||||
| 			} | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestDescriptor(t *testing.T) { | ||||
| 	for _, tc := range []struct { | ||||
| 		err  error | ||||
| 		desc v1.Descriptor | ||||
| 	}{{ | ||||
| 		err: errors.New("error verifying descriptor; Data == nil"), | ||||
| 	}, { | ||||
| 		err: errors.New(`error verifying Digest; got "sha256:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", want ":"`), | ||||
| 		desc: v1.Descriptor{ | ||||
| 			Data: []byte("abc"), | ||||
| 		}, | ||||
| 	}, { | ||||
| 		err: errors.New("error verifying Size; got 3, want 0"), | ||||
| 		desc: v1.Descriptor{ | ||||
| 			Data: []byte("abc"), | ||||
| 			Digest: v1.Hash{ | ||||
| 				Algorithm: "sha256", | ||||
| 				Hex:       "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", | ||||
| 			}, | ||||
| 		}, | ||||
| 	}, { | ||||
| 		desc: v1.Descriptor{ | ||||
| 			Data: []byte("abc"), | ||||
| 			Size: 3, | ||||
| 			Digest: v1.Hash{ | ||||
| 				Algorithm: "sha256", | ||||
| 				Hex:       "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", | ||||
| 			}, | ||||
| 		}, | ||||
| 	}} { | ||||
| 		got, want := Descriptor(tc.desc), tc.err | ||||
|  | ||||
| 		if got == nil { | ||||
| 			if want != nil { | ||||
| 				t.Errorf("Descriptor(): got nil, want %v", want) | ||||
| 			} | ||||
| 		} else if want == nil { | ||||
| 			t.Errorf("Descriptor(): got %v, want nil", got) | ||||
| 		} else if got, want := got.Error(), want.Error(); got != want { | ||||
| 			t.Errorf("Descriptor(): got %q, want %q", got, want) | ||||
| 		} | ||||
|  | ||||
| 	shaer := sha256.New() | ||||
| 	shaer.Write(bs) | ||||
| 	sum := hex.EncodeToString(shaer.Sum(nil)) | ||||
|  | ||||
| 	r, err := ReadCloser(io.NopCloser(bytes.NewReader(bs)), int64(len(bs)), model.Hash{Algorithm: "sha256", Hex: name}) | ||||
| 	if err != nil { | ||||
| 		t.Error(4, err) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if _, err = io.ReadAll(r); err != nil { | ||||
| 		t.Error(5, err) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if sum != name { | ||||
| 		t.Error(3, fmt.Sprintf("want: %s got: %s", name, sum)) | ||||
| 	} | ||||
|  | ||||
| 	_ = r | ||||
| } | ||||
|   | ||||
| @@ -1,57 +0,0 @@ | ||||
| package x | ||||
|  | ||||
| import "testing" | ||||
|  | ||||
| func TestMinPathSum(t *testing.T) { | ||||
| 	grid := [][]int{ | ||||
| 		{3, 8, 6, 0, 5, 9, 9, 6, 3, 4, 0, 5, 7, 3, 9, 3}, | ||||
| 		{0, 9, 2, 5, 5, 4, 9, 1, 4, 6, 9, 5, 6, 7, 3, 2}, | ||||
| 		{8, 2, 2, 3, 3, 3, 1, 6, 9, 1, 1, 6, 6, 2, 1, 9}, | ||||
| 		{1, 3, 6, 9, 9, 5, 0, 3, 4, 9, 1, 0, 9, 6, 2, 7}, | ||||
| 		{8, 6, 2, 2, 1, 3, 0, 0, 7, 2, 7, 5, 4, 8, 4, 8}, | ||||
| 		{4, 1, 9, 5, 8, 9, 9, 2, 0, 2, 5, 1, 8, 7, 0, 9}, | ||||
| 		{6, 2, 1, 7, 8, 1, 8, 5, 5, 7, 0, 2, 5, 7, 2, 1}, | ||||
| 		{8, 1, 7, 6, 2, 8, 1, 2, 2, 6, 4, 0, 5, 4, 1, 3}, | ||||
| 		{9, 2, 1, 7, 6, 1, 4, 3, 8, 6, 5, 5, 3, 9, 7, 3}, | ||||
| 		{0, 6, 0, 2, 4, 3, 7, 6, 1, 3, 8, 6, 9, 0, 0, 8}, | ||||
| 		{4, 3, 7, 2, 4, 3, 6, 4, 0, 3, 9, 5, 3, 6, 9, 3}, | ||||
| 		{2, 1, 8, 8, 4, 5, 6, 5, 8, 7, 3, 7, 7, 5, 8, 3}, | ||||
| 		{0, 7, 6, 6, 1, 2, 0, 3, 5, 0, 8, 0, 8, 7, 4, 3}, | ||||
| 		{0, 4, 3, 4, 9, 0, 1, 9, 7, 7, 8, 6, 4, 6, 9, 5}, | ||||
| 		{6, 5, 1, 9, 9, 2, 2, 7, 4, 2, 7, 2, 2, 3, 7, 2}, | ||||
| 		{7, 1, 9, 6, 1, 2, 7, 0, 9, 6, 6, 4, 4, 5, 1, 0}, | ||||
| 		{3, 4, 9, 2, 8, 3, 1, 2, 6, 9, 7, 0, 2, 4, 2, 0}, | ||||
| 		{5, 1, 8, 8, 4, 6, 8, 5, 2, 4, 1, 6, 2, 2, 9, 7}, | ||||
| 	} | ||||
|  | ||||
| 	result := minPathSum(grid) | ||||
|  | ||||
| 	t.Log("result:", result) | ||||
| } | ||||
|  | ||||
| func minPathSum(grid [][]int) int { | ||||
| 	return sum(grid, len(grid)-1, len(grid[0])-1) | ||||
| } | ||||
|  | ||||
| func sum(grid [][]int, x, y int) int { | ||||
| 	if x == 0 && y == 0 { | ||||
| 		return grid[x][y] | ||||
| 	} | ||||
|  | ||||
| 	if x == 0 { | ||||
| 		return grid[x][y] + sum(grid, x, y-1) | ||||
| 	} | ||||
|  | ||||
| 	if y == 0 { | ||||
| 		return grid[x][y] + sum(grid, x-1, y) | ||||
| 	} | ||||
|  | ||||
| 	return grid[x][y] + _min(sum(grid, x-1, y), sum(grid, x, y-1)) | ||||
| } | ||||
|  | ||||
| func _min(a, b int) int { | ||||
| 	if a < b { | ||||
| 		return a | ||||
| 	} | ||||
| 	return b | ||||
| } | ||||
							
								
								
									
										37
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								main.go
									
									
									
									
									
								
							| @@ -5,34 +5,49 @@ package main | ||||
| import ( | ||||
| 	"context" | ||||
| 	"crypto/tls" | ||||
| 	"flag" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"nf-repo/internal/api" | ||||
| 	"nf-repo/internal/interfaces" | ||||
| 	"nf-repo/internal/interfaces/blobs" | ||||
| 	"nf-repo/internal/interfaces/manifests" | ||||
| 	"nf-repo/internal/interfaces/tx" | ||||
| 	"nf-repo/internal/interfaces/uploads" | ||||
| 	"nf-repo/internal/opt" | ||||
| 	"path" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	tlsCfg *tls.Config | ||||
| 	bh     = blobs.NewLocalBlobHandler("images/layers") | ||||
| 	//uh     = uploads.NewMemUploader() | ||||
| 	uh = uploads.NewLocalUploader("images/uploads") | ||||
| 	//mh     = manifests.NewManifestMemHandler() | ||||
| 	mh = manifests.NewManifestDBHandler(tx.Must(tx.NewSqliteTX("data.sqlite"))) | ||||
| 	tlsCfg                     *tls.Config | ||||
| 	bh                         interfaces.BlobHandler | ||||
| 	uh                         interfaces.UploadHandler | ||||
| 	mh                         interfaces.ManifestHandler | ||||
| 	crtPath, keyPath, dataPath string | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	logrus.SetFormatter(&logrus.JSONFormatter{TimestampFormat: "06/01/02 15:04:05"}) | ||||
| 	logrus.SetLevel(logrus.InfoLevel) | ||||
| 	logrus.SetReportCaller(true) | ||||
| 	flag.BoolVar(&opt.Debug, "debug", false, "debug mode") | ||||
| 	flag.StringVar(&crtPath, "crt", "etc/repo.me.crt", "certificate file") | ||||
| 	flag.StringVar(&keyPath, "key", "etc/repo.me.key", "certificate key file") | ||||
| 	flag.StringVar(&dataPath, "data", "images", "images, sqlite ... data path") | ||||
| 	flag.Parse() | ||||
|  | ||||
| 	crt, err := tls.LoadX509KeyPair("etc/repo.me.crt", "etc/repo.me.key") | ||||
| 	if opt.Debug { | ||||
| 		logrus.SetFormatter(&logrus.JSONFormatter{TimestampFormat: "06/01/02 15:04:05"}) | ||||
| 		logrus.SetLevel(logrus.DebugLevel) | ||||
| 		logrus.SetReportCaller(true) | ||||
| 	} | ||||
|  | ||||
| 	crt, err := tls.LoadX509KeyPair(crtPath, keyPath) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 		logrus.Panic(err) | ||||
| 	} | ||||
|  | ||||
| 	tlsCfg = &tls.Config{Certificates: []tls.Certificate{crt}} | ||||
|  | ||||
| 	mh = manifests.NewManifestDBHandler(tx.Must(tx.NewSqliteTX(path.Join(dataPath, "data.sqlite")))) | ||||
| 	bh = blobs.NewLocalBlobHandler(path.Join(dataPath, "layers")) | ||||
| 	uh = uploads.NewLocalUploader(path.Join(dataPath, "uploads")) | ||||
| } | ||||
|  | ||||
| func main() { | ||||
|   | ||||
							
								
								
									
										127
									
								
								x/t1/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								x/t1/main.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,127 @@ | ||||
| // https://iximiuz.com/en/posts/working-with-container-images-in-go/ | ||||
| // package main | ||||
| // | ||||
| // import ( | ||||
| // | ||||
| //	"context" | ||||
| //	"nf-repo/internal/util/tools" | ||||
| //	"os" | ||||
| // | ||||
| //	"github.com/containers/image/copy" | ||||
| //	"github.com/containers/image/signature" | ||||
| //	"github.com/containers/image/storage" | ||||
| //	"github.com/containers/image/transports/alltransports" | ||||
| //	"github.com/containers/image/types" | ||||
| // | ||||
| // ) | ||||
| // | ||||
| //	func main() { | ||||
| //		imageName := "docker://alpine:latest" | ||||
| //		srcRef, _ := alltransports.ParseImageName(imageName) | ||||
| // | ||||
| //		// Carries various default locations. | ||||
| //		systemCtx := &types.SystemContext{} | ||||
| //		policy, _ := signature.DefaultPolicy(systemCtx) | ||||
| //		policyCtx, _ := signature.NewPolicyContext(policy) | ||||
| // | ||||
| //		dstName := imageName | ||||
| //		if srcRef.DockerReference() != nil { | ||||
| //			dstName = srcRef.DockerReference().String() | ||||
| //		} | ||||
| //		store := createStore() // see previous section | ||||
| //		dstRef, _ := storage.Transport.ParseStoreReference(store, dstName) | ||||
| // | ||||
| //		copyOptions := ©.Options{ReportWriter: os.Stdout} | ||||
| //		manifest, _ := copy.Image( | ||||
| //			context.Background(), | ||||
| //			policyCtx, | ||||
| //			dstRef, | ||||
| //			srcRef, | ||||
| //			copyOptions, | ||||
| //		) | ||||
| //		println(string(manifest)) | ||||
| //	} | ||||
|  | ||||
| package main | ||||
|  | ||||
| import ( | ||||
| 	"encoding/json" | ||||
| 	"github.com/containers/image/v5/pkg/blobinfocache" | ||||
| 	"github.com/containers/image/v5/transports/alltransports" | ||||
| 	"github.com/containers/image/v5/types" | ||||
| 	digest "github.com/opencontainers/go-digest" | ||||
| 	"log" | ||||
| 	"nf-repo/internal/util/tools" | ||||
| 	"runtime" | ||||
| ) | ||||
|  | ||||
| type M struct { | ||||
| 	Manifests []struct { | ||||
| 		Digest    string `json:"digest"` | ||||
| 		MediaType string `json:"mediaType"` | ||||
| 		Platform  struct { | ||||
| 			Architecture string `json:"architecture"` | ||||
| 			Os           string `json:"os"` | ||||
| 			Variant      string `json:"variant,omitempty"` | ||||
| 		} `json:"platform"` | ||||
| 		Size int `json:"size"` | ||||
| 	} `json:"manifests"` | ||||
| 	MediaType     string `json:"mediaType"` | ||||
| 	SchemaVersion int    `json:"schemaVersion"` | ||||
| } | ||||
|  | ||||
| func main() { | ||||
| 	imageName := "docker://alpine:latest" | ||||
| 	srcRef, _ := alltransports.ParseImageName(imageName) | ||||
|  | ||||
| 	// Carries various default locations. | ||||
| 	systemCtx := &types.SystemContext{ | ||||
| 		DockerInsecureSkipTLSVerify: types.OptionalBoolTrue, | ||||
| 		DockerDisableV1Ping:         true, | ||||
| 	} | ||||
|  | ||||
| 	log.Printf("[NewImageSource] start!!!") | ||||
| 	imgSrc, err := srcRef.NewImageSource(tools.Timeout(60), systemCtx) | ||||
| 	if err != nil { | ||||
| 		log.Panic(1, err) | ||||
| 	} | ||||
|  | ||||
| 	log.Printf("[GetManifest] start!!!") | ||||
| 	bs, str, err := imgSrc.GetManifest(tools.Timeout(5), nil) | ||||
| 	if err != nil { | ||||
| 		log.Panic(2, err) | ||||
| 	} | ||||
|  | ||||
| 	log.Printf("[manifest] bs=%s str=%s", string(bs), str) | ||||
|  | ||||
| 	var ( | ||||
| 		m = new(M) | ||||
| 		d string | ||||
| 	) | ||||
| 	if err = json.Unmarshal(bs, m); err != nil { | ||||
| 		log.Panic(3, err) | ||||
| 	} | ||||
|  | ||||
| 	for _, item := range m.Manifests { | ||||
| 		if item.Platform.Os == "linux" && item.Platform.Architecture == runtime.GOARCH { | ||||
| 			d = item.Digest | ||||
| 			break | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if d == "" { | ||||
| 		log.Panicf("[4] empty digest: %s - %s", runtime.GOOS, runtime.GOARCH) | ||||
| 	} | ||||
|  | ||||
| 	rc, size, err := imgSrc.GetBlob(tools.Timeout(60), | ||||
| 		types.BlobInfo{ | ||||
| 			Digest: digest.Digest(d), | ||||
| 		}, blobinfocache.DefaultCache(systemCtx)) | ||||
| 	if err != nil { | ||||
| 		log.Panic(5, err) | ||||
| 	} | ||||
|  | ||||
| 	log.Printf("[GetBlob] size=%d", size) | ||||
|  | ||||
| 	rc.Close() | ||||
| } | ||||
							
								
								
									
										61
									
								
								x/t2/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								x/t2/main.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| package main | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/google/go-containerregistry/pkg/name" | ||||
| 	"github.com/google/go-containerregistry/pkg/v1/remote" | ||||
| 	"io" | ||||
| 	"log" | ||||
| 	"os/signal" | ||||
| 	"syscall" | ||||
| ) | ||||
|  | ||||
| func main() { | ||||
| 	ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT) | ||||
| 	defer cancel() | ||||
|  | ||||
| 	puller, err := remote.NewPuller() | ||||
| 	if err != nil { | ||||
| 		log.Panic(1, err) | ||||
| 	} | ||||
|  | ||||
| 	//imageName := "loveuer/hello:v2.0.1" | ||||
| 	imageName := "alpine:latest" | ||||
| 	tn, err := name.NewTag(imageName) | ||||
| 	if err != nil { | ||||
| 		log.Panic(2, err) | ||||
| 	} | ||||
|  | ||||
| 	des, err := puller.Get(ctx, tn) | ||||
| 	if err != nil { | ||||
| 		log.Panic(3, err) | ||||
| 	} | ||||
|  | ||||
| 	img, err := des.Image() | ||||
| 	if err != nil { | ||||
| 		log.Panic(4, err) | ||||
| 	} | ||||
|  | ||||
| 	lys, err := img.Layers() | ||||
| 	if err != nil { | ||||
| 		log.Panic(5, err) | ||||
| 	} | ||||
|  | ||||
| 	rs := make([]io.Reader, 0) | ||||
| 	for _, item := range lys { | ||||
| 		r, err := item.Uncompressed() | ||||
| 		if err != nil { | ||||
| 			log.Panic(6, err) | ||||
| 		} | ||||
|  | ||||
| 		rs = append(rs, r) | ||||
| 	} | ||||
|  | ||||
| 	allr := io.MultiReader(rs...) | ||||
| 	bs, err := io.ReadAll(allr) | ||||
| 	if err != nil { | ||||
| 		log.Panic(7, err) | ||||
| 	} | ||||
|  | ||||
| 	log.Printf("size: %.2f MB", float64(len(bs))/1024/1024) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user