mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #97274 from nicolehanjing/nicoleh-update-sample
Update cloud-controller-manager samples to read --cloud-config flag
This commit is contained in:
		@@ -33,7 +33,8 @@ import (
 | 
				
			|||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/spf13/pflag"
 | 
						"github.com/spf13/pflag"
 | 
				
			||||||
	cloudprovider "k8s.io/cloud-provider"
 | 
					
 | 
				
			||||||
 | 
						"k8s.io/cloud-provider"
 | 
				
			||||||
	"k8s.io/cloud-provider/app"
 | 
						"k8s.io/cloud-provider/app"
 | 
				
			||||||
	cloudcontrollerconfig "k8s.io/cloud-provider/app/config"
 | 
						cloudcontrollerconfig "k8s.io/cloud-provider/app/config"
 | 
				
			||||||
	"k8s.io/cloud-provider/options"
 | 
						"k8s.io/cloud-provider/options"
 | 
				
			||||||
@@ -56,9 +57,6 @@ const (
 | 
				
			|||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
	rand.Seed(time.Now().UnixNano())
 | 
						rand.Seed(time.Now().UnixNano())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// cloudProviderConfigFile shows an sample of parse config file from flag option
 | 
					 | 
				
			||||||
	var flagset *pflag.FlagSet = pflag.NewFlagSet("flagSet", pflag.ContinueOnError)
 | 
					 | 
				
			||||||
	var cloudProviderConfigFile *string = flagset.String("cloud-provider-configfile", "", "This is the sample input for cloud provider config file")
 | 
					 | 
				
			||||||
	pflag.CommandLine.ParseErrorsWhitelist.UnknownFlags = true
 | 
						pflag.CommandLine.ParseErrorsWhitelist.UnknownFlags = true
 | 
				
			||||||
	_ = pflag.CommandLine.Parse(os.Args[1:])
 | 
						_ = pflag.CommandLine.Parse(os.Args[1:])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -75,7 +73,7 @@ func main() {
 | 
				
			|||||||
		os.Exit(1)
 | 
							os.Exit(1)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cloud, err := cloudprovider.InitCloudProvider(cloudProviderName, *cloudProviderConfigFile)
 | 
						cloud, err := cloudprovider.InitCloudProvider(cloudProviderName, c.ComponentConfig.KubeCloudShared.CloudProvider.CloudConfigFile)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		klog.Fatalf("Cloud provider could not be initialized: %v", err)
 | 
							klog.Fatalf("Cloud provider could not be initialized: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,7 @@ import (
 | 
				
			|||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/spf13/pflag"
 | 
						"github.com/spf13/pflag"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/cloud-provider"
 | 
						"k8s.io/cloud-provider"
 | 
				
			||||||
	"k8s.io/cloud-provider/app"
 | 
						"k8s.io/cloud-provider/app"
 | 
				
			||||||
	"k8s.io/cloud-provider/options"
 | 
						"k8s.io/cloud-provider/options"
 | 
				
			||||||
@@ -50,9 +51,6 @@ const (
 | 
				
			|||||||
func advancedMain() {
 | 
					func advancedMain() {
 | 
				
			||||||
	rand.Seed(time.Now().UnixNano())
 | 
						rand.Seed(time.Now().UnixNano())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// cloudProviderConfigFile shows an sample of parse config file from flag option
 | 
					 | 
				
			||||||
	var flagset *pflag.FlagSet = pflag.NewFlagSet("flagSet", pflag.ContinueOnError)
 | 
					 | 
				
			||||||
	var cloudProviderConfigFile *string = flagset.String("cloud-provider-configfile", "", "This is the sample input for cloud provider config file")
 | 
					 | 
				
			||||||
	pflag.CommandLine.ParseErrorsWhitelist.UnknownFlags = true
 | 
						pflag.CommandLine.ParseErrorsWhitelist.UnknownFlags = true
 | 
				
			||||||
	_ = pflag.CommandLine.Parse(os.Args[1:])
 | 
						_ = pflag.CommandLine.Parse(os.Args[1:])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -69,7 +67,7 @@ func advancedMain() {
 | 
				
			|||||||
		os.Exit(1)
 | 
							os.Exit(1)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cloud, err := cloudprovider.InitCloudProvider(cloudProviderName, *cloudProviderConfigFile)
 | 
						cloud, err := cloudprovider.InitCloudProvider(cloudProviderName, c.ComponentConfig.KubeCloudShared.CloudProvider.CloudConfigFile)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		klog.Fatalf("Cloud provider could not be initialized: %v", err)
 | 
							klog.Fatalf("Cloud provider could not be initialized: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,7 @@ import (
 | 
				
			|||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/spf13/pflag"
 | 
						"github.com/spf13/pflag"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/cloud-provider"
 | 
						"k8s.io/cloud-provider"
 | 
				
			||||||
	"k8s.io/cloud-provider/app"
 | 
						"k8s.io/cloud-provider/app"
 | 
				
			||||||
	"k8s.io/cloud-provider/options"
 | 
						"k8s.io/cloud-provider/options"
 | 
				
			||||||
@@ -45,8 +46,6 @@ const (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// sampleCloudProviderName shows an sample of using hard coded parameter for CloudProviderName
 | 
						// sampleCloudProviderName shows an sample of using hard coded parameter for CloudProviderName
 | 
				
			||||||
	sampleCloudProviderName = "SampleCloudProviderName"
 | 
						sampleCloudProviderName = "SampleCloudProviderName"
 | 
				
			||||||
	// sampleCloudProviderConfigFile shows an sample of using hard coded parameter for CloudProviderConfigFile
 | 
					 | 
				
			||||||
	sampleCloudProviderConfigFile = "sampleCloudProviderConfigFile"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
@@ -63,7 +62,7 @@ func main() {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// initialize cloud provider with the cloud provider name and config file provided
 | 
						// initialize cloud provider with the cloud provider name and config file provided
 | 
				
			||||||
	cloud, err := cloudprovider.InitCloudProvider(sampleCloudProviderName, sampleCloudProviderConfigFile)
 | 
						cloud, err := cloudprovider.InitCloudProvider(sampleCloudProviderName, c.ComponentConfig.KubeCloudShared.CloudProvider.CloudConfigFile)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		klog.Fatalf("Cloud provider could not be initialized: %v", err)
 | 
							klog.Fatalf("Cloud provider could not be initialized: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user