Copilot commented on code in PR #16169: URL: https://github.com/apache/pinot/pull/16169#discussion_r2160276669
########## pinot-tools/src/main/resources/scripts/timeseries/run_ts_query.py: ########## @@ -0,0 +1,94 @@ +#!/usr/bin/env python +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +import argparse +import requests +import time +import logging +import sys + +# === Constants === +DEFAULT_QUERY_FILE = "query.txt" +DEFAULT_API_URL = "http://localhost:8000/timeseries/api/v1/query_range" +DEFAULT_DURATION_SECONDS = 3600 +AUTH_TOKEN = "Basic YWRtaW46dmVyeXNlY3JldA==" Review Comment: Consider loading the auth token from an environment variable or external config rather than hard-coding it to improve security and flexibility. ```suggestion import os # === Constants === DEFAULT_QUERY_FILE = "query.txt" DEFAULT_API_URL = "http://localhost:8000/timeseries/api/v1/query_range" DEFAULT_DURATION_SECONDS = 3600 AUTH_TOKEN = os.getenv("TIMESERIES_AUTH_TOKEN") if AUTH_TOKEN is None: print("Error: TIMESERIES_AUTH_TOKEN environment variable is not set.") sys.exit(1) ``` ########## pinot-tools/src/main/java/org/apache/pinot/tools/utils/AuthUtils.java: ########## @@ -0,0 +1,70 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.tools.utils; + +import java.util.HashMap; +import java.util.Map; + + +public class AuthUtils { + + private AuthUtils() { + } + + public static Map<String, Object> getAuthConfigs() { + Map<String, Object> properties = new HashMap<>(); + // controller + properties.put("pinot.controller.segment.fetcher.auth.token", "Basic YWRtaW46dmVyeXNlY3JldA=="); Review Comment: Extract the repeated auth token string into a constant to avoid duplication and simplify future updates. ```suggestion private static final String DEFAULT_AUTH_TOKEN = "Basic YWRtaW46dmVyeXNlY3JldA=="; private AuthUtils() { } public static Map<String, Object> getAuthConfigs() { Map<String, Object> properties = new HashMap<>(); // controller properties.put("pinot.controller.segment.fetcher.auth.token", DEFAULT_AUTH_TOKEN); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
