mirror of
https://github.com/compute-blade-community/compute-blade-agent.git
synced 2026-04-21 17:45:43 +02:00
chore(ci): update Go setup action to v5 and simplify caching configuration for improved performance chore(release): update Go setup action to v5 and simplify caching configuration for improved performance fix(.gitignore): add .idea directory to ignore list to prevent IDE files from being tracked feat(goreleaser): add versioning information to builds for better traceability feat(agent): expose version, commit, and date information in logs for better tracking feat(bladectl): implement command structure for managing compute-blade features fix(bladectl): improve error handling in identify command for better user feedback chore(go.mod): update dependencies to latest versions for improved stability and features
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"time"
|
|
|
|
bladeapiv1alpha1 "github.com/uptime-induestries/compute-blade-agent/api/bladeapi/v1alpha1"
|
|
)
|
|
|
|
type grpcClientContextKey int
|
|
|
|
const (
|
|
defaultGrpcClientContextKey grpcClientContextKey = 0
|
|
defaultGrpcClientConnContextKey grpcClientContextKey = 1
|
|
)
|
|
|
|
var (
|
|
grpcAddr string
|
|
timeout time.Duration
|
|
|
|
Version string
|
|
Commit string
|
|
Date string
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.PersistentFlags().
|
|
StringVar(&grpcAddr, "addr", "unix:///tmp/compute-blade-agent.sock", "address of the compute-blade-agent gRPC server")
|
|
rootCmd.PersistentFlags().DurationVar(&timeout, "timeout", time.Minute, "timeout for gRPC requests")
|
|
}
|
|
|
|
func clientIntoContext(ctx context.Context, client bladeapiv1alpha1.BladeAgentServiceClient) context.Context {
|
|
return context.WithValue(ctx, defaultGrpcClientContextKey, client)
|
|
}
|
|
|
|
func clientFromContext(ctx context.Context) bladeapiv1alpha1.BladeAgentServiceClient {
|
|
client, ok := ctx.Value(defaultGrpcClientContextKey).(bladeapiv1alpha1.BladeAgentServiceClient)
|
|
if !ok {
|
|
panic("grpc client not found in context")
|
|
}
|
|
return client
|
|
}
|
|
|
|
func main() {
|
|
if err := rootCmd.Execute(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|