add HAKO-VERSION checking
This commit is contained in:
parent
33f45eae02
commit
30a510cb17
6 changed files with 68 additions and 33 deletions
43
commands.go
43
commands.go
|
@ -19,6 +19,9 @@ func initCommand(lang string) error {
|
|||
if err := buildBaseImage(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// Check base image version
|
||||
checkVersionMismatch("hako-userland")
|
||||
}
|
||||
|
||||
fmt.Printf("Building %s language image...\n", lang)
|
||||
|
@ -36,6 +39,9 @@ func upCommand(lang string) error {
|
|||
return fmt.Errorf("image %s not found, run 'hako init %s' first", imageName, lang)
|
||||
}
|
||||
|
||||
// Check for version mismatch
|
||||
checkVersionMismatch(imageName)
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -103,7 +109,24 @@ func downCommand(container string) error {
|
|||
|
||||
func psCommand() error {
|
||||
fmt.Println("Hako containers:")
|
||||
return listHakoContainers()
|
||||
if err := listHakoContainers(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Check for version mismatches in running containers
|
||||
output, err := runCommandOutput("docker", "ps", "-a", "--filter", "name=hako-", "--format", "{{.Image}}")
|
||||
if err == nil {
|
||||
images := strings.Split(strings.TrimSpace(output), "\n")
|
||||
checkedImages := make(map[string]bool)
|
||||
for _, image := range images {
|
||||
if image != "" && !checkedImages[image] {
|
||||
checkVersionMismatch(image)
|
||||
checkedImages[image] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func syncCommand() error {
|
||||
|
@ -122,7 +145,7 @@ func syncCommand() error {
|
|||
}
|
||||
|
||||
fmt.Printf("Syncing files from container %s...\n", containerName)
|
||||
|
||||
|
||||
tempDir, err := os.MkdirTemp("", "hako-sync-*")
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -184,12 +207,12 @@ func copyWorkspaceToContainer(containerName string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
untrackedFiles, err := runCommandOutput("git", "ls-files", "--others", "--exclude-standard")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
allFiles := []string{}
|
||||
if trackedFiles != "" {
|
||||
allFiles = append(allFiles, strings.Split(trackedFiles, "\n")...)
|
||||
|
@ -197,17 +220,17 @@ func copyWorkspaceToContainer(containerName string) error {
|
|||
if untrackedFiles != "" {
|
||||
allFiles = append(allFiles, strings.Split(untrackedFiles, "\n")...)
|
||||
}
|
||||
|
||||
|
||||
if len(allFiles) == 0 {
|
||||
return fmt.Errorf("no files to copy")
|
||||
}
|
||||
|
||||
|
||||
// Copy files one by one to preserve directory structure
|
||||
for _, file := range allFiles {
|
||||
if file == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
// Create directory structure in container if needed
|
||||
dir := filepath.Dir(file)
|
||||
if dir != "." {
|
||||
|
@ -215,12 +238,12 @@ func copyWorkspaceToContainer(containerName string) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Copy the file
|
||||
if err := copyToContainer(containerName, file, "/workspace/"+file); err != nil {
|
||||
return fmt.Errorf("failed to copy %s: %v", file, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue