mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-06-08 06:32:55 -04:00
installer: make hash checking optional
This commit is contained in:
parent
dac4bb04f2
commit
138057a2ee
2 changed files with 10 additions and 1 deletions
|
@ -70,7 +70,7 @@ func (i *OsInstaller) Install(ctx context.Context, kubernetesComponent *componen
|
||||||
return fmt.Errorf("reading file %q: %w", tempPath, err)
|
return fmt.Errorf("reading file %q: %w", tempPath, err)
|
||||||
}
|
}
|
||||||
calculatedHash := fmt.Sprintf("sha256:%x", sha.Sum(nil))
|
calculatedHash := fmt.Sprintf("sha256:%x", sha.Sum(nil))
|
||||||
if calculatedHash != kubernetesComponent.Hash {
|
if len(kubernetesComponent.Hash) > 0 && calculatedHash != kubernetesComponent.Hash {
|
||||||
return fmt.Errorf("hash of file %q %s does not match expected hash %s", tempPath, calculatedHash, kubernetesComponent.Hash)
|
return fmt.Errorf("hash of file %q %s does not match expected hash %s", tempPath, calculatedHash, kubernetesComponent.Hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,15 @@ func TestInstall(t *testing.T) {
|
||||||
},
|
},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
|
"hash is not mandatory": {
|
||||||
|
server: newHTTPBufconnServerWithBody([]byte("file-contents")),
|
||||||
|
component: components.Component{
|
||||||
|
URL: serverURL,
|
||||||
|
Hash: "",
|
||||||
|
InstallPath: "/destination",
|
||||||
|
},
|
||||||
|
wantFiles: map[string][]byte{"/destination": []byte("file-contents")},
|
||||||
|
},
|
||||||
"download fails": {
|
"download fails": {
|
||||||
server: newHTTPBufconnServer(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(500) }),
|
server: newHTTPBufconnServer(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(500) }),
|
||||||
component: &components.Component{
|
component: &components.Component{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue