-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
get-latest-ethereum-client-version
command to CTF Utils CMD Tool (
#964) * Add `get-latest-ethereum-client-version` command to CTF Utils CMD Tool * fix
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package internal | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" | ||
) | ||
|
||
var GetLatestEthereumClientVersionCmd = &cobra.Command{ | ||
Use: "get-latest-ethereum-client-version", | ||
Short: "Get the latest Ethereum client release version from Github", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) != 1 { | ||
return fmt.Errorf("please provide the repository in the format 'org/repo:tag'") | ||
} | ||
|
||
repo := args[0] | ||
|
||
latest, err := test_env.FetchLatestEthereumClientDockerImageVersionIfNeed(repo) | ||
if err != nil { | ||
return fmt.Errorf("error fetching release information: %v", err) | ||
} | ||
|
||
fmt.Println(strings.Split(latest, ":")[1]) | ||
return nil | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"time" | ||
|
||
"github.com/spf13/cobra" | ||
"golang.org/x/net/context" | ||
|
||
"github.com/smartcontractkit/chainlink-testing-framework/utils/cmd/internal" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "ctf-utils", | ||
Short: "CTF Utils Tool", | ||
} | ||
|
||
func init() { | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*1) | ||
defer cancel() | ||
|
||
internal.GetLatestEthereumClientVersionCmd.SetContext(ctx) | ||
|
||
rootCmd.AddCommand(internal.GetLatestEthereumClientVersionCmd) | ||
} | ||
|
||
func main() { | ||
if err := rootCmd.Execute(); err != nil { | ||
log.Println(err) | ||
os.Exit(1) | ||
} | ||
} |