Skip to content

Commit

Permalink
Fix host volumes with source ./ and add sync host volumes across cont…
Browse files Browse the repository at this point in the history
…ainers
  • Loading branch information
Evgeny committed Oct 21, 2022
1 parent d1ea7e0 commit 7a5cb0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion internal/pkg/resource_name_utils/resource_name_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resource_name_utils
import (
"fmt"
"regexp"
"strings"
)

type ResouceNameUtils struct{}
Expand Down Expand Up @@ -43,8 +44,12 @@ func (resouceNameUtils *ResouceNameUtils) VolumeName(name string) string {
return fmt.Sprintf("volume-%v", rfcName)
}

// A lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.',
// and must start and end with an alphanumeric character (e.g. 'example.com',
// regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')
func toRfc(str string) string {
regexp := regexp.MustCompile(`(\/|~|\.|_)`)
replacedStr := regexp.ReplaceAllString(str, "-")

return regexp.ReplaceAllString(str, "-")
return strings.Trim(replacedStr, "-")
}
2 changes: 1 addition & 1 deletion internal/types/domain/container_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (volume ContainerVolume) BuildUniqName(container *Container) string {
case ContainerVolumeTypeNamed:
return volume.Source
case ContainerVolumeTypeHost:
return fmt.Sprintf("host-%s-%s", container.ServiceName, volume.Source)
return fmt.Sprintf("host-%s", volume.Source)
default:
return ""
}
Expand Down

0 comments on commit 7a5cb0b

Please sign in to comment.