Issue-ID: NONRTRIC-702
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
Change-Id: Iee9ac0cf831e216639f77d0a08aa0b7d54091aa5
-FROM gcr.io/distroless/base-debian10
+FROM gcr.io/distroless/base-debian11
WORKDIR /
## Copy from "build" stage
COPY --from=build /dmaapmediatorproducer .
WORKDIR /
## Copy from "build" stage
COPY --from=build /dmaapmediatorproducer .
func (r RegistratorImpl) RegisterTypes(jobTypes []TypeDefinition) error {
for _, jobType := range jobTypes {
func (r RegistratorImpl) RegisterTypes(jobTypes []TypeDefinition) error {
for _, jobType := range jobTypes {
- body := fmt.Sprintf(`{"info_job_data_schema": %v}`, jobType.TypeSchema)
+ s, _ := json.Marshal(jobType.TypeSchema)
+ body := fmt.Sprintf(`{"info_job_data_schema": %v}`, string(s))
if error := restclient.Put(r.infoCoordinatorAddress+registerTypePath+url.PathEscape(jobType.Identity), []byte(body), r.httpClient); error != nil {
return error
}
if error := restclient.Put(r.infoCoordinatorAddress+registerTypePath+url.PathEscape(jobType.Identity), []byte(body), r.httpClient); error != nil {
return error
}
"io/ioutil"
"net/http"
"testing"
"io/ioutil"
"net/http"
"testing"
StatusCode: http.StatusCreated,
}, nil)
StatusCode: http.StatusCreated,
}, nil)
+ schemaString := `{
+ "type": "object",
+ "properties": {},
+ "additionalProperties": false
+ }`
+ var schemaObj interface{}
+ json.Unmarshal([]byte(schemaString), &schemaObj)
+
type1 := TypeDefinition{
Identity: "Type1",
type1 := TypeDefinition{
Identity: "Type1",
- TypeSchema: `{"type": "object","properties": {},"additionalProperties": false}`,
}
types := []TypeDefinition{type1}
}
types := []TypeDefinition{type1}
assertions.Equal("/data-producer/v1/info-types/Type1", actualRequest.URL.Path)
assertions.Equal("application/json", actualRequest.Header.Get("Content-Type"))
body, _ := ioutil.ReadAll(actualRequest.Body)
assertions.Equal("/data-producer/v1/info-types/Type1", actualRequest.URL.Path)
assertions.Equal("application/json", actualRequest.Header.Get("Content-Type"))
body, _ := ioutil.ReadAll(actualRequest.Body)
- expectedBody := []byte(`{"info_job_data_schema": {"type": "object","properties": {},"additionalProperties": false}}`)
+ expectedBody := []byte(`{"info_job_data_schema": {"additionalProperties":false,"properties":{},"type":"object"}}`)
assertions.Equal(expectedBody, body)
clientMock.AssertNumberOfCalls(t, "Do", 1)
}
assertions.Equal(expectedBody, body)
clientMock.AssertNumberOfCalls(t, "Do", 1)
}
"net/http"
"github.com/gorilla/mux"
"net/http"
"github.com/gorilla/mux"
vars := mux.Vars(r)
id, ok := vars["typeId"]
if ok {
vars := mux.Vars(r)
id, ok := vars["typeId"]
if ok {
- fmt.Println("Registered type ", id)
+ fmt.Printf("Registered type %v with schema: %v\n", id, readBody(r))
vars := mux.Vars(r)
id, ok := vars["producerId"]
if ok {
vars := mux.Vars(r)
id, ok := vars["producerId"]
if ok {
- fmt.Println("Registered producer ", id)
+ fmt.Printf("Registered producer %v with data: %v\n", id, readBody(r))
+
+func readBody(r *http.Request) string {
+ b, readErr := ioutil.ReadAll(r.Body)
+ if readErr != nil {
+ return fmt.Sprintf("Unable to read body due to: %v", readErr)
+ }
+ return string(b)
+}