blob: 73807d31acc574b889bdc4137a9b1aa93f38e8bb [file]
// 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 conf
import (
"github.com/apache/doris-operator/pkg/controller"
"os"
)
var Default_Secret_Name = "doris-operator-secret-cert"
type EnvVariables struct {
EnableWebhook bool
OperatorNamespace string
OperatorName string
ServiceName string
}
// get envs
func ParseEnvs() *EnvVariables {
ev := &EnvVariables{}
enableWebhook := os.Getenv("ENABLE_WEBHOOK")
if enableWebhook == "true" {
ev.EnableWebhook = true
}
ev.OperatorNamespace = os.Getenv("OPERATOR_NAMESPACE")
if ev.OperatorNamespace == "" {
ev.OperatorNamespace = "doris"
}
ev.OperatorName = os.Getenv("OPERATOR_NAME")
if ev.OperatorName == "" {
ev.OperatorName = "doris-operator"
}
ev.ServiceName = os.Getenv("SERVICE_NAME")
if ev.ServiceName == "" {
ev.ServiceName = "doris-operator-service"
}
return ev
}
// build start parameters for controller
func NewControllerOptions(envs *EnvVariables) *controller.Options {
return &controller.Options{
EnableWebHook: envs.EnableWebhook,
Name: envs.OperatorName,
SecretName: Default_Secret_Name,
Namespace: envs.OperatorNamespace,
WebhookService: envs.ServiceName,
}
}