github.com/verrazzano/verrazzano-monitoring-operator@v0.0.30/test/integ/util/utils.go (about)

     1  // Copyright (C) 2020, 2021, Oracle and/or its affiliates.
     2  // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     3  
     4  package util
     5  
     6  import (
     7  	"fmt"
     8  	"github.com/go-resty/resty/v2"
     9  	"github.com/verrazzano/verrazzano-monitoring-operator/test/integ/framework"
    10  	"os"
    11  )
    12  
    13  // RunBeforePhase returns, based on the given framework object, whether or not to run the before phase.
    14  func RunBeforePhase(f *framework.Framework) bool {
    15  	return framework.Before == f.Phase || f.Phase == ""
    16  }
    17  
    18  // RunAfterPhase returns, based on the given framework object, whether or not to run the after phase.
    19  func RunAfterPhase(f *framework.Framework) bool {
    20  	return framework.After == f.Phase || f.Phase == ""
    21  }
    22  
    23  // SkipTeardown returns, based on the given framework object, whether or not to skip teardown
    24  func SkipTeardown(f *framework.Framework) bool {
    25  	return f.SkipTeardown || framework.Before == f.Phase
    26  }
    27  
    28  // GetClient gets a client, setting the proxy if appropriate
    29  func GetClient() *resty.Client {
    30  	restyClient := resty.New()
    31  
    32  	f := framework.Global
    33  	// Set proxy for resty client
    34  	if f.ExternalIP != "localhost" {
    35  		proxyURL := os.Getenv("http_proxy")
    36  		if proxyURL != "" {
    37  			fmt.Println("Setting proxy for resty clients to :" + proxyURL)
    38  			restyClient.SetProxy(proxyURL)
    39  		}
    40  	}
    41  	return restyClient
    42  }