Skip to content

Commit 240efdf

Browse files
committed
Refactor to address linting.
Signed-off-by: agoins <alyssacgoins@gmail.com>
1 parent 20887ad commit 240efdf

17 files changed

Lines changed: 26 additions & 23 deletions

File tree

backend/src/common/client/api_server/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func NewHTTPRuntime(clientConfig clientcmd.ClientConfig, debug bool, tlsCfg *tls
7575
if testconfig.ApiScheme != nil {
7676
scheme = append(scheme, *testconfig.ApiScheme)
7777
}
78-
if *testconfig.DisableTlsCheck {
78+
if *testconfig.DisableTLSCheck {
7979
tr := &http.Transport{
8080
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
8181
}

backend/src/common/util/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func GetKubernetesClientFromClientConfig(clientConfig clientcmd.ClientConfig) (
103103
return clientSet, config, namespace, nil
104104
}
105105

106-
func GetRpcConnectionWithTimeout(address string, tlsCfg *tls.Config, timeout time.Time) (*grpc.ClientConn, error) {
106+
func GetRPCConnectionWithTimeout(address string, tlsCfg *tls.Config, timeout time.Time) (*grpc.ClientConn, error) {
107107
creds := insecure.NewCredentials()
108108
if tlsCfg != nil {
109109
creds = credentials.NewTLS(tlsCfg)
@@ -124,7 +124,7 @@ func GetRpcConnection(address string, tlsCfg *tls.Config) (*grpc.ClientConn, err
124124
creds = credentials.NewTLS(tlsCfg)
125125
}
126126

127-
conn, err := grpc.Dial(
127+
conn, err := grpc.NewClient(
128128
address,
129129
grpc.WithTransportCredentials(creds),
130130
)

backend/src/common/util/tls_config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"os"
77
)
88

9+
// Util to create TLS config.
10+
911
// GetTLSConfig returns TLS config set with system CA certs as well as custom CA stored at input caCertPath if provided.
1012
func GetTLSConfig(caCertPath string) (*tls.Config, error) {
1113
caCertPool, err := x509.SystemCertPool()

backend/src/crd/controller/scheduledworkflow/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func main() {
111111
log.Fatalf("Error creating tls config: %s", err.Error())
112112
}
113113

114-
apiConnection, err := commonutil.GetRpcConnectionWithTimeout(grpcAddress, tlsCfg, time.Now().Add(time.Minute))
114+
apiConnection, err := commonutil.GetRPCConnectionWithTimeout(grpcAddress, tlsCfg, time.Now().Add(time.Minute))
115115
if err != nil {
116116
log.Fatalf("Error connecting to the API server after trying for one minute: %v", err)
117117
}

backend/src/v2/cacheutils/cache.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ func NewClient(cacheDisabled bool, tlsCfg *tls.Config) (Client, error) {
8787
creds = credentials.NewTLS(tlsCfg)
8888
}
8989
glog.Infof("Connecting to cache endpoint %s", defaultKfpApiEndpoint)
90-
conn, err := grpc.Dial(
90+
conn, err := grpc.NewClient(
9191
defaultKfpApiEndpoint,
9292
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(MaxClientGRPCMessageSize)),
9393
grpc.WithTransportCredentials(creds),
9494
)
95+
9596
if err != nil {
9697
return nil, fmt.Errorf("metadata.NewClient() failed: %w", err)
9798
}

backend/src/v2/metadata/testutils/test_utils.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ import (
77
pb "github.com/kubeflow/pipelines/third_party/ml-metadata/go/ml_metadata"
88
"google.golang.org/grpc"
99
"google.golang.org/grpc/credentials"
10+
"google.golang.org/grpc/credentials/insecure"
1011
)
1112

1213
func NewTestMlmdClient(testMlmdServerAddress string, testMlmdServerPort string, tlsEnabled bool, caCertPath string) (pb.MetadataStoreServiceClient, error) {
13-
dialOption := grpc.WithInsecure()
14+
creds := insecure.NewCredentials()
1415
if tlsEnabled {
1516
tlsCfg, err := test.GetTLSConfig(caCertPath)
1617
if err != nil {
1718
return nil, err
1819
}
19-
creds := credentials.NewTLS(tlsCfg)
20-
dialOption = grpc.WithTransportCredentials(creds)
20+
creds = credentials.NewTLS(tlsCfg)
2121
}
22+
dialOption := grpc.WithTransportCredentials(creds)
2223
conn, err := grpc.Dial(fmt.Sprintf("%s:%s", testMlmdServerAddress, testMlmdServerPort),
2324
dialOption,
2425
)

backend/test/config/flags.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ var (
3030
ApiHost = flag.String("apiHost", "localhost", "The hostname of the API server")
3131
ApiPort = flag.String("apiPort", "8888", "The port on which the API server is listening")
3232
ApiUrl = flag.String("apiUrl", fmt.Sprintf("%s://%s:%s", *ApiScheme, *ApiHost, *ApiPort), "The URL of the API server")
33-
DisableTlsCheck = flag.Bool("disableTlsCheck", false, "Whether to use server certificate chain and hostname.")
33+
DisableTLSCheck = flag.Bool("disableTlsCheck", false, "Whether to use server certificate chain and hostname")
3434
InClusterRun = flag.Bool("runInCluster", false, "Whether to run your tests from within the K8s cluster")
3535
AuthToken = flag.String("authToken", "", "The default auth token that will be injected to all your API request")
36-
TlsEnabled = flag.Bool("tlsEnabled", false, "Set to true if mlpipeline API server and metadata server serve over TLS.")
37-
CaCertPath = flag.String("caCertPath", "", "The path to the CA certificate to trust on connections to the ML pipeline API server and metadata server.")
36+
TLSEnabled = flag.Bool("tlsEnabled", false, "Set to true if mlpipeline API server and metadata server serve over TLS")
37+
CaCertPath = flag.String("caCertPath", "", "The path to the CA certificate to trust on connections to the ML pipeline API server and metadata server")
3838
)
3939

4040
var (

backend/test/end2end/e2e_suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ var _ = BeforeSuite(func() {
7070
k8Client, err = testutil.CreateK8sClient()
7171
Expect(err).To(BeNil(), "Failed to initialize K8s client")
7272
var tlsCfg *tls.Config
73-
if *config.TlsEnabled {
73+
if *config.TLSEnabled {
7474
tlsCfg, err = test.GetTLSConfig(*config.CaCertPath)
7575
if err != nil {
7676
log.Fatalf("Error getting TLS Config: %v", err)

backend/test/integration/pipeline_version_api_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
params "github.com/kubeflow/pipelines/backend/api/v1beta1/go_http_client/pipeline_client/pipeline_service"
2424
"github.com/kubeflow/pipelines/backend/api/v1beta1/go_http_client/pipeline_model"
2525
uploadParams "github.com/kubeflow/pipelines/backend/api/v1beta1/go_http_client/pipeline_upload_client/pipeline_upload_service"
26-
"github.com/kubeflow/pipelines/backend/src/apiserver/template"
2726
pipelinetemplate "github.com/kubeflow/pipelines/backend/src/apiserver/template"
2827
api_server "github.com/kubeflow/pipelines/backend/src/common/client/api_server/v1"
2928
"github.com/kubeflow/pipelines/backend/src/common/util"
@@ -337,7 +336,7 @@ func (s *PipelineVersionApiTest) TestArgoSpec() {
337336
require.Nil(t, err)
338337
bytes, err := os.ReadFile("../resources/arguments-parameters.yaml")
339338
require.Nil(t, err)
340-
expected, err := pipelinetemplate.New(bytes, template.TemplateOptions{CacheDisabled: true})
339+
expected, err := pipelinetemplate.New(bytes, pipelinetemplate.TemplateOptions{CacheDisabled: true})
341340
require.Nil(t, err)
342341
assert.Equal(t, expected, tmpl)
343342
}
@@ -370,7 +369,7 @@ func (s *PipelineVersionApiTest) TestV2Spec() {
370369
require.Nil(t, err)
371370
bytes, err := os.ReadFile("../resources/v2-hello-world.yaml")
372371
require.Nil(t, err)
373-
expected, err := pipelinetemplate.New(bytes, template.TemplateOptions{CacheDisabled: true})
372+
expected, err := pipelinetemplate.New(bytes, pipelinetemplate.TemplateOptions{CacheDisabled: true})
374373
require.Nil(t, err)
375374
assert.Equal(t, expected, tmpl, "Discrepancy found in template's pipeline name. Created pipeline's name - %s.", pipeline.Name)
376375
}

backend/test/testutil/test_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func CheckIfSkipping(stringValue string) {
6262
ginkgo.Skip(fmt.Sprintf("Skipping pipeline run test because of a known issue: https://github.com/kubeflow/pipelines/issues/%s", issue))
6363
}
6464
// Skip pipeline 'pipeline_submit_request' test if TLS is not enabled
65-
if !*config.TlsEnabled && strings.Contains(strings.ToLower(stringValue), "pipeline_submit_request") {
65+
if !*config.TLSEnabled && strings.Contains(strings.ToLower(stringValue), "pipeline_submit_request") {
6666
ginkgo.Skip(fmt.Sprintf("Skipping pipeline run test because TLS is not enabled"))
6767
}
6868
}

0 commit comments

Comments
 (0)