Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MG-2025 - CLI : Flag to print only curl output #2242

Merged
merged 19 commits into from
Jun 18, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Feature: Add flag to print cURL commands
Signed-off-by: JeffMboya <[email protected]>
JeffMboya authored and dborovcanin committed Jun 18, 2024
commit 3eeabde131048ef0a2c30c16d4e49fa13794f02f
4 changes: 1 addition & 3 deletions cli/sdk.go
Original file line number Diff line number Diff line change
@@ -3,9 +3,7 @@

package cli

import (
mgxsdk "github.com/absmach/magistrala/pkg/sdk/go"
)
import mgxsdk "github.com/absmach/magistrala/pkg/sdk/go"

// Keep SDK handle in global var.
var sdk mgxsdk.SDK
6 changes: 2 additions & 4 deletions pkg/sdk/go/sdk.go
Original file line number Diff line number Diff line change
@@ -1192,7 +1192,7 @@ type Config struct {

// NewSDK returns new magistrala SDK instance.
func NewSDK(conf Config) SDK {
sdk := &mgSDK{
return &mgSDK{
bootstrapURL: conf.BootstrapURL,
certsURL: conf.CertsURL,
httpAdapterURL: conf.HTTPAdapterURL,
@@ -1213,13 +1213,11 @@ func NewSDK(conf Config) SDK {
},
curlFlag: conf.CurlFlag,
}

return sdk
}

// processRequest creates and send a new HTTP request, and checks for errors in the HTTP response.
// It then returns the response headers, the response body, and the associated error(s) (if any).
func (sdk *mgSDK) processRequest(method, reqUrl, token string, data []byte, headers map[string]string, expectedRespCodes ...int) (http.Header, []byte, errors.SDKError) {
func (sdk mgSDK) processRequest(method, reqUrl, token string, data []byte, headers map[string]string, expectedRespCodes ...int) (http.Header, []byte, errors.SDKError) {
req, err := http.NewRequest(method, reqUrl, bytes.NewReader(data))
if err != nil {
return make(http.Header), []byte{}, errors.NewSDKError(err)
20 changes: 0 additions & 20 deletions pkg/sdk/mocks/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.