Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hash): recreate container on project config content change #11931

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix linters
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
  • Loading branch information
idsulik committed Feb 24, 2025
commit 4b60861e7160db51b91bb2ac8eba41272f493b7e
1 change: 0 additions & 1 deletion cmd/compose/config.go
Original file line number Diff line number Diff line change
@@ -348,7 +348,6 @@ func runHash(ctx context.Context, dockerCli command.Cli, opts configOptions) err
}

hash, err := compose.ServiceHash(s)

if err != nil {
return err
}
10 changes: 4 additions & 6 deletions pkg/compose/hash.go
Original file line number Diff line number Diff line change
@@ -52,7 +52,6 @@ func ServiceConfigsHash(project *types.Project, serviceConfig types.ServiceConfi
for _, config := range serviceConfig.Configs {
file := project.Configs[config.Source]
b, err := createTarForConfig(project, types.FileReferenceConfig(config), types.FileObjectConfig(file))

if err != nil {
return nil, err
}
@@ -69,7 +68,6 @@ func ServiceSecretsHash(project *types.Project, serviceConfig types.ServiceConfi
for _, secret := range serviceConfig.Secrets {
file := project.Secrets[secret.Source]
b, err := createTarForConfig(project, types.FileReferenceConfig(secret), types.FileObjectConfig(file))

if err != nil {
return nil, err
}
@@ -114,21 +112,21 @@ func createTarForConfig(

// NetworkHash computes the configuration hash for a network.
func NetworkHash(o *types.NetworkConfig) (string, error) {
bytes, err := json.Marshal(o)
data, err := json.Marshal(o)
if err != nil {
return "", err
}
return digest.SHA256.FromBytes(bytes).Encoded(), nil
return digest.SHA256.FromBytes(data).Encoded(), nil
}

// VolumeHash computes the configuration hash for a volume.
func VolumeHash(o types.VolumeConfig) (string, error) {
if o.Driver == "" { // (TODO: jhrotko) This probably should be fixed in compose-go
o.Driver = "local"
}
bytes, err := json.Marshal(o)
data, err := json.Marshal(o)
if err != nil {
return "", err
}
return digest.SHA256.FromBytes(bytes).Encoded(), nil
return digest.SHA256.FromBytes(data).Encoded(), nil
}
1 change: 0 additions & 1 deletion pkg/utils/tar.go
Original file line number Diff line number Diff line change
@@ -123,7 +123,6 @@ func CreateTarByPath(path string, modTime time.Time) (*bytes.Buffer, error) {

return nil
})

if err != nil {
return nil, err
}
Loading
Oops, something went wrong.