...

Source file src/github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/repo/paths.go

Documentation: github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/repo

     1  // Copyright 2022 Google LLC
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package repo
    16  
    17  import (
    18  	"os"
    19  	"path/filepath"
    20  
    21  	"k8s.io/klog/v2"
    22  )
    23  
    24  const serviceMappingDirEnvVar = "SERVICE_MAPPING_DIR"
    25  const serviceMappingDir = "/configconnector/servicemappings/"
    26  
    27  func GetServiceMappingsPathOrLogFatal() string {
    28  	if dir, ok := os.LookupEnv(serviceMappingDirEnvVar); ok {
    29  		val, err := filepath.Abs(dir)
    30  		if err != nil {
    31  			klog.Fatalf("error getting absolute path for '%v': %v", dir, err)
    32  		}
    33  		return val
    34  	}
    35  	repoRoot, err := GetRoot()
    36  	if err == nil {
    37  		return filepath.Join(repoRoot, "config", "servicemappings")
    38  	}
    39  	dir := serviceMappingDir
    40  	absPath, err := filepath.Abs(dir)
    41  	if err != nil {
    42  		klog.Fatalf("error getting absolute path for '%v': %v", dir, err)
    43  	}
    44  	return absPath
    45  }
    46  
    47  func GetDCLSchemasPathOrLogFatal() string {
    48  	return filepath.Join(GetRootOrLogFatal(), "temp-vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google")
    49  }
    50  
    51  func GetServiceAccountCRDPath() string {
    52  	return filepath.Join(GetCRDsPath(), "apiextensions.k8s.io_v1_customresourcedefinition_iamserviceaccounts.iam.cnrm.cloud.google.com.yaml")
    53  }
    54  
    55  func GetServiceAccountKeyCRDPath() string {
    56  	return filepath.Join(GetCRDsPath(), "apiextensions.k8s.io_v1_customresourcedefinition_iamserviceaccountkeys.iam.cnrm.cloud.google.com.yaml")
    57  }
    58  
    59  func GetResourcesSamplesPath() string {
    60  	return filepath.Join(GetRootOrLogFatal(), "config", "samples", "resources")
    61  }
    62  
    63  func GetCRDsPath() string {
    64  	return filepath.Join(GetRootOrLogFatal(), "config", "crds", "resources")
    65  }
    66  
    67  func GetResourcesSnippetsPath() string {
    68  	return filepath.Join(GetRootOrLogFatal(), "config", "cloudcodesnippets")
    69  }
    70  
    71  func GetClusterRolesPath() string {
    72  	return filepath.Join(GetRootOrLogFatal(), "config", "installbundle", "components", "clusterroles")
    73  }
    74  
    75  func GetG3ResourceReferenceTemplatesPath() string {
    76  	return filepath.Join(GetRootOrLogFatal(), "scripts", "generate-google3-docs", "resource-reference", "templates/")
    77  }
    78  
    79  func GetG3ResourceReferenceGeneratedPath() string {
    80  	return filepath.Join(GetRootOrLogFatal(), "scripts", "generate-google3-docs", "resource-reference", "generated", "resource-docs")
    81  }
    82  
    83  func GetG3ResourceListsTemplatePath() string {
    84  	return filepath.Join(GetRootOrLogFatal(), "scripts", "generate-google3-docs", "resource-lists", "template.tmpl")
    85  }
    86  
    87  func GetG3ResourceListsGeneratedPath() string {
    88  	return filepath.Join(GetRootOrLogFatal(), "scripts", "generate-google3-docs", "resource-lists", "generated")
    89  }
    90  
    91  func GetClientGenerationPath() string {
    92  	return filepath.Join(GetRootOrLogFatal(), "scripts", "generate-go-crd-clients")
    93  }
    94  
    95  func GetTypesGeneratedApisPath() string {
    96  	return filepath.Join(GetRootOrLogFatal(), "pkg", "clients", "generated", "apis")
    97  }
    98  
    99  func GetBasicIntegrationTestDataPath() string {
   100  	return filepath.Join(GetRootOrLogFatal(), "pkg", "test", "resourcefixture", "testdata", "basic")
   101  }
   102  
   103  func GetTypesTemplatePath() string {
   104  	return filepath.Join(GetRootOrLogFatal(), "scripts", "generate-go-crd-clients")
   105  }
   106  
   107  func GetAutoGeneratedServiceMappingsPathOrLogFatal() string {
   108  	return filepath.Join(GetRootOrLogFatal(), "scripts", "resource-autogen", "generated", "servicemappings")
   109  }
   110  
   111  func GetAutoGeneratedTFSamplesPathOrFatal() string {
   112  	return filepath.Join(GetRootOrLogFatal(), "scripts", "resource-autogen", "generated", "samples")
   113  }
   114  

View as plain text