Cosmos plugin environment subscribe command#291
Conversation
| logger := zap.NewExample().Sugar() | ||
| defer logger.Sync() | ||
|
|
||
| u := url.URL{Scheme: "ws", Host: "0.0.0.0:26657", Path: "/websocket"} |
There was a problem hiding this comment.
@Catalin4513 use parameters and variables for host,port and path.
ab42e8f to
94ebe63
Compare
| Namespace string `name:"namespace" short:"n" help:"Namespace used for cluster resources"` | ||
| EngineRelease string `name:"engine-release" short:"r" help:"Crossplane Helm release name"` | ||
| EngineVersion string `name:"engine-version" default:"1.19.0" short:"v" help:"Crossplane version"` | ||
| PluginPath string `name:"plugin-path" help:"Path to the plugin file" default:"./plugins/cosmos.so"` |
There was a problem hiding this comment.
@Catalin4513 shall be default value where plugins stored, but not single plugin file.
There was a problem hiding this comment.
@Catalin4513 was idea of fully dynamic plugins, even not stored in this repository, just make it look to directory and load all .so files from there.
| ) | ||
|
|
||
| type CLI struct { | ||
| Network network.Cmd `cmd:"" help:"Network information"` |
There was a problem hiding this comment.
@Catalin4513 I another plugin will have also Network command what's happens?
Idea was that every plugin adds own commands namespace, like Cosmos
| @@ -0,0 +1,18 @@ | |||
| package network | |||
| if engine == "" { | ||
| engine = "k3s" | ||
| } |
There was a problem hiding this comment.
@Catalin4513 you do not need this condition if you have default value, and on cmd level it shall be k3s, we do not support kind in case of networks at all.
| result, ok := decodedMessage["result"].(map[string]interface{}) | ||
| if !ok { | ||
| log.Println("Skipping message: 'result' field is missing") | ||
| return msgStruct, fmt.Errorf("'result' field is missing") | ||
| } | ||
|
|
||
| data, ok := result["data"].(map[string]interface{}) | ||
| if !ok { | ||
| log.Println("Skipping message: 'data' field is missing") | ||
| return msgStruct, fmt.Errorf("'data' field is missing") | ||
| } | ||
|
|
||
| value, ok := data["value"].(map[string]interface{}) | ||
| if !ok { | ||
| log.Println("Skipping message: 'value' field is missing") | ||
| return msgStruct, fmt.Errorf("'value' field is missing") | ||
| } | ||
|
|
||
| txResult, ok := value["TxResult"].(map[string]interface{}) | ||
| if !ok { | ||
| log.Println("Skipping message: 'TxResult' field is missing") | ||
| return msgStruct, fmt.Errorf("'TxResult' field is missing") | ||
| } | ||
|
|
||
| transaction, ok := txResult["tx"].(string) | ||
| if !ok { | ||
| log.Println("Skipping message: 'tx' field is missing or not a string") | ||
| return msgStruct, fmt.Errorf("'tx' field is missing or not a string") | ||
| } | ||
|
|
||
| txBytes, err := base64.StdEncoding.DecodeString(transaction) | ||
| if err != nil { | ||
| log.Printf("Failed to decode base64: %v", err) | ||
| return msgStruct, err | ||
| } |
There was a problem hiding this comment.
@Catalin4513 is not good idea to direct convert fields, use unmarshal to ready to use structure and use validation package for structures for simplify code, take a look to repository package, there validation was used.
94ebe63 to
912e3e1
Compare
No description provided.