Skip to content

Commit

Permalink
Renaming packages
Browse files Browse the repository at this point in the history
Signed-off-by: ytimocin <ytimocin@microsoft.com>
  • Loading branch information
ytimocin committed Jan 18, 2025
1 parent 205d949 commit 196517a
Show file tree
Hide file tree
Showing 55 changed files with 290 additions and 251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ func NewRootCommand() *cobra.Command {
Long: `
Cloud Connection:
- Available Cloud connection types: Azure and AWS.
- Available Cloud connection types: Azure.
- Commands: create, delete, open, list, types.
- Examples:
* 'pops connection cloud create' creates a connection to a cloud provider.
* 'pops connection cloud open' opens an existing cloud connection.
* 'pops connection cloud list' lists all cloud connections.
* 'pops connection cloud delete' deletes a cloud connection.
* 'pops connection cloud types' lists all available cloud connection types (for now; Azure and AWS).
* 'pops connection cloud types' lists all available cloud connection types (for now; Azure).
More connection types and features are coming soon!`,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"strings"

"github.com/prompt-ops/pops/pkg/config"
"github.com/prompt-ops/pops/pkg/connection"
"github.com/prompt-ops/pops/pkg/conn"
"github.com/prompt-ops/pops/pkg/ui"
"github.com/prompt-ops/pops/pkg/ui/cloud"
"github.com/prompt-ops/pops/pkg/ui/conn/cloud"

tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -57,7 +57,7 @@ func newCreateCmd() *cobra.Command {
Long: `
Cloud Connection:
- Available Cloud connection types: Azure, AWS, and GCP.
- Available Cloud connection types: Azure.
- Commands: create, delete, open, list, types.
- Examples:
* 'pops connection cloud create' creates a connection interactively.
Expand All @@ -73,8 +73,8 @@ Cloud Connection:
}

transitionMsg := ui.TransitionToShellMsg{
Connection: connection.NewCloudConnection(name,
connection.AvailableCloudConnectionType{
Connection: conn.NewCloudConnection(name,
conn.AvailableCloudConnectionType{
Subtype: strings.Title(provider),
},
),
Expand Down Expand Up @@ -114,8 +114,8 @@ func createCloudConnection(name, provider string) error {
return fmt.Errorf("connection name cannot be empty")
}

var selectedProvider connection.AvailableCloudConnectionType
for _, p := range connection.AvailableCloudConnectionTypes {
var selectedProvider conn.AvailableCloudConnectionType
for _, p := range conn.AvailableCloudConnectionTypes {
if strings.ToLower(p.Subtype) == provider {
selectedProvider = p
break
Expand All @@ -129,7 +129,7 @@ func createCloudConnection(name, provider string) error {
return fmt.Errorf("connection name '%s' already exists", name)
}

connection := connection.NewCloudConnection(name, selectedProvider)
connection := conn.NewCloudConnection(name, selectedProvider)
if err := config.SaveConnection(connection); err != nil {
return fmt.Errorf("failed to save connection: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/prompt-ops/pops/pkg/config"
"github.com/prompt-ops/pops/pkg/connection"
"github.com/prompt-ops/pops/pkg/conn"
"github.com/prompt-ops/pops/pkg/ui"

"github.com/charmbracelet/bubbles/table"
Expand Down Expand Up @@ -98,7 +98,7 @@ Examples:

// deleteAllCloudConnections deletes all cloud connections
func deleteAllCloudConnections() error {
if err := config.DeleteAllConnectionsByType(connection.ConnectionTypeCloud); err != nil {
if err := config.DeleteAllConnectionsByType(conn.ConnectionTypeCloud); err != nil {
return fmt.Errorf("error deleting all cloud connections: %w", err)
}
color.Green("All cloud connections have been successfully deleted.")
Expand All @@ -123,7 +123,7 @@ func deleteCloudConnection(name string) error {

// runInteractiveDelete runs the Bubble Tea program for interactive deletion
func runInteractiveDelete() (string, error) {
connections, err := config.GetConnectionsByType(connection.ConnectionTypeCloud)
connections, err := config.GetConnectionsByType(conn.ConnectionTypeCloud)
if err != nil {
return "", fmt.Errorf("getting connections: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"

"github.com/prompt-ops/pops/pkg/config"
"github.com/prompt-ops/pops/pkg/connection"
"github.com/prompt-ops/pops/pkg/conn"
"github.com/prompt-ops/pops/pkg/ui"

"github.com/charmbracelet/bubbles/table"
Expand Down Expand Up @@ -33,7 +33,7 @@ func newListCmd() *cobra.Command {

// runListConnections lists all connections
func runListConnections() error {
connections, err := config.GetConnectionsByType(connection.ConnectionTypeCloud)
connections, err := config.GetConnectionsByType(conn.ConnectionTypeCloud)
if err != nil {
return fmt.Errorf("getting cloud connections: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"

"github.com/prompt-ops/pops/pkg/config"
"github.com/prompt-ops/pops/pkg/connection"
"github.com/prompt-ops/pops/pkg/conn"
"github.com/prompt-ops/pops/pkg/ui"
"github.com/prompt-ops/pops/pkg/ui/cloud"
"github.com/prompt-ops/pops/pkg/ui/conn/cloud"

tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -51,7 +51,7 @@ func newOpenCmd() *cobra.Command {

cmd := &cobra.Command{
Use: "open [connection-name]",
Short: "Open an existing cloud connection.",
Short: "Open an existing cloud conn.",
Long: `Open a cloud connection to access its shell.
You can specify the connection name either as a positional argument or using the --name flag.
Expand Down Expand Up @@ -116,10 +116,10 @@ Examples:

// getConnectionByName retrieves a cloud connection by its name.
// Returns an error if the connection does not exist.
func getConnectionByName(name string) (connection.Connection, error) {
cloudConnections, err := config.GetConnectionsByType(connection.ConnectionTypeCloud)
func getConnectionByName(name string) (conn.Connection, error) {
cloudConnections, err := config.GetConnectionsByType(conn.ConnectionTypeCloud)
if err != nil {
return connection.Connection{}, fmt.Errorf("failed to retrieve connections: %w", err)
return conn.Connection{}, fmt.Errorf("failed to retrieve connections: %w", err)
}

for _, conn := range cloudConnections {
Expand All @@ -128,5 +128,5 @@ func getConnectionByName(name string) (connection.Connection, error) {
}
}

return connection.Connection{}, fmt.Errorf("connection '%s' does not exist", name)
return conn.Connection{}, fmt.Errorf("connection '%s' does not exist", name)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cloud
import (
"os"

"github.com/prompt-ops/pops/pkg/connection"
"github.com/prompt-ops/pops/pkg/conn"
"github.com/prompt-ops/pops/pkg/ui"

"github.com/charmbracelet/bubbles/table"
Expand Down Expand Up @@ -31,7 +31,7 @@ func newTypesCmd() *cobra.Command {

// runListAvaibleCloudTypes lists all available cloud connection types
func runListAvaibleCloudTypes() error {
cloudConnectionTypes := connection.AvailableCloudConnectionTypes
cloudConnectionTypes := conn.AvailableCloudConnectionTypes

items := make([]table.Row, len(cloudConnectionTypes))
for i, cloudConnectionType := range cloudConnectionTypes {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package connection
package conn

import (
"github.com/prompt-ops/pops/cmd/pops/app/connection/cloud"
"github.com/prompt-ops/pops/cmd/pops/app/connection/db"
"github.com/prompt-ops/pops/cmd/pops/app/connection/kubernetes"
"github.com/prompt-ops/pops/cmd/pops/app/conn/cloud"
"github.com/prompt-ops/pops/cmd/pops/app/conn/db"
"github.com/prompt-ops/pops/cmd/pops/app/conn/k8s"

"github.com/spf13/cobra"
)
Expand All @@ -18,7 +18,7 @@ func NewConnectionCommand() *cobra.Command {
Prompt-Ops manages your infrastructure using natural language.
**Cloud Connection:**
- **Types**: Azure, AWS
- **Types**: Azure, AWS, and GCP (coming soon)
- **Commands**: create, delete, open, list, types
- **Example**: 'pops connection cloud create' creates a connection to a cloud provider.
Expand All @@ -44,7 +44,7 @@ More connection types and features are coming soon!`,

// Add subcommands
cmd.AddCommand(cloud.NewRootCommand())
cmd.AddCommand(kubernetes.NewRootCommand())
cmd.AddCommand(k8s.NewRootCommand())
cmd.AddCommand(db.NewRootCommand())

// Add additional commands
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package connection
package conn

import (
"github.com/prompt-ops/pops/cmd/pops/app/connection/factory"
"github.com/prompt-ops/pops/pkg/connection"
"github.com/prompt-ops/pops/cmd/pops/app/conn/factory"
"github.com/prompt-ops/pops/pkg/conn"
"github.com/prompt-ops/pops/pkg/ui"

"github.com/charmbracelet/bubbles/table"
Expand Down Expand Up @@ -49,7 +49,7 @@ type createModel struct {
}

func initialCreateModel() *createModel {
connectionTypes := connection.AvailableConnectionTypes()
connectionTypes := conn.AvailableConnectionTypes()

items := make([]table.Row, len(connectionTypes))
for i, connectionType := range connectionTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package db

import (
"github.com/prompt-ops/pops/pkg/ui"
"github.com/prompt-ops/pops/pkg/ui/db"
"github.com/prompt-ops/pops/pkg/ui/conn/db"

tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

config "github.com/prompt-ops/pops/pkg/config"
"github.com/prompt-ops/pops/pkg/connection"
"github.com/prompt-ops/pops/pkg/conn"
"github.com/prompt-ops/pops/pkg/ui"

"github.com/charmbracelet/bubbles/table"
Expand Down Expand Up @@ -70,7 +70,7 @@ func newDeleteCmd() *cobra.Command {

// deleteAllDatabaseConnections deletes all database connections
func deleteAllDatabaseConnections() error {
if err := config.DeleteAllConnectionsByType(connection.ConnectionTypeDatabase); err != nil {
if err := config.DeleteAllConnectionsByType(conn.ConnectionTypeDatabase); err != nil {
return fmt.Errorf("error deleting all database connections: %w", err)
}
return nil
Expand All @@ -86,7 +86,7 @@ func deleteDatabaseConnection(name string) error {

// runInteractiveDelete runs the Bubble Tea program for interactive deletion
func runInteractiveDelete() (string, error) {
connections, err := config.GetConnectionsByType(connection.ConnectionTypeDatabase)
connections, err := config.GetConnectionsByType(conn.ConnectionTypeDatabase)
if err != nil {
return "", fmt.Errorf("getting connections: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"

config "github.com/prompt-ops/pops/pkg/config"
"github.com/prompt-ops/pops/pkg/connection"
"github.com/prompt-ops/pops/pkg/conn"
"github.com/prompt-ops/pops/pkg/ui"

"github.com/charmbracelet/bubbles/table"
Expand Down Expand Up @@ -33,7 +33,7 @@ func newListCmd() *cobra.Command {

// runListConnections lists all connections
func runListConnections() error {
connections, err := config.GetConnectionsByType(connection.ConnectionTypeDatabase)
connections, err := config.GetConnectionsByType(conn.ConnectionTypeDatabase)
if err != nil {
return fmt.Errorf("getting database connections: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package db

import (
ui "github.com/prompt-ops/pops/pkg/ui"
dbui "github.com/prompt-ops/pops/pkg/ui/db"
dbui "github.com/prompt-ops/pops/pkg/ui/conn/db"

tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package db
import (
"os"

"github.com/prompt-ops/pops/pkg/connection"
"github.com/prompt-ops/pops/pkg/conn"
"github.com/prompt-ops/pops/pkg/ui"

"github.com/charmbracelet/bubbles/table"
Expand Down Expand Up @@ -31,7 +31,7 @@ func newTypesCmd() *cobra.Command {

// runListAvaibledatabaseTypes lists all available database connection types
func runListAvaibleDatabaseTypes() error {
databaseConnections := connection.AvailableDatabaseConnectionTypes
databaseConnections := conn.AvailableDatabaseConnectionTypes

items := make([]table.Row, len(databaseConnections))
for i, connectionType := range databaseConnections {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package connection
package conn

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"
"strings"

"github.com/prompt-ops/pops/cmd/pops/app/connection/cloud"
"github.com/prompt-ops/pops/cmd/pops/app/connection/db"
"github.com/prompt-ops/pops/cmd/pops/app/connection/kubernetes"
"github.com/prompt-ops/pops/cmd/pops/app/conn/cloud"
"github.com/prompt-ops/pops/cmd/pops/app/conn/db"
"github.com/prompt-ops/pops/cmd/pops/app/conn/k8s"

tea "github.com/charmbracelet/bubbletea"
)
Expand All @@ -17,7 +17,7 @@ func GetCreateModel(connectionType string) (tea.Model, error) {
case "cloud":
return cloud.NewCreateModel(), nil
case "kubernetes":
return kubernetes.NewCreateModel(), nil
return k8s.NewCreateModel(), nil
case "database":
return db.NewCreateModel(), nil
default:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import (
"fmt"
"strings"

"github.com/prompt-ops/pops/cmd/pops/app/connection/cloud"
"github.com/prompt-ops/pops/cmd/pops/app/connection/db"
"github.com/prompt-ops/pops/cmd/pops/app/connection/kubernetes"
"github.com/prompt-ops/pops/pkg/connection"
"github.com/prompt-ops/pops/cmd/pops/app/conn/cloud"
"github.com/prompt-ops/pops/cmd/pops/app/conn/db"
"github.com/prompt-ops/pops/cmd/pops/app/conn/k8s"
"github.com/prompt-ops/pops/pkg/conn"

tea "github.com/charmbracelet/bubbletea"
)

// GetOpenModel returns a new openModel based on the connection type
func GetOpenModel(connection connection.Connection) (tea.Model, error) {
func GetOpenModel(connection conn.Connection) (tea.Model, error) {
switch strings.ToLower(connection.Type.GetMainType()) {
case "cloud":
return cloud.NewOpenModel(), nil
case "kubernetes":
return kubernetes.NewOpenModel(), nil
return k8s.NewOpenModel(), nil
case "database":
return db.NewOpenModel(), nil
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kubernetes
package k8s

import (
"github.com/prompt-ops/pops/pkg/ui"
k8sui "github.com/prompt-ops/pops/pkg/ui/kubernetes"
k8sui "github.com/prompt-ops/pops/pkg/ui/conn/k8s"

tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"
Expand Down
Loading

0 comments on commit 196517a

Please sign in to comment.