Skip to content
Open
Changes from all commits
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
19 changes: 11 additions & 8 deletions pkg/connectors/microcks_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func NewClient(opts ClientOptions) (MicrocksClient, error) {

u, err := url.Parse(apiURL)
if err != nil {
panic(err)
return nil, fmt.Errorf("failed to parse API URL: %w", err)
}
c.APIURL = u

Expand Down Expand Up @@ -239,12 +239,12 @@ func (c *microcksClient) GetKeycloakURL() (string, error) {

body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err.Error())
return "", fmt.Errorf("failed to read keycloak config response body: %w", err)
}

var configResp map[string]interface{}
if err := json.Unmarshal(body, &configResp); err != nil {
panic(err)
return "", fmt.Errorf("failed to parse keycloak config response: %w", err)
}

// Retrieve auth server url and realm name.
Expand Down Expand Up @@ -381,15 +381,18 @@ func (c *microcksClient) CreateTestResult(serviceID string, testEndpoint string,

body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err.Error())
return "", fmt.Errorf("failed to read create test response body: %w", err)
}

var createTestResp map[string]interface{}
if err := json.Unmarshal(body, &createTestResp); err != nil {
panic(err)
return "", fmt.Errorf("failed to parse create test response: %w", err)
}

testID := createTestResp["id"].(string)
testID, ok := createTestResp["id"].(string)
if !ok {
return "", fmt.Errorf("invalid response format: missing or non-string id")
}
return testID, err
}

Expand Down Expand Up @@ -420,7 +423,7 @@ func (c *microcksClient) GetTestResult(testResultID string) (*TestResultSummary,

body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err.Error())
return nil, fmt.Errorf("failed to read test result response body: %w", err)
}

result := TestResultSummary{}
Expand Down Expand Up @@ -553,7 +556,7 @@ func (c *microcksClient) DownloadArtifact(artifactURL string, mainArtifact bool,

respBody, err := io.ReadAll(resp.Body)
if err != nil {
panic(err.Error())
return "", fmt.Errorf("failed to read upload artifact response body: %w", err)
}

// Raise exception if not created.
Expand Down
Loading