Skip to content

Commit

Permalink
🌱 add clusterName, clusterID for later usage
Browse files Browse the repository at this point in the history
  • Loading branch information
anngdinh committed Apr 4, 2024
1 parent 42e3fd4 commit 71fa2a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 7 additions & 4 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ import (

// Config struct contains ingress controller configuration
type Config struct {
ClusterName string `mapstructure:"clusterName"`
Kubernetes kubeConfig `mapstructure:"kubernetes"`
Global client.AuthOpts `mapstructure:"global"`
Metadata metadata.Opts `mapstructure:"metadata"`
Cluster struct {
ClusterName string `mapstructure:"clusterName"`
ClusterID string `mapstructure:"clusterID"`
} `mapstructure:"cluster"`
Kubernetes kubeConfig `mapstructure:"kubernetes"`
Global client.AuthOpts `mapstructure:"global"`
Metadata metadata.Opts `mapstructure:"metadata"`
}

// Configuration for connecting to Kubernetes API server, either api_host or kubeconfig should be configured.
Expand Down
8 changes: 7 additions & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ func NewController(conf config.Config) *Controller {
// Start starts the vngcloud ingress controller.
func (c *Controller) Start() {
klog.Infoln("------------ Start() ------------")
klog.Infoln("ClusterName: ", c.getClusterName())
klog.Infoln("ClusterID: ", c.getClusterID())
defer close(c.stopCh)
defer utilruntime.HandleCrash()
defer c.queue.ShutDown()
Expand Down Expand Up @@ -1568,7 +1570,11 @@ func (c *Controller) toVngCloudCertificate(secretName string, namespace string,

// NAME RESOURCE
func (c *Controller) getClusterName() string {
return c.config.ClusterName
return c.config.Cluster.ClusterName
}

func (c *Controller) getClusterID() string {
return c.config.Cluster.ClusterID
}

func (c *Controller) generateHashName(ing *nwv1.Ingress) string {
Expand Down

0 comments on commit 71fa2a5

Please sign in to comment.