-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add phpManager type to enforce OS-specific interface
- Loading branch information
1 parent
c44614b
commit f1d100d
Showing
6 changed files
with
77 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package legacy | ||
|
||
type phpManager interface { | ||
// copy writes embedded PHP files to temporary files. | ||
copy() error | ||
|
||
// binPath returns the path to the temporary PHP binary. | ||
binPath() string | ||
|
||
// iniSettings returns PHP INI entries (key=value format). | ||
iniSettings() []string | ||
} | ||
|
||
type phpManagerPerOS struct { | ||
cacheDir string | ||
} | ||
|
||
func newPHPManager(cacheDir string) phpManager { | ||
return &phpManagerPerOS{cacheDir} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package legacy | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestPHPManager(t *testing.T) { | ||
tempDir := t.TempDir() | ||
|
||
pm := newPHPManager(tempDir) | ||
assert.NoError(t, pm.copy()) | ||
|
||
assert.FileExists(t, pm.binPath()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build darwin || linux | ||
|
||
package legacy | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/platformsh/cli/internal/file" | ||
) | ||
|
||
func (m *phpManagerPerOS) copy() error { | ||
return file.WriteIfNeeded(m.binPath(), phpCLI, 0o755) | ||
} | ||
|
||
func (m *phpManagerPerOS) binPath() string { | ||
return filepath.Join(m.cacheDir, "php") | ||
} | ||
|
||
func (m *phpManagerPerOS) iniSettings() []string { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.