Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/2.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmccallister committed Mar 17, 2021
2 parents 3ffd6ed + ac9a50b commit 7459549
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 105 deletions.
20 changes: 14 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# Release Notes for Craft Nitro

## 2.0.6 - 2021-03-17

### Fixed
- Fixed an error where `initset` was not updating opcache settings. [#298](https://github.com/craftcms/nitro/issues/298)
- Fixed an error preventing Linux users from using Xdebug. [#288](https://github.com/docker/for-linux/issues/288)
- Fixed a display error for Windows users when using the `trust` command. [#291](https://github.com/craftcms/nitro/issues/291)
- Fixed a bug where command completion was not working in a zsh shell. [#295](https://github.com/craftcms/nitro/issues/295)

## 2.0.5 - 2021-03-09

### Added
- Added the `php` command to execute PHP commands in a site container [#276](https://github.com/craftcms/nitro/issues/276).
- Added the `php` command to execute PHP commands in a site container. [#276](https://github.com/craftcms/nitro/issues/276)

### Fixed
- Fixed an error where mysql permissions were not being set properly [#275](https://github.com/craftcms/nitro/issues/275).
- Fixed an error that could occur when paths included spaces [#277](https://github.com/craftcms/nitro/issues/277).
- Fixed an error where mysql permissions were not being set properly. [#275](https://github.com/craftcms/nitro/issues/275)
- Fixed an error that could occur when paths included spaces. [#277](https://github.com/craftcms/nitro/issues/277)
- Fixed certificate installations for POP!_OS Linux.

## 2.0.4 - 2021-03-04
Expand All @@ -16,13 +24,13 @@
- Nitro will now verify and start containers if not running.

### Fixed
- Fixed an error that could occur when running `version` before `init` [#270](https://github.com/craftcms/nitro/issues/270).
- Fixed an error that could occur when Nitro is unable to detect the database engine from a backup [#269](https://github.com/craftcms/nitro/issues/269).
- Fixed an error that could occur when running `version` before `init`. [#270](https://github.com/craftcms/nitro/issues/270)
- Fixed an error that could occur when Nitro is unable to detect the database engine from a backup. [#269](https://github.com/craftcms/nitro/issues/269)

## 2.0.3 - 2021-03-03

### Fixed
- Fixed a bug where the `iniset` command was not updating PHP settings for sites [#268](https://github.com/craftcms/nitro/issues/268).
- Fixed a bug where the `iniset` command was not updating PHP settings for sites. [#268](https://github.com/craftcms/nitro/issues/268)

## 2.0.2 - 2021-03-02

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: docker docs

VERSION ?= 2.0.4
VERSION ?= 2.0.6

build:
go build -trimpath -ldflags="-s -w -X 'github.com/craftcms/nitro/command/version.Version=${VERSION}'" -o nitro ./cmd/nitro
Expand Down
2 changes: 1 addition & 1 deletion command/apply/internal/match/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func checkEnvs(site config.Site, blackfire config.Blackfire, envs []string) bool
return false
}
case "PHP_OPCACHE_ENABLE":
if site.PHP.OpcacheEnable && val == config.DefaultEnvs[env] {
if (site.PHP.OpcacheEnable && val == config.DefaultEnvs[env]) || (!site.PHP.OpcacheEnable && val != config.DefaultEnvs[env]) {
return false
}
case "PHP_OPCACHE_REVALIDATE_FREQ":
Expand Down
14 changes: 14 additions & 0 deletions command/apply/internal/match/match_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ func Test_checkEnvs(t *testing.T) {
},
want: false,
},
{
name: "opcache_disable returns false",
args: args{
site: config.Site{
PHP: config.PHP{
OpcacheEnable: false,
},
},
envs: []string{
"PHP_OPCACHE_ENABLE=1",
},
},
want: false,
},
{
name: "opcache_enable returns false",
args: args{
Expand Down
7 changes: 7 additions & 0 deletions command/apply/internal/sitecontainer/sitecontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import (
"context"
"fmt"
"os"
"runtime"
"strings"

"github.com/craftcms/nitro/command/apply/internal/match"
"github.com/craftcms/nitro/command/apply/internal/nginx"
"github.com/craftcms/nitro/pkg/config"
"github.com/craftcms/nitro/pkg/containerlabels"
"github.com/craftcms/nitro/pkg/wsl"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
Expand Down Expand Up @@ -109,6 +111,11 @@ func create(ctx context.Context, docker client.CommonAPIClient, home, networkID
extraHosts = append(extraHosts, fmt.Sprintf("%s:%s", s, "127.0.0.1"))
}

// check if this is linux specific
if runtime.GOOS == "linux" && !wsl.IsWSL() {
extraHosts = append(extraHosts, fmt.Sprintf("%s:%s", "host.docker.internal", "host-gateway"))
}

// get the sites environment variables
envs := site.AsEnvs("host.docker.internal")

Expand Down
34 changes: 0 additions & 34 deletions command/completion/bash.go

This file was deleted.

33 changes: 20 additions & 13 deletions command/completion/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ package completion

import (
"fmt"
"os"

"github.com/spf13/cobra"
)

var (
// ErrExample is used when we want to share an error
ErrExample = fmt.Errorf("not implemented")
)

const exampleText = `To load completions:
Bash:
Expand All @@ -36,18 +32,29 @@ $ nitro completion zsh > "${fpath[1]}/_nitro"
# You will need to start a new shell for this setup to take effect.
`

// New is used for scaffolding new commands
func New() *cobra.Command {
// NewCommand returns the command used for generating completion shells
func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "completion",
Short: "Enable shell completion",
Example: exampleText,
Use: "completion",
Short: "Enable shell completion",
ValidArgs: []string{"bash", "zsh"},
Example: exampleText,
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
// print the help if not defined
if len(args) == 0 {
return cmd.Help()
}

switch args[0] {
case "zsh":
return cmd.Root().GenZshCompletion(os.Stdout)
case "bash":
return cmd.Root().GenBashCompletion(os.Stdout)
}

return fmt.Errorf("unknown shell requested")
},
}

cmd.AddCommand(bashCompletionCommand, zshCompletionCommand)

return cmd
}
32 changes: 0 additions & 32 deletions command/completion/zsh.go

This file was deleted.

7 changes: 1 addition & 6 deletions command/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ func NewCommand() *cobra.Command {
log.Fatal(err)
}

// if _, err := docker.Ping(contextpkg.Background()); err != nil {
// fmt.Println("Unable to talk to Docker, it appears it is not running…")
// os.Exit(2)
// }

// get the port for the nitrod API
apiPort := "5000"
if os.Getenv("NITRO_API_PORT") != "" {
Expand All @@ -110,7 +105,7 @@ func NewCommand() *cobra.Command {
blackfire.NewCommand(home, docker, term),
bridge.NewCommand(home, docker, term),
clean.NewCommand(home, docker, term),
completion.New(),
completion.NewCommand(),
composer.NewCommand(docker, term),
container.NewCommand(home, docker, term),
context.NewCommand(home, docker, term),
Expand Down
8 changes: 4 additions & 4 deletions pkg/certinstall/certinstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func Install(file, system string) error {
}

// find the linux distro
dist, err := findDistro(buf.String())
dist, err := identify(buf.String())
if err != nil {
return err
}
Expand Down Expand Up @@ -78,7 +78,7 @@ func Install(file, system string) error {
if dist, exists := os.LookupEnv("WSL_DISTRO_NAME"); exists {
user := os.Getenv("USER")
fmt.Println("Users on WSL will need to open an elevated (run as administrator) Command Prompt or terminal on Windows and run the following command:")
fmt.Printf(`certutil -addstore -f "Root" \\wsl$\%s\home\%s\.nitro\nitro.crt\n`, dist, user)
fmt.Println(fmt.Printf(`certutil -addstore -f "Root" \\wsl$\%s\home\%s\.nitro\nitro.crt`, dist, user))
}
default:
// add the certificate to the macOS keychain
Expand All @@ -90,14 +90,14 @@ func Install(file, system string) error {
return nil
}

func findDistro(description string) (string, error) {
func identify(description string) (string, error) {
// detect arch systems
if strings.Contains(description, "Manjaro") || strings.Contains(description, "Arch Linux") {
return "arch", nil
}

// detect debian systems
if strings.Contains(description, "Ubuntu") || strings.Contains(description, "Pop!_OS") {
if strings.Contains(description, "Ubuntu") || strings.Contains(description, "Pop!_OS") || strings.Contains(description, "Mint") {
return "debian", nil
}

Expand Down
9 changes: 1 addition & 8 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,10 @@ func (s *Site) GetContainerPath() string {
func (s *Site) AsEnvs(addr string) []string {
var envs []string

if addr == "" {
addr = "host.docker.internal"
}

// set the php vars
envs = append(envs, phpVars(s.PHP, s.Version)...)

// get the xdebug vars
envs = append(envs, xdebugVars(s.PHP, s.Xdebug, s.Version, s.Hostname, addr)...)

return envs
return append(envs, xdebugVars(s.PHP, s.Xdebug, s.Version, s.Hostname, addr)...)
}

// SetPHPBoolSetting is used to set php settings that are bool. It will look
Expand Down

0 comments on commit 7459549

Please sign in to comment.