Skip to content

Commit

Permalink
a bit refactored hash.go
Browse files Browse the repository at this point in the history
Signed-off-by: Suleiman Dibirov <[email protected]>
  • Loading branch information
idsulik committed Jul 10, 2024
1 parent f75d940 commit b67627e
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions pkg/compose/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,21 @@ func ServiceHash(project *types.Project, o types.ServiceConfig) (string, error)
}

for _, serviceConfig := range o.Configs {
if projectConfig, ok := project.Configs[serviceConfig.Source]; ok {
if projectConfig.Content != "" {
bytes = append(bytes, []byte(projectConfig.Content)...)
} else if projectConfig.File != "" {
content, err := os.ReadFile(projectConfig.File)
if err != nil {
return "", err
}
bytes = append(bytes, content...)
} else if projectConfig.Environment != "" {
bytes = append(bytes, []byte(projectConfig.Environment)...)
projectConfig, ok := project.Configs[serviceConfig.Source]
if !ok {
continue
}

if projectConfig.Content != "" {
bytes = append(bytes, []byte(projectConfig.Content)...)
} else if projectConfig.File != "" {
content, err := os.ReadFile(projectConfig.File)
if err != nil {
return "", err
}
bytes = append(bytes, content...)
} else if projectConfig.Environment != "" {
bytes = append(bytes, []byte(projectConfig.Environment)...)
}
}

Expand Down

0 comments on commit b67627e

Please sign in to comment.