apache / dubbo-admin

The ops and reference implementation for Apache Dubbo
https://dubbo.apache.org
Apache License 2.0
3.99k stars 2.17k forks source link

Refactor authority startup with cobra and viper #1040

Closed 2456868764 closed 1 year ago

2456868764 commented 1 year ago

What is the purpose of the change

Refactor authority startup with cobra and viper

Brief changelog

  1. change authority command line flags style as follow:

    ./authority --help The authority app is responsible for controllers in dubbo authority

Usage: authority [flags]

Flags: --debug-port int dubbo debug port (default 30070) --enable-oidc-check dubbo enable OIDC check -h, --help help for authority --in-pod-env dubbo run in pod environment --is-kubernetes-connected dubbo connected with kubernetes --kubeconfig string Paths to a kubeconfig. Only required if out-of-cluster. --namespace string dubbo namespace (default "dubbo-system") --plain-server-port int dubbo plain server port (default 30060) --secure-server-port int dubbo secure server port (default 30062) --service-name string dubbo service name (default "dubbo-ca") --webhook-allow-on-err dubbo webhook allow on error (default true) --webhook-port int32 dubbo webhook port (default 30080)

  1. Read command line flags from Env variables, which are prefixed with DUBBO , for example

DUBBO_PLAIN_SERVER_PORT

  1. Change k8s client init rest.config

           `// Read kubeconfig from command line
    if len(kubeconfig) <= 0 {
        // Read kubeconfig from env
        kubeconfig = os.Getenv(clientcmd.RecommendedConfigPathEnvVar)
        if len(kubeconfig) <= 0 {
            // Read kubeconfig from home dir
            if home := homedir.HomeDir(); home != "" {
                kubeconfig = filepath.Join(home, ".kube", "config")
            }
        }
    }`

Verifying this change

  1. ./authority
  2. ./authority --kubeconfig=/Users/jun/.kube/config_kind --plain-server-port=30061
  3. DUBBO_PLAIN_SERVER_PORT=30061; ./authority
  4. KUBECONFIG=/Users/jun/.kube/config_kind;DUBBO_PLAIN_SERVER_PORT=30069; ./authority --plain-server-port=30061

Follow this checklist to help us incorporate your contribution quickly and easily:

github-advanced-security[bot] commented 1 year ago

You have successfully added a new SonarCloud configuration ``. As part of the setup process, we have scanned this repository and found no existing alerts. In the future, you will see all code scanning alerts on the repository Security tab.

codecov-commenter commented 1 year ago

Codecov Report

Merging #1040 (240e91f) into refactor-with-go (4927fe2) will increase coverage by 0.21%. The diff coverage is n/a.

@@                 Coverage Diff                  @@
##           refactor-with-go    #1040      +/-   ##
====================================================
+ Coverage             63.66%   63.88%   +0.21%     
====================================================
  Files                    29       29              
  Lines                  2323     2323              
====================================================
+ Hits                   1479     1484       +5     
+ Misses                  746      742       -4     
+ Partials                 98       97       -1     

see 2 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

AlbumenJ commented 1 year ago

Please fix conflicts

2456868764 commented 1 year ago

Please fix conflicts

i've fixed the conflicts and merged envflag.go , pls review it again!

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

2456868764 commented 1 year ago

LGTM Please fix conflict again :)

I've fixed the conflict, please review again