Skip to content

Commit

Permalink
Add get-latest-ethereum-client-version command to CTF Utils CMD Tool (
Browse files Browse the repository at this point in the history
#964)

* Add `get-latest-ethereum-client-version` command to CTF Utils CMD Tool

* fix
  • Loading branch information
lukaszcl authored May 27, 2024
1 parent b6a4700 commit 6df0418
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
30 changes: 30 additions & 0 deletions utils/cmd/internal/get_latest_version_commands.go
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
},
}
33 changes: 33 additions & 0 deletions utils/cmd/main.go
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)
}
}

0 comments on commit 6df0418

Please sign in to comment.