Skip to content

Commit

Permalink
baetyl add fingerprint command (#797)
Browse files Browse the repository at this point in the history
Co-authored-by: miaodanyang <miaodanyang@baidu.com>
  • Loading branch information
miaow999 and miaodanyang committed Nov 1, 2023
1 parent f0f93d5 commit eb0d642
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
38 changes: 38 additions & 0 deletions cmd/fingerprint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cmd

import (
"fmt"

"github.com/baetyl/baetyl-go/v2/log"
"github.com/baetyl/baetyl-go/v2/utils"
"github.com/spf13/cobra"
)

type GetFingerprintFunc func()

const (
HookGetFingerprint = "getFingerprint"
)

func init() {
rootCmd.AddCommand(fingerprint)
}

var fingerprint = &cobra.Command{
Use: "fingerprint",
Short: "Obtain machine fingerprints.",
Long: "Observer machine fingerprints activation program",
Run: func(_ *cobra.Command, _ []string) {
Hooks[HookGetFingerprint].(GetFingerprintFunc)()
},
}

func GetFingerprint() {
info, err := utils.GetFingerprint("")
if err != nil {
log.L().Error("get fingerprint err: " + err.Error())
return
}
fmt.Println("Copy The Fingerprint:")
fmt.Println(info)
}
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
replace github.com/kardianos/service => github.com/baetyl/service v1.2.3-0.20221205070704-85cb455aa3a3

require (
github.com/baetyl/baetyl-go/v2 v2.2.4-0.20231013083918-f1eadd462ead
github.com/baetyl/baetyl-go/v2 v2.2.4-0.20231101031952-339029b804ca
github.com/golang/mock v1.6.0
github.com/gorilla/websocket v1.4.2
github.com/imdario/mergo v0.3.12
Expand Down Expand Up @@ -41,6 +41,7 @@ require (
github.com/containerd/containerd v1.5.18 // indirect
github.com/creasty/defaults v1.4.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/denisbrodbeck/machineid v1.0.1 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/dsnet/compress v0.0.1 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/baetyl/baetyl-go/v2 v2.2.4-0.20231013083918-f1eadd462ead h1:6SXFs7Qw+C34FE3Wzg0Me1MVtS/V6kIW0VvsnMidHN4=
github.com/baetyl/baetyl-go/v2 v2.2.4-0.20231013083918-f1eadd462ead/go.mod h1:p1V1EpzbtPV4pAQirG+XvpXOGmEU7wOuZ+G5onHzRpk=
github.com/baetyl/baetyl-go/v2 v2.2.4-0.20231101031952-339029b804ca h1:fteulNfMZJIG6ummZ7ChNxYN7THGX5LiNbi3L4IbZNE=
github.com/baetyl/baetyl-go/v2 v2.2.4-0.20231101031952-339029b804ca/go.mod h1:tZo5qNUjoPcTBDBF61Ubdg92SAzFAHhtguYi6iRlblY=
github.com/baetyl/service v1.2.3-0.20221205070704-85cb455aa3a3 h1:vVNBMGCt01dwNwF2wtctC4uUbfgW6eXUG9ZicajIfAs=
github.com/baetyl/service v1.2.3-0.20221205070704-85cb455aa3a3/go.mod h1:CIMRFEJVL+0DS1a3Nx06NaMn4Dz63Ng6O7dl0qH0zVM=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
Expand Down Expand Up @@ -82,6 +82,8 @@ github.com/creasty/defaults v1.4.0/go.mod h1:9UWnPlI41ASz+YJswP5aK5S79d6QH60/Ioz
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/denisbrodbeck/machineid v1.0.1 h1:geKr9qtkB876mXguW2X6TU4ZynleN6ezuMSRhl4D7AQ=
github.com/denisbrodbeck/machineid v1.0.1/go.mod h1:dJUwb7PTidGDeYyUBmXZ2GphQBbjJCrnectwCyxcUSI=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
func init() {
cmd.Hooks[cmd.HookNameStartCoreService] = core.StartCoreServiceFunc(core.StartCoreService)
cmd.Hooks[cmd.HookNameStartInitService] = initz.StartInitServiceFunc(initz.StartInitService)
cmd.Hooks[cmd.HookGetFingerprint] = cmd.GetFingerprintFunc(cmd.GetFingerprint)
}

func main() {
Expand Down

0 comments on commit eb0d642

Please sign in to comment.