Skip to content

Cosmos plugin environment subscribe command#291

Merged
evgheni7 merged 2 commits into
mainfrom
263-featenv-auto-create-environment-by-network-event
Mar 31, 2025
Merged

Cosmos plugin environment subscribe command#291
evgheni7 merged 2 commits into
mainfrom
263-featenv-auto-create-environment-by-network-event

Conversation

@Catalin4513
Copy link
Copy Markdown
Contributor

No description provided.

@Catalin4513 Catalin4513 self-assigned this Mar 28, 2025
@Catalin4513 Catalin4513 requested a review from evgheni7 as a code owner March 28, 2025 13:59
@Catalin4513 Catalin4513 linked an issue Mar 28, 2025 that may be closed by this pull request
2 tasks
Comment thread cmd/overlock/main.go Outdated
Comment thread plugins/cosmos/cmd/main.go Outdated
Comment thread plugins/cosmos/pkg/network/network.go Outdated
logger := zap.NewExample().Sugar()
defer logger.Sync()

u := url.URL{Scheme: "ws", Host: "0.0.0.0:26657", Path: "/websocket"}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Catalin4513 use parameters and variables for host,port and path.

Comment thread plugins/cosmos/pkg/network/network.go Outdated
Comment thread plugins/cosmos/pkg/network/network.go Outdated
@Catalin4513 Catalin4513 force-pushed the 263-featenv-auto-create-environment-by-network-event branch from ab42e8f to 94ebe63 Compare March 31, 2025 12:52
Comment thread cmd/overlock/main.go Outdated
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"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Catalin4513 shall be default value where plugins stored, but not single plugin file.

Comment thread cmd/overlock/plugin/plugin.go Outdated
Copy link
Copy Markdown
Contributor

@evgheni7 evgheni7 Mar 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Comment thread plugins/cosmos/cmd/main.go Outdated
)

type CLI struct {
Network network.Cmd `cmd:"" help:"Network information"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Catalin4513 I another plugin will have also Network command what's happens?
Idea was that every plugin adds own commands namespace, like Cosmos

Comment thread plugins/cosmos/cmd/network/subscribe.go Outdated
@@ -0,0 +1,18 @@
package network
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Catalin4513 cosmos package, not network

Comment thread plugins/cosmos/pkg/network/network.go Outdated
Comment on lines +156 to +158
if engine == "" {
engine = "k3s"
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Comment thread plugins/cosmos/pkg/network/network.go Outdated
Comment on lines +96 to +107
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
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@evgheni7 evgheni7 changed the title Renamed environment files Cosmos network plugin Mar 31, 2025
@evgheni7 evgheni7 changed the title Cosmos network plugin Cosmos plugin environment subscribe command Mar 31, 2025
@Catalin4513 Catalin4513 force-pushed the 263-featenv-auto-create-environment-by-network-event branch from 94ebe63 to 912e3e1 Compare March 31, 2025 16:15
@evgheni7 evgheni7 merged commit 9a37d85 into main Mar 31, 2025
@evgheni7 evgheni7 deleted the 263-featenv-auto-create-environment-by-network-event branch March 31, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 feat(env): Auto create Environment by network event

2 participants