github.com/openebs/node-disk-manager@v1.9.1-0.20230225014141-4531f06ffa1e/pkg/cleaner/config.go (about)

     1  /*
     2  Copyright 2019 OpenEBS Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package cleaner
    18  
    19  import (
    20  	"os"
    21  )
    22  
    23  const (
    24  	// EnvCleanUpJobImage is the environment variable for getting the
    25  	// job container image
    26  	EnvCleanUpJobImage = "CLEANUP_JOB_IMAGE"
    27  	// ServiceAccountName is the service account in which the operator pod
    28  	// is running. The cleanup job, pod will be started with this service account
    29  	ServiceAccountName = "SERVICE_ACCOUNT"
    30  )
    31  
    32  var (
    33  	// defaultCleanUpJobImage is the default job container image
    34  	defaultCleanUpJobImage = "quay.io/openebs/linux-utils:latest"
    35  )
    36  
    37  // getCleanUpImage gets the image to be used for the cleanup job
    38  func getCleanUpImage() string {
    39  	image, ok := os.LookupEnv(EnvCleanUpJobImage)
    40  	if !ok {
    41  		return defaultCleanUpJobImage
    42  	}
    43  	return image
    44  }
    45  
    46  // getServiceAccount gets the service account in which the pod is running
    47  // TODO move env variable operations to a separate pkg
    48  func getServiceAccount() string {
    49  	return os.Getenv(ServiceAccountName)
    50  }