package models

// AppImportRequest represents a request to import an app from docker-compose
type AppImportRequest struct {
	AppName     string `json:"app_name,omitempty"`            // Optional app name, can be auto-generated
	SourceURL   string `json:"source_url" binding:"required"` // Git repository URL
	Branch      string `json:"branch" binding:"required"`     // Git branch, defaults to "main"
	ComposePath string `json:"compose_path,omitempty"`        // Path to docker-compose.yml, defaults to "docker-compose.yml"
}

// ComposeService represents a service found in a docker-compose.yml file
type ComposeService struct {
	Name         string            `json:"name"`                    // Service name from compose file
	Source       string            `json:"source"`                  // "build" or "image"
	BuildContext string            `json:"build_context,omitempty"` // For build services, the context path
	Dockerfile   string            `json:"dockerfile,omitempty"`    // For build services, the dockerfile path
	Image        string            `json:"image,omitempty"`         // For image services, the image name
	Ports        []string          `json:"ports,omitempty"`         // Port mappings
	Environment  map[string]string `json:"environment,omitempty"`   // Environment variables
	Volumes      []string          `json:"volumes,omitempty"`       // Volume mappings
}

// AppImportReview represents the review response for an app import
type AppImportReview struct {
	AppName  string           `json:"app_name"`        // Suggested or provided app name
	Services []ComposeService `json:"services"`        // List of services found in compose file
	Valid    bool             `json:"valid"`           // Whether the compose file is valid
	Error    string           `json:"error,omitempty"` // Error message if invalid
}

// AppImportCreateRequest represents the final request to create an app from compose
type AppImportCreateRequest struct {
	AppImportRequest
	ConfirmedAppName string `json:"confirmed_app_name" binding:"required"` // User-confirmed app name
}
