mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
installer: make hash checking optional
This commit is contained in:
parent
dac4bb04f2
commit
138057a2ee
@ -70,7 +70,7 @@ func (i *OsInstaller) Install(ctx context.Context, kubernetesComponent *componen
|
||||
return fmt.Errorf("reading file %q: %w", tempPath, err)
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,15 @@ func TestInstall(t *testing.T) {
|
||||
},
|
||||
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": {
|
||||
server: newHTTPBufconnServer(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(500) }),
|
||||
component: &components.Component{
|
||||
|
Loading…
Reference in New Issue
Block a user