mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
parent
32a990b4f2
commit
bf5816cc00
@ -2,7 +2,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"testing"
|
"testing"
|
||||||
@ -175,20 +175,20 @@ func TestConfigFetchMeasurements(t *testing.T) {
|
|||||||
if req.URL.String() == "https://public-edgeless-constellation.s3.us-east-2.amazonaws.com/projects/constellation-images/global/images/constellation-coreos-1658216163/measurements.yaml" {
|
if req.URL.String() == "https://public-edgeless-constellation.s3.us-east-2.amazonaws.com/projects/constellation-images/global/images/constellation-coreos-1658216163/measurements.yaml" {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusOK,
|
StatusCode: http.StatusOK,
|
||||||
Body: ioutil.NopCloser(bytes.NewBufferString(measurements)),
|
Body: io.NopCloser(bytes.NewBufferString(measurements)),
|
||||||
Header: make(http.Header),
|
Header: make(http.Header),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.URL.String() == "https://public-edgeless-constellation.s3.us-east-2.amazonaws.com/projects/constellation-images/global/images/constellation-coreos-1658216163/measurements.yaml.sig" {
|
if req.URL.String() == "https://public-edgeless-constellation.s3.us-east-2.amazonaws.com/projects/constellation-images/global/images/constellation-coreos-1658216163/measurements.yaml.sig" {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusOK,
|
StatusCode: http.StatusOK,
|
||||||
Body: ioutil.NopCloser(bytes.NewBufferString(signature)),
|
Body: io.NopCloser(bytes.NewBufferString(signature)),
|
||||||
Header: make(http.Header),
|
Header: make(http.Header),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusNotFound,
|
StatusCode: http.StatusNotFound,
|
||||||
Body: ioutil.NopCloser(bytes.NewBufferString("Not found.")),
|
Body: io.NopCloser(bytes.NewBufferString("Not found.")),
|
||||||
Header: make(http.Header),
|
Header: make(http.Header),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//go:generate docgen ./config.go ./config_doc.go Configuration
|
|
||||||
// This binary can be build from siderolabs/talos projects. Located at:
|
// This binary can be build from siderolabs/talos projects. Located at:
|
||||||
// https://github.com/siderolabs/talos/tree/master/hack/docgen
|
// https://github.com/siderolabs/talos/tree/master/hack/docgen
|
||||||
|
//
|
||||||
|
//go:generate docgen ./config.go ./config_doc.go Configuration
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ func getFromURL(ctx context.Context, client *http.Client, sourceURL *url.URL) ([
|
|||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return []byte{}, fmt.Errorf("http status code: %d", resp.StatusCode)
|
return []byte{}, fmt.Errorf("http status code: %d", resp.StatusCode)
|
||||||
}
|
}
|
||||||
content, err := ioutil.ReadAll(resp.Body)
|
content, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []byte{}, err
|
return []byte{}, err
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package config
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
@ -282,20 +282,20 @@ func TestMeasurementsFetchAndVerify(t *testing.T) {
|
|||||||
if req.URL.String() == measurementsURL.String() {
|
if req.URL.String() == measurementsURL.String() {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: tc.measurementsStatus,
|
StatusCode: tc.measurementsStatus,
|
||||||
Body: ioutil.NopCloser(strings.NewReader(tc.measurements)),
|
Body: io.NopCloser(strings.NewReader(tc.measurements)),
|
||||||
Header: make(http.Header),
|
Header: make(http.Header),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.URL.String() == signatureURL.String() {
|
if req.URL.String() == signatureURL.String() {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: tc.signatureStatus,
|
StatusCode: tc.signatureStatus,
|
||||||
Body: ioutil.NopCloser(strings.NewReader(tc.signature)),
|
Body: io.NopCloser(strings.NewReader(tc.signature)),
|
||||||
Header: make(http.Header),
|
Header: make(http.Header),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusNotFound,
|
StatusCode: http.StatusNotFound,
|
||||||
Body: ioutil.NopCloser(strings.NewReader("Not found.")),
|
Body: io.NopCloser(strings.NewReader("Not found.")),
|
||||||
Header: make(http.Header),
|
Header: make(http.Header),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -3,7 +3,7 @@ Package logger provides logging functionality for Constellation services.
|
|||||||
It is a thin wrapper around the zap package, providing a consistent interface for logging.
|
It is a thin wrapper around the zap package, providing a consistent interface for logging.
|
||||||
Use this package to implement logging for your Constellation services.
|
Use this package to implement logging for your Constellation services.
|
||||||
|
|
||||||
Usage
|
# Usage
|
||||||
|
|
||||||
1. Create a logger using New().
|
1. Create a logger using New().
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ This can also be used to add context to a single log message:
|
|||||||
|
|
||||||
logger.With(zap.String("key", "value")).Infof("log message")
|
logger.With(zap.String("key", "value")).Infof("log message")
|
||||||
|
|
||||||
Log Levels
|
# Log Levels
|
||||||
|
|
||||||
Use Debugf() to log low level and detailed information that is useful for debugging.
|
Use Debugf() to log low level and detailed information that is useful for debugging.
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ const (
|
|||||||
|
|
||||||
// packageLock is needed to block concurrent use of package functions, since libcryptsetup is not thread safe.
|
// packageLock is needed to block concurrent use of package functions, since libcryptsetup is not thread safe.
|
||||||
// See: https://gitlab.com/cryptsetup/cryptsetup/-/issues/710
|
// See: https://gitlab.com/cryptsetup/cryptsetup/-/issues/710
|
||||||
|
//
|
||||||
// https://stackoverflow.com/questions/30553386/cryptsetup-backend-safe-with-multithreading
|
// https://stackoverflow.com/questions/30553386/cryptsetup-backend-safe-with-multithreading
|
||||||
var packageLock = sync.Mutex{}
|
var packageLock = sync.Mutex{}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
|
|
||||||
// packageLock is needed to block concurrent use of package functions, since libcryptsetup is not thread safe.
|
// packageLock is needed to block concurrent use of package functions, since libcryptsetup is not thread safe.
|
||||||
// See: https://gitlab.com/cryptsetup/cryptsetup/-/issues/710
|
// See: https://gitlab.com/cryptsetup/cryptsetup/-/issues/710
|
||||||
|
//
|
||||||
// https://stackoverflow.com/questions/30553386/cryptsetup-backend-safe-with-multithreading
|
// https://stackoverflow.com/questions/30553386/cryptsetup-backend-safe-with-multithreading
|
||||||
var packageLock = sync.Mutex{}
|
var packageLock = sync.Mutex{}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user