This repository has been archived by the owner on Mar 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update filesystem dependency injection (#233)
Updates `fs` package to have `Asset`/`DotShip` `BasePath` instances
- Loading branch information
Showing
13 changed files
with
82 additions
and
35 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
package constants | ||
|
||
// InstallerPrefixPath is the path prefix of installed assets | ||
const InstallerPrefixPath = "installer" | ||
|
||
// ShipPath is the default folder path of Ship configuration | ||
const ShipPath = ".ship" | ||
|
||
// OverlaysPrefixPath is the path prefix of overlays | ||
const OverlaysPrefixPath = "overlays/ship" | ||
|
||
// StatePath is the default state file path | ||
const StatePath = ".ship/state.json" | ||
|
||
// KustomizeHelmPath is the path used to store helm chart contents | ||
const KustomizeHelmPath = ".ship/kustomize/chart" | ||
|
||
// TempHelmValuesPath is the folder path used to store the updated values.yaml | ||
const TempHelmValuesPath = ".ship/kustomize/tmp" |
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,5 @@ | ||
package constants | ||
|
||
// ShouldUseUpdate is the message printed to the user when they attempt | ||
// to use "ship init" with a present state file on disk | ||
const ShouldUseUpdate = `To build on your progress, run "ship update"` |
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 |
---|---|---|
@@ -1,10 +1,50 @@ | ||
package fs | ||
|
||
import ( | ||
"github.com/replicatedhq/ship/pkg/constants" | ||
"github.com/spf13/afero" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func FromViper(v *viper.Viper) afero.Afero { | ||
// NewBaseFilesystem creates a new Afero OS filesystem | ||
func NewBaseFilesystem() afero.Afero { | ||
return afero.Afero{Fs: afero.NewOsFs()} | ||
} | ||
|
||
// FilesystemParams is a struct that contains Filesystem configuration | ||
type FilesystemParams struct { | ||
AssetsPath string | ||
DotShipPath string | ||
} | ||
|
||
// NewFilesystemParams creates a new FilesystemParams config object | ||
func NewFilesystemParams(v *viper.Viper) FilesystemParams { | ||
assetsPath := "" | ||
if v.GetBool("is-app") { | ||
assetsPath = constants.InstallerPrefixPath | ||
} | ||
|
||
return FilesystemParams{ | ||
AssetsPath: assetsPath, | ||
DotShipPath: constants.ShipPath, | ||
} | ||
} | ||
|
||
// Filesystems is a struct that returns multiple filesystems for use | ||
// in ship execution | ||
type Filesystems struct { | ||
DotShip afero.Afero | ||
Assets afero.Afero | ||
} | ||
|
||
// NewFilesystems creates a new Filesystems struct for use in ship execution | ||
func NewFilesystems(fsp FilesystemParams, baseFilesystem afero.Afero) Filesystems { | ||
return Filesystems{ | ||
DotShip: afero.Afero{ | ||
Fs: afero.NewBasePathFs(baseFilesystem.Fs, fsp.DotShipPath), | ||
}, | ||
Assets: afero.Afero{ | ||
Fs: afero.NewBasePathFs(baseFilesystem.Fs, fsp.AssetsPath), | ||
}, | ||
} | ||
} |
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
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
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
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
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