mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
tools/deployContract: Remove specific k8s code (#10075)
This commit is contained in:
@@ -17,9 +17,6 @@ go_library(
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
"@com_github_x_cray_logrus_prefixed_formatter//:go_default_library",
|
||||
"@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library",
|
||||
"@io_k8s_client_go//kubernetes:go_default_library",
|
||||
"@io_k8s_client_go//rest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"os"
|
||||
@@ -19,9 +18,6 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
k8s "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -30,7 +26,6 @@ func main() {
|
||||
var passwordFile string
|
||||
var httpPath string
|
||||
var privKeyString string
|
||||
var k8sConfigMapName string
|
||||
var drainAddress string
|
||||
|
||||
customFormatter := new(prefixed.TextFormatter)
|
||||
@@ -71,11 +66,6 @@ func main() {
|
||||
Usage: "Private key to unlock account",
|
||||
Destination: &privKeyString,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "k8sConfig",
|
||||
Usage: "Name of kubernetes config map to update with the contract address",
|
||||
Destination: &k8sConfigMapName,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "drainAddress",
|
||||
Value: "",
|
||||
@@ -171,12 +161,6 @@ func main() {
|
||||
"address": addr.Hex(),
|
||||
}).Info("New contract deployed")
|
||||
|
||||
if k8sConfigMapName != "" {
|
||||
if err := updateKubernetesConfigMap(context.Background(), addr.Hex()); err != nil {
|
||||
log.Fatalf("Failed to update kubernetes config map: %v", err)
|
||||
}
|
||||
log.Printf("Updated config map %s", k8sConfigMapName)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -185,31 +169,3 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// updateKubernetesConfigMap in the beacon-chain namespace. This specifically
|
||||
// updates the data value for DEPOSIT_CONTRACT_ADDRESS.
|
||||
func updateKubernetesConfigMap(ctx context.Context, contractAddr string) error {
|
||||
config, err := rest.InClusterConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := k8s.NewForConfig(config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cm, err := client.CoreV1().ConfigMaps("beacon-chain").Get(ctx, "beacon-config", metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if cm.Data["DEPOSIT_CONTRACT_ADDRESS"] != "0x0" {
|
||||
return fmt.Errorf("existing vcr address in config map = %v", cm.Data["DEPOSIT_CONTRACT_ADDRESS"])
|
||||
}
|
||||
cm.Data["DEPOSIT_CONTRACT_ADDRESS"] = contractAddr
|
||||
|
||||
_, err = client.CoreV1().ConfigMaps("beacon-chain").Update(ctx, cm, metav1.UpdateOptions{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user