Skip to content

Commit

Permalink
Merge pull request #2338 from carapace-sh/add-molecule
Browse files Browse the repository at this point in the history
add molecule
  • Loading branch information
rsteube authored Apr 8, 2024
2 parents 9f715de + 22b925a commit c43d622
Show file tree
Hide file tree
Showing 24 changed files with 670 additions and 0 deletions.
30 changes: 30 additions & 0 deletions completers/molecule_completer/cmd/check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/molecule"
"github.com/spf13/cobra"
)

var checkCmd = &cobra.Command{
Use: "check [flags]",
Short: "Use the provisioner to perform a Dry-Run",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(checkCmd)

checkCmd.Flags().Bool("help", false, "Show help message and exit")
checkCmd.Flags().Bool("no-parallel", true, "Disable parallel mode (default)")
checkCmd.Flags().Bool("parallel", false, "Enabe parallel mode")
checkCmd.Flags().StringP("scenario-name", "s", "default", "Name of the scenario to target")

checkCmd.MarkFlagsMutuallyExclusive("parallel", "no-parallel")

carapace.Gen(checkCmd).FlagCompletion(carapace.ActionMap{
"scenario-name": molecule.ActionScenarios(),
})

rootCmd.AddCommand(checkCmd)
}
26 changes: 26 additions & 0 deletions completers/molecule_completer/cmd/cleanup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/molecule"
"github.com/spf13/cobra"
)

var cleanupCmd = &cobra.Command{
Use: "cleanup [flags]",
Short: "Use the provisioner to cleanup any changes made to external systems",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cleanupCmd)

cleanupCmd.Flags().Bool("help", false, "Show help message and exit")
cleanupCmd.Flags().StringP("scenario-name", "s", "default", "Name of the scenario to target")

carapace.Gen(cleanupCmd).FlagCompletion(carapace.ActionMap{
"scenario-name": molecule.ActionScenarios(),
})

rootCmd.AddCommand(cleanupCmd)
}
26 changes: 26 additions & 0 deletions completers/molecule_completer/cmd/converge.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/molecule"
"github.com/spf13/cobra"
)

var convergeCmd = &cobra.Command{
Use: "converge [flags]",
Short: "Use the provisioner to configure instances",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(convergeCmd)

convergeCmd.Flags().Bool("help", false, "Show help message and exit")
convergeCmd.Flags().StringP("scenario-name", "s", "default", "Name of the scenario to target")

carapace.Gen(convergeCmd).FlagCompletion(carapace.ActionMap{
"scenario-name": molecule.ActionScenarios(),
})

rootCmd.AddCommand(convergeCmd)
}
28 changes: 28 additions & 0 deletions completers/molecule_completer/cmd/create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/molecule"
"github.com/spf13/cobra"
)

var createCmd = &cobra.Command{
Use: "create [flags]",
Short: "Use the provisioner to start the instances",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(createCmd)

createCmd.Flags().StringP("driver-name", "d", "delegated", "Name of the driver to use")
createCmd.Flags().Bool("help", false, "Show help message and exit")
createCmd.Flags().StringP("scenario-name", "s", "default", "Name of the scenario to target")

carapace.Gen(createCmd).FlagCompletion(carapace.ActionMap{
"driver-name": molecule.ActionDrivers(),
"scenario-name": molecule.ActionScenarios(),
})

rootCmd.AddCommand(createCmd)
}
26 changes: 26 additions & 0 deletions completers/molecule_completer/cmd/dependency.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/molecule"
"github.com/spf13/cobra"
)

var dependencyCmd = &cobra.Command{
Use: "dependency [flags]",
Short: "Manage the role's dependencies",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(dependencyCmd)

dependencyCmd.Flags().Bool("help", false, "Show help message and exit")
dependencyCmd.Flags().StringP("scenario-name", "s", "default", "Name of the scenario to target")

carapace.Gen(dependencyCmd).FlagCompletion(carapace.ActionMap{
"scenario-name": molecule.ActionScenarios(),
})

rootCmd.AddCommand(dependencyCmd)
}
36 changes: 36 additions & 0 deletions completers/molecule_completer/cmd/destroy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/molecule"
"github.com/spf13/cobra"
)

var destroyCmd = &cobra.Command{
Use: "destroy [flags]",
Short: "Use the provisioner to destroy the instances",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(destroyCmd)

destroyCmd.Flags().Bool("all", false, "Destroy all scenarios")
destroyCmd.Flags().StringP("driver-name", "d", "delegated", "Name of the driver to use")
destroyCmd.Flags().Bool("help", false, "Show help message and exit")
destroyCmd.Flags().Bool("no-all", true, "Don't destroy all scenarios (default)")
destroyCmd.Flags().Bool("no-parallel", true, "Disable parallel mode (default)")
destroyCmd.Flags().Bool("parallel", false, "Enabe parallel mode")
destroyCmd.Flags().StringP("scenario-name", "s", "default", "Name of the scenario to target")

destroyCmd.MarkFlagsMutuallyExclusive("all", "scenario-name")
destroyCmd.MarkFlagsMutuallyExclusive("all", "no-all")
destroyCmd.MarkFlagsMutuallyExclusive("parallel", "no-parallel")

carapace.Gen(destroyCmd).FlagCompletion(carapace.ActionMap{
"driver-name": molecule.ActionDrivers(),
"scenario-name": molecule.ActionScenarios(),
})

rootCmd.AddCommand(destroyCmd)
}
25 changes: 25 additions & 0 deletions completers/molecule_completer/cmd/drivers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var driversCmd = &cobra.Command{
Use: "drivers [flags]",
Short: "List drivers",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(driversCmd)

driversCmd.Flags().StringP("format", "f", "plain", "Change output format")
driversCmd.Flags().Bool("help", false, "Show help message and exit")

carapace.Gen(driversCmd).FlagCompletion(carapace.ActionMap{
"format": carapace.ActionValues("plain", "simple"),
})

rootCmd.AddCommand(driversCmd)
}
26 changes: 26 additions & 0 deletions completers/molecule_completer/cmd/idempotence.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/molecule"
"github.com/spf13/cobra"
)

var idempotenceCmd = &cobra.Command{
Use: "idempotence [flags]",
Short: "Use the provisioner to configure instances and determine idempotence",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(idempotenceCmd)

idempotenceCmd.Flags().Bool("help", false, "Show help message and exit")
idempotenceCmd.Flags().StringP("scenario-name", "s", "default", "Name of the scenario to target")

carapace.Gen(idempotenceCmd).FlagCompletion(carapace.ActionMap{
"scenario-name": molecule.ActionScenarios(),
})

rootCmd.AddCommand(idempotenceCmd)
}
20 changes: 20 additions & 0 deletions completers/molecule_completer/cmd/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var initCmd = &cobra.Command{
Use: "init [flags] COMMAND",
Short: "Use the provisioner to cleanup any changes made to external systems",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(initCmd)

initCmd.Flags().Bool("help", false, "Show help message and exit")

rootCmd.AddCommand(initCmd)
}
31 changes: 31 additions & 0 deletions completers/molecule_completer/cmd/init_role.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/molecule"
"github.com/spf13/cobra"
)

var initRoleCmd = &cobra.Command{
Use: "role [flags] ROLE_NAME",
Short: "Initialize a new role for use with Molecule",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(initRoleCmd)

initRoleCmd.Flags().String("dependency-name", "", "Name of galaxy dependency to initialize")
initRoleCmd.Flags().StringP("driver-name", "d", "delegated", "Name of the driver to use")
initRoleCmd.Flags().Bool("help", false, "Show help message and exit")
initRoleCmd.Flags().String("provisioner-name", "ansible", "Name of provisioner to initialize")
initRoleCmd.Flags().String("verifier-name", "ansible", "Name of verifier to initialize")

carapace.Gen(initRoleCmd).FlagCompletion(carapace.ActionMap{
"driver-name": molecule.ActionDrivers(),
"provisioner-name": carapace.ActionExecutables(),
"verifier-name": carapace.ActionValues("ansible", "testinfra"),
})

initCmd.AddCommand(initRoleCmd)
}
32 changes: 32 additions & 0 deletions completers/molecule_completer/cmd/init_scenario.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/molecule"
"github.com/spf13/cobra"
)

var initScenarioCmd = &cobra.Command{
Use: "scenario [flags] [SCENARIO_NAME]",
Short: "Initializes a new scenario to use with Molecule",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(initScenarioCmd)

initScenarioCmd.Flags().String("dependency-name", "", "Name of galaxy dependency to initialize")
initScenarioCmd.Flags().StringP("driver-name", "d", "delegated", "Name of the driver to use")
initScenarioCmd.Flags().Bool("help", false, "Show help message and exit")
initScenarioCmd.Flags().String("provisioner-name", "ansible", "Name of provisioner to initialize")
initScenarioCmd.Flags().StringP("role-name", "r", "", "Name of the role to create")
initScenarioCmd.Flags().String("verifier-name", "ansible", "Name of verifier to initialize")

carapace.Gen(initScenarioCmd).FlagCompletion(carapace.ActionMap{
"driver-name": molecule.ActionDrivers(),
"provisioner-name": carapace.ActionExecutables(),
"verifier-name": carapace.ActionValues("ansible", "testinfra"),
})

initCmd.AddCommand(initScenarioCmd)
}
28 changes: 28 additions & 0 deletions completers/molecule_completer/cmd/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/molecule"
"github.com/spf13/cobra"
)

var listCmd = &cobra.Command{
Use: "list [flags]",
Short: "List status of instances",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(listCmd)

listCmd.Flags().StringP("format", "f", "simple", "Change output format")
listCmd.Flags().Bool("help", false, "Show help message and exit")
listCmd.Flags().StringP("scenario-name", "s", "default", "Name of the scenario to target")

carapace.Gen(listCmd).FlagCompletion(carapace.ActionMap{
"format": carapace.ActionValues("plain", "simple", "yaml"),
"scenario-name": molecule.ActionScenarios(),
})

rootCmd.AddCommand(listCmd)
}
28 changes: 28 additions & 0 deletions completers/molecule_completer/cmd/login.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/molecule"
"github.com/spf13/cobra"
)

var loginCmd = &cobra.Command{
Use: "login [flags]",
Short: "Login to one instance",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(loginCmd)

loginCmd.Flags().Bool("help", false, "Show help message and exit")
loginCmd.Flags().StringP("host", "h", "", "Host to access")
loginCmd.Flags().StringP("scenario-name", "s", "default", "Name of the scenario to target")

carapace.Gen(loginCmd).FlagCompletion(carapace.ActionMap{
// "host": action.ActionInstances(loginCmd), // TODO
"scenario-name": molecule.ActionScenarios(),
})

rootCmd.AddCommand(loginCmd)
}
Loading

0 comments on commit c43d622

Please sign in to comment.