github.com/weaviate/weaviate@v1.24.6/test/helper/init.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  package helper
    13  
    14  // This file contains the init() function for the helper package.
    15  // In go, each package can have an init() function that runs whenever a package is "imported" in a program, before
    16  // the main function runs.
    17  //
    18  // In our case, we use it to parse additional flags that are used to configure the helper to point to the right
    19  // Weaviate instance, with the correct key and token.
    20  
    21  import (
    22  	"fmt"
    23  
    24  	"github.com/go-openapi/runtime"
    25  )
    26  
    27  // Configuration flags provided by the user that runs an acceptance test.
    28  var (
    29  	ServerPort   string
    30  	ServerHost   string
    31  	ServerScheme string
    32  	DebugHTTP    bool
    33  )
    34  
    35  // Credentials for the root key
    36  var RootAuth runtime.ClientAuthInfoWriterFunc
    37  
    38  func init() {
    39  	if ServerScheme == "" {
    40  		ServerScheme = "http"
    41  	}
    42  
    43  	if ServerPort == "" {
    44  		ServerPort = "8080"
    45  	}
    46  
    47  	RootAuth = nil
    48  }
    49  
    50  func GetWeaviateURL() string {
    51  	return fmt.Sprintf("%s://%s:%s", ServerScheme, ServerHost, ServerPort)
    52  }