feat: define recipe version inside app env file
This commit is contained in:
parent
790dbca362
commit
4085eb6654
@ -50,6 +50,10 @@ And if you want to copy that file back to your current working directory locally
|
|||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
app := internal.ValidateApp(c)
|
app := internal.ValidateApp(c)
|
||||||
|
|
||||||
|
if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
src := c.Args().Get(1)
|
src := c.Args().Get(1)
|
||||||
dst := c.Args().Get(2)
|
dst := c.Args().Get(2)
|
||||||
if src == "" {
|
if src == "" {
|
||||||
|
@ -52,6 +52,9 @@ EXAMPLE:
|
|||||||
stackName := app.StackName()
|
stackName := app.StackName()
|
||||||
|
|
||||||
specificVersion := c.Args().Get(1)
|
specificVersion := c.Args().Get(1)
|
||||||
|
if specificVersion == "" {
|
||||||
|
specificVersion = app.Recipe.Version
|
||||||
|
}
|
||||||
if specificVersion != "" && internal.Chaos {
|
if specificVersion != "" && internal.Chaos {
|
||||||
log.Fatal("cannot use <version> and --chaos together")
|
log.Fatal("cannot use <version> and --chaos together")
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,9 @@ EXAMPLE:
|
|||||||
BashComplete: autocomplete.AppNameComplete,
|
BashComplete: autocomplete.AppNameComplete,
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
app := internal.ValidateApp(c)
|
app := internal.ValidateApp(c)
|
||||||
|
if err := app.Recipe.Ensure(false, false); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
serviceName := c.Args().Get(1)
|
serviceName := c.Args().Get(1)
|
||||||
if serviceName == "" && !internal.AllServices {
|
if serviceName == "" && !internal.AllServices {
|
||||||
|
@ -31,7 +31,6 @@ var appRestoreCommand = cli.Command{
|
|||||||
BashComplete: autocomplete.AppNameComplete,
|
BashComplete: autocomplete.AppNameComplete,
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
app := internal.ValidateApp(c)
|
app := internal.ValidateApp(c)
|
||||||
|
|
||||||
if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
|
if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,9 @@ EXAMPLE:
|
|||||||
}
|
}
|
||||||
|
|
||||||
specificVersion := c.Args().Get(1)
|
specificVersion := c.Args().Get(1)
|
||||||
|
if specificVersion == "" {
|
||||||
|
specificVersion = app.Recipe.Version
|
||||||
|
}
|
||||||
if specificVersion != "" {
|
if specificVersion != "" {
|
||||||
parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version)
|
parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -55,7 +55,6 @@ var appSecretGenerateCommand = cli.Command{
|
|||||||
BashComplete: autocomplete.AppNameComplete,
|
BashComplete: autocomplete.AppNameComplete,
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
app := internal.ValidateApp(c)
|
app := internal.ValidateApp(c)
|
||||||
|
|
||||||
if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
|
if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -246,27 +245,10 @@ Example:
|
|||||||
`,
|
`,
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
app := internal.ValidateApp(c)
|
app := internal.ValidateApp(c)
|
||||||
|
if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
|
||||||
if err := app.Recipe.EnsureExists(); err != nil {
|
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !internal.Chaos {
|
|
||||||
if err := app.Recipe.EnsureIsClean(); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !internal.Offline {
|
|
||||||
if err := app.Recipe.EnsureUpToDate(); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := app.Recipe.EnsureLatest(); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
|
composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -354,27 +336,10 @@ var appSecretLsCommand = cli.Command{
|
|||||||
BashComplete: autocomplete.AppNameComplete,
|
BashComplete: autocomplete.AppNameComplete,
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
app := internal.ValidateApp(c)
|
app := internal.ValidateApp(c)
|
||||||
|
if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
|
||||||
if err := app.Recipe.EnsureExists(); err != nil {
|
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !internal.Chaos {
|
|
||||||
if err := app.Recipe.EnsureIsClean(); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !internal.Offline {
|
|
||||||
if err := app.Recipe.EnsureUpToDate(); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := app.Recipe.EnsureLatest(); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cl, err := client.New(app.Server)
|
cl, err := client.New(app.Server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -28,6 +28,9 @@ var appServicesCommand = cli.Command{
|
|||||||
BashComplete: autocomplete.AppNameComplete,
|
BashComplete: autocomplete.AppNameComplete,
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
app := internal.ValidateApp(c)
|
app := internal.ValidateApp(c)
|
||||||
|
if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
cl, err := client.New(app.Server)
|
cl, err := client.New(app.Server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -81,6 +81,9 @@ any previously attached volumes as eligible for pruning once undeployed.
|
|||||||
Passing "-p/--prune" does not remove those volumes.`,
|
Passing "-p/--prune" does not remove those volumes.`,
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
app := internal.ValidateApp(c)
|
app := internal.ValidateApp(c)
|
||||||
|
if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
stackName := app.StackName()
|
stackName := app.StackName()
|
||||||
|
|
||||||
cl, err := client.New(app.Server)
|
cl, err := client.New(app.Server)
|
||||||
|
@ -21,15 +21,23 @@ func (r Recipe) Ensure(chaos bool, offline bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !chaos {
|
if chaos {
|
||||||
if err := r.EnsureIsClean(); err != nil {
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := r.EnsureIsClean(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !offline {
|
||||||
|
if err := r.EnsureUpToDate(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if r.Version != "" {
|
||||||
|
if _, err := r.EnsureVersion(r.Version); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !offline {
|
} else {
|
||||||
if err := r.EnsureUpToDate(); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := r.EnsureLatest(); err != nil {
|
if err := r.EnsureLatest(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,13 @@ type Features struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Get(name string) Recipe {
|
func Get(name string) Recipe {
|
||||||
|
version := ""
|
||||||
|
if strings.Contains(name, ":") {
|
||||||
|
split := strings.Split(name, ":")
|
||||||
|
name = split[0]
|
||||||
|
version = split[1]
|
||||||
|
}
|
||||||
|
|
||||||
gitURL := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, name)
|
gitURL := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, name)
|
||||||
sshURL := fmt.Sprintf(config.SSH_URL_TEMPLATE, name)
|
sshURL := fmt.Sprintf(config.SSH_URL_TEMPLATE, name)
|
||||||
if strings.Contains(name, "/") {
|
if strings.Contains(name, "/") {
|
||||||
@ -142,10 +149,11 @@ func Get(name string) Recipe {
|
|||||||
dir := path.Join(config.RECIPES_DIR, escapeRecipeName(name))
|
dir := path.Join(config.RECIPES_DIR, escapeRecipeName(name))
|
||||||
|
|
||||||
return Recipe{
|
return Recipe{
|
||||||
Name: name,
|
Name: name,
|
||||||
Dir: dir,
|
Version: version,
|
||||||
GitURL: gitURL,
|
Dir: dir,
|
||||||
SSHURL: sshURL,
|
GitURL: gitURL,
|
||||||
|
SSHURL: sshURL,
|
||||||
|
|
||||||
ComposePath: path.Join(dir, "compose.yml"),
|
ComposePath: path.Join(dir, "compose.yml"),
|
||||||
ReadmePath: path.Join(dir, "README.md"),
|
ReadmePath: path.Join(dir, "README.md"),
|
||||||
@ -155,10 +163,11 @@ func Get(name string) Recipe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Recipe struct {
|
type Recipe struct {
|
||||||
Name string
|
Name string
|
||||||
Dir string
|
Version string
|
||||||
GitURL string
|
Dir string
|
||||||
SSHURL string
|
GitURL string
|
||||||
|
SSHURL string
|
||||||
|
|
||||||
ComposePath string
|
ComposePath string
|
||||||
ReadmePath string
|
ReadmePath string
|
||||||
|
@ -29,6 +29,20 @@ func TestGet(t *testing.T) {
|
|||||||
AbraShPath: path.Join(cfg.GetAbraDir(), "recipes/foo/abra.sh"),
|
AbraShPath: path.Join(cfg.GetAbraDir(), "recipes/foo/abra.sh"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "foo:1.2.3",
|
||||||
|
recipe: Recipe{
|
||||||
|
Name: "foo",
|
||||||
|
Version: "1.2.3",
|
||||||
|
Dir: path.Join(cfg.GetAbraDir(), "/recipes/foo"),
|
||||||
|
GitURL: "https://git.coopcloud.tech/coop-cloud/foo.git",
|
||||||
|
SSHURL: "ssh://git@git.coopcloud.tech:2222/coop-cloud/foo.git",
|
||||||
|
ComposePath: path.Join(cfg.GetAbraDir(), "recipes/foo/compose.yml"),
|
||||||
|
ReadmePath: path.Join(cfg.GetAbraDir(), "recipes/foo/README.md"),
|
||||||
|
SampleEnvPath: path.Join(cfg.GetAbraDir(), "recipes/foo/.env.sample"),
|
||||||
|
AbraShPath: path.Join(cfg.GetAbraDir(), "recipes/foo/abra.sh"),
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "mygit.org/myorg/cool-recipe",
|
name: "mygit.org/myorg/cool-recipe",
|
||||||
recipe: Recipe{
|
recipe: Recipe{
|
||||||
@ -42,6 +56,20 @@ func TestGet(t *testing.T) {
|
|||||||
AbraShPath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/abra.sh"),
|
AbraShPath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/abra.sh"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "mygit.org/myorg/cool-recipe:1.2.4",
|
||||||
|
recipe: Recipe{
|
||||||
|
Name: "mygit.org/myorg/cool-recipe",
|
||||||
|
Version: "1.2.4",
|
||||||
|
Dir: path.Join(cfg.GetAbraDir(), "/recipes/mygit_org_myorg_cool-recipe"),
|
||||||
|
GitURL: "https://mygit.org/myorg/cool-recipe.git",
|
||||||
|
SSHURL: "ssh://git@mygit.org/myorg/cool-recipe.git",
|
||||||
|
ComposePath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/compose.yml"),
|
||||||
|
ReadmePath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/README.md"),
|
||||||
|
SampleEnvPath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/.env.sample"),
|
||||||
|
AbraShPath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/abra.sh"),
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testcases {
|
for _, tc := range testcases {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user