Skip to content

Commit

Permalink
[ignore] Adjusted environment variable checking so only a string repr…
Browse files Browse the repository at this point in the history
…esenting a true boolean value is accepted.
  • Loading branch information
samiib authored and lhercot committed Nov 11, 2024
1 parent f5cd137 commit 4fe22cb
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,11 @@ func getExampleCode(filePath string) []byte {

// When RE_GEN_CLASSES environment variable is set, the existing class metadata is retrieved from APIC or the latest devnet docs and stored in the meta directory.
func reGenClassMetadata() {
_, re_gen_classes := os.LookupEnv("RE_GEN_CLASSES")
if re_gen_classes {
reGenClasses, err := strconv.ParseBool(os.Getenv("RE_GEN_CLASSES"))
if err != nil {
return
}
if reGenClasses {
names := getFileNames(metaPath)
classNames := strings.Join(names, ",")
getClassMetadata(classNames)
Expand All @@ -788,10 +791,6 @@ func reGenClassMetadata() {
// When GEN_CLASSES environment variable is set, the class metadata is retrieved from the APIC or the latest devnet docs and stored in the meta directory.
func getClassMetadata(classNames string) {

if classNames == "" {
classNames = os.Getenv("GEN_CLASSES")
}

if classNames != "" {
var name, nameSpace, url string
classNameList := strings.Split(classNames, ",")
Expand Down Expand Up @@ -837,8 +836,11 @@ func getClassMetadata(classNames string) {
// When GEN_ANNOTATION_UNSUPPORTED environment variable is set, the list of classes that don't support annotation are retrieved and annotation_unsupported.go is generated.
func genAnnotationUnsupported() []string {
classes := []string{}
_, gen_annotation_unsupported := os.LookupEnv("GEN_ANNOTATION_UNSUPPORTED")
if gen_annotation_unsupported {
genAnnotationUnsupported, err := strconv.ParseBool(os.Getenv("GEN_ANNOTATION_UNSUPPORTED"))
if err != nil {
return classes
}
if genAnnotationUnsupported {
var url string
host := os.Getenv("GEN_HOST")
if host == "" {
Expand Down Expand Up @@ -875,7 +877,7 @@ func genAnnotationUnsupported() []string {

func main() {
reGenClassMetadata()
getClassMetadata("")
getClassMetadata(os.Getenv("GEN_CLASSES"))
cleanDirectories()

definitions := getDefinitions()
Expand Down

0 comments on commit 4fe22cb

Please sign in to comment.