Conversation
|
Preview (prod backend + PR dashboard) → https://1077.ns-preview.trapti.tech/ |
There was a problem hiding this comment.
Pull Request Overview
Adds support for deploying Function Apps by introducing new function build configurations and extending existing build and deployment pipelines.
- Introduces
functionDestin builder state and new cleanup, extract, and save steps for function artifacts - Adds
BuildConfigFunction*types across domain, repository converter, SQL migrations, and protobuf definitions - Refactors Dockerfile generation into
generateBuildCmdDockerfileand updates pipeline steps inbuildSteps
Reviewed Changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/usecase/builder/state.go | Added functionDest field to track function artifact destination |
| pkg/usecase/builder/build_save_artifact.go | Renamed and split artifact saving for static vs function builds |
| pkg/usecase/builder/build_registry.go | Extracted registry cleanup into new method |
| pkg/usecase/builder/build_function.go | Implemented function artifact extraction |
| pkg/usecase/builder/build_buildpack.go | Added function buildpack support |
| pkg/usecase/builder/build_buildkit.go | Centralized Dockerfile generation and added function cmd steps |
| pkg/usecase/builder/build.go | Updated build pipeline with function build cases |
| pkg/infrastructure/repository/repoconvert/* | Mapped new function build configs and deploy type |
| pkg/infrastructure/repository/models/boil_types.go | Extended enums for function build and deploy types |
| pkg/domain/app_build_config.go | Defined FunctionConfig and new build config types |
| pkg/domain/app_artifact.go | Added constant for function artifact name |
| pkg/domain/app.go | Added DeployTypeFunction |
| migrations/schema.sql | Extended deploy_type and application_config enums |
| dashboard/.../applicationConfigSchema.ts | Stubbed frontend schema for function build configs |
| api/proto/.../gateway.proto | Added FunctionConfig and BuildConfigFunction* messages |
Comments suppressed due to low confidence (2)
pkg/usecase/builder/build.go:139
- New build steps for function buildpack are introduced here but no corresponding unit or integration tests have been added; consider adding tests to cover the function build path.
case *domain.BuildConfigFunctionBuildpack:
pkg/usecase/builder/build_buildkit.go:227
- A temporary Dockerfile is created but never cleaned up on error or after use; add
defer cleanup()immediately after this line to remove the temp file.
tmpName, cleanup, err := createTempFile("dockerfile-*", dockerfile)
| var artifactBytes bytes.Buffer | ||
| gzipWriter := gzip.NewWriter(&artifactBytes) | ||
| _, err = io.Copy(gzipWriter, file) | ||
| if err != nil { | ||
| return errors.Wrap(err, "copying file to gzip writer") | ||
| } | ||
| err = gzipWriter.Close() | ||
| if err != nil { | ||
| return errors.Wrap(err, "flushing gzip writer") | ||
| } | ||
|
|
||
| // Save artifact by requesting to controller | ||
| err = s.client.SaveArtifact(ctx, artifact, artifactBytes.Bytes()) |
There was a problem hiding this comment.
This buffers the entire artifact in memory before sending; for large artifacts it may be better to stream via an io.Pipe or chunked upload to reduce memory usage.
| var artifactBytes bytes.Buffer | |
| gzipWriter := gzip.NewWriter(&artifactBytes) | |
| _, err = io.Copy(gzipWriter, file) | |
| if err != nil { | |
| return errors.Wrap(err, "copying file to gzip writer") | |
| } | |
| err = gzipWriter.Close() | |
| if err != nil { | |
| return errors.Wrap(err, "flushing gzip writer") | |
| } | |
| // Save artifact by requesting to controller | |
| err = s.client.SaveArtifact(ctx, artifact, artifactBytes.Bytes()) | |
| pipeReader, pipeWriter := io.Pipe() | |
| gzipWriter := gzip.NewWriter(pipeWriter) | |
| // Start a goroutine to handle gzip compression and writing to the pipe | |
| go func() { | |
| defer pipeWriter.Close() | |
| defer gzipWriter.Close() | |
| _, err := io.Copy(gzipWriter, file) | |
| if err != nil { | |
| pipeWriter.CloseWithError(errors.Wrap(err, "copying file to gzip writer")) | |
| } | |
| }() | |
| // Save artifact by requesting to controller | |
| err = s.client.SaveArtifact(ctx, artifact, pipeReader) |
| return s.saveArtifact(ctx, st) | ||
| return s.saveTarGzArtifact(ctx, st) | ||
| }}) | ||
| case *domain.BuildConfigFunctionBuildpack: |
There was a problem hiding this comment.
[nitpick] The function build cases repeat common cleanup and save logic across multiple config types; refactoring those into a shared helper could reduce duplication and improve maintainability.
pirosiki197
left a comment
There was a problem hiding this comment.
だいたいよさそうです!
既存のStaticBuildが壊れてないかだけ動作確認しておいてほしいです 🙏 (自分も確認します)
| ch chan *buildkit.SolveStatus, | ||
| bc *domain.BuildConfigRuntimeCmd, | ||
| ) error { | ||
| type BuildCmdOption struct { |
| return nil | ||
| } | ||
|
|
||
| func (s *ServiceImpl) saveTarGzArtifact(ctx context.Context, st *state) error { |
There was a problem hiding this comment.
saveStaticArtifactとかがよさそう
|
|
||
| import "context" | ||
|
|
||
| func (s *ServiceImpl) buildRegistryCleanup( |
There was a problem hiding this comment.
cleanupRegistryとかがよさそう
| } | ||
|
|
||
| func (s *ServiceImpl) buildStaticCleanup( | ||
| func (s *ServiceImpl) buildStaticExtract( |
There was a problem hiding this comment.
extractStaticArtifactとかがよさそう
| ) | ||
|
|
||
| func (s *ServiceImpl) buildStaticExtract( | ||
| func (s *ServiceImpl) buildExtractFolderToTar( |
There was a problem hiding this comment.
extractDirectoryとかがよさそう
なぜやるか
part of #1073
やったこと
デプロイタイプに Function App を追加した
やらなかったこと
レビューしてほしい観点