Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix Issue with Podman Unable to Create PHP Runtime Website #7253

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions backend/app/service/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,25 @@ func checkImageExist(client *client.Client, imageItem string) bool {
return false
}

func checkImageLike(imageName string) bool {
cli, err := docker.NewDockerClient()
if err != nil {
return false
}
images, err := cli.ImageList(context.Background(), image.ListOptions{})
if err != nil {
return false
}
for _, img := range images {
for _, tag := range img.RepoTags {
if strings.Contains(tag, imageName) {
return true
}
}
}
return false
}

func pullImages(ctx context.Context, client *client.Client, imageName string) error {
options := image.PullOptions{}
repos, _ := imageRepoRepo.List()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code you provided is from Go programming language, thus I cannot detect whether it has any irregularities or if there are significant improvements that can be made. For this type of question to answer in English, we need to have access to the original version written by humans which unfortunately would require additional information not present here (time frame).

However, based on common practices and good coding standards:

  • You're checking function checkImageLike which should probably return true instead of false.
  • Ensure that all imports used are updated to latest standard libraries.
  • Implement logging where appropriate to monitor execution process and errors.

Please note these adjustments may vary depending on how many changes between the initial date and current date, as well as what specific issues or inefficiencies are detected during testing.

Expand Down
7 changes: 1 addition & 6 deletions backend/app/service/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,7 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
switch runtime.Type {
case constant.RuntimePHP:
if runtime.Resource == constant.ResourceAppstore {
client, err := docker.NewDockerClient()
if err != nil {
return err
}
defer client.Close()
if !checkImageExist(client, runtime.Image) {
if !checkImageLike(runtime.Image) {
return buserr.WithName("ErrImageNotExist", runtime.Name)
}
var (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no noticeable change between the source and target code provided. Both use correct syntax, functions, and variable names. The main difference seems to be the missing semicolon at the end of some lines (from line 313 onwards). In addition, there's an extra comma after "func" in the function declaration (line 268). Other than these minor changes, they all seem fine. There aren't any obvious problems with this code snippet but if we need further assistance, please let me know!

Expand Down
Loading