get.porter.sh/porter@v1.3.0/pkg/runtime/context.go (about)

     1  package runtime
     2  
     3  import (
     4  	"context"
     5  	"strconv"
     6  
     7  	"get.porter.sh/porter/pkg/config"
     8  )
     9  
    10  // RuntimeConfig is a specialized config.Config with additional runtime-specific settings.
    11  type RuntimeConfig struct {
    12  	*config.Config
    13  
    14  	// DebugMode indicates if the bundle is running in debug mode.
    15  	DebugMode bool
    16  }
    17  
    18  // NewConfig returns an initialized RuntimeConfig
    19  func NewConfig() RuntimeConfig {
    20  	return NewConfigFor(config.New())
    21  }
    22  
    23  // NewConfigFor returns an initialized RuntimeConfig using the specified context.
    24  func NewConfigFor(config *config.Config) RuntimeConfig {
    25  	debug, _ := strconv.ParseBool(config.Getenv("PORTER_DEBUG"))
    26  	return RuntimeConfig{
    27  		DebugMode: debug,
    28  		Config:    config,
    29  	}
    30  }
    31  
    32  func (c RuntimeConfig) ConfigureLogging(ctx context.Context) (context.Context, error) {
    33  	// Just use porter's config to load up common settings, such as logging
    34  	pc := config.NewFor(c.Context)
    35  	return pc.Load(ctx, nil)
    36  }