github.com/crossplane/upjet@v1.3.0/cmd/resolver/main.go (about) 1 // SPDX-FileCopyrightText: 2024 The Crossplane Authors <https://crossplane.io> 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package main 6 7 import ( 8 "os" 9 "path/filepath" 10 11 "github.com/crossplane/crossplane-runtime/pkg/logging" 12 "github.com/spf13/afero" 13 "gopkg.in/alecthomas/kingpin.v2" 14 "sigs.k8s.io/controller-runtime/pkg/log/zap" 15 16 "github.com/crossplane/upjet/pkg/transformers" 17 ) 18 19 func main() { 20 var ( 21 app = kingpin.New(filepath.Base(os.Args[0]), "Transformer for the generated resolvers by the crossplane-tools so that cross API-group imports are removed.").DefaultEnvars() 22 apiGroupSuffix = app.Flag("apiGroupSuffix", "Resource API group suffix, such as aws.upbound.io. The resource API group names are suffixed with this to get the canonical API group name.").Short('g').Required().String() 23 apiGroupOverride = app.Flag("apiGroupOverride", "API group overrides").Short('o').StringMap() 24 apiResolverPackage = app.Flag("apiResolverPackage", "The package that contains the implementation for the GetManagedResource function, such as github.com/upbound/provider-aws/internal/apis.").Short('a').Required().String() 25 pattern = app.Flag("pattern", "List patterns for the packages to process, such as ./...").Short('p').Default("./...").Strings() 26 resolverFilePattern = app.Flag("resolver", "Name of the generated resolver files to process.").Short('r').Default("zz_generated.resolvers.go").String() 27 ignorePackageLoadErrors = app.Flag("ignoreLoadErrors", "Ignore errors encountered while loading the packages.").Short('s').Bool() 28 ) 29 kingpin.MustParse(app.Parse(os.Args[1:])) 30 logger := logging.NewLogrLogger(zap.New().WithName("transformer-resolver")) 31 r := transformers.NewResolver(afero.NewOsFs(), *apiGroupSuffix, *apiResolverPackage, *ignorePackageLoadErrors, logger, transformers.WithAPIGroupOverrides(*apiGroupOverride)) 32 kingpin.FatalIfError(r.TransformPackages(*resolverFilePattern, *pattern...), "Failed to transform the resolver files in the specified packages.") 33 }