...

Source file src/github.com/chaos-mesh/chaos-mesh/controllers/chaosimpl/httpchaos/podhttpchaosmanager/builder.go

Documentation: github.com/chaos-mesh/chaos-mesh/controllers/chaosimpl/httpchaos/podhttpchaosmanager

     1  // Copyright 2021 Chaos Mesh Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package podhttpchaosmanager
    15  
    16  import (
    17  	"github.com/go-logr/logr"
    18  	"go.uber.org/fx"
    19  	"k8s.io/apimachinery/pkg/runtime"
    20  	"k8s.io/apimachinery/pkg/types"
    21  	"sigs.k8s.io/controller-runtime/pkg/client"
    22  )
    23  
    24  type Builder struct {
    25  	Log logr.Logger
    26  	client.Client
    27  	client.Reader
    28  	scheme *runtime.Scheme
    29  }
    30  
    31  type Params struct {
    32  	fx.In
    33  
    34  	Logger logr.Logger
    35  	Client client.Client
    36  	Reader client.Reader `name:"no-cache"`
    37  	Scheme *runtime.Scheme
    38  }
    39  
    40  func NewBuilder(params Params) *Builder {
    41  	return &Builder{
    42  		Log:    params.Logger,
    43  		Client: params.Client,
    44  		Reader: params.Reader,
    45  		scheme: params.Scheme,
    46  	}
    47  }
    48  
    49  func (b *Builder) WithInit(source string, key types.NamespacedName) *PodHttpManager {
    50  	t := &PodHttpTransaction{}
    51  	t.Clear(source)
    52  
    53  	return &PodHttpManager{
    54  		Source: source,
    55  		Log:    b.Log,
    56  		Client: b.Client,
    57  		Reader: b.Reader,
    58  		scheme: b.scheme,
    59  
    60  		Key: key,
    61  		T:   t,
    62  	}
    63  }
    64