// utility function to fill in the Base fields under PipelineRun
518949
func (run *PipelineRun) update() {
	href := run.URLs["self"]["href"]
	if matches := baseURLRegex.FindStringSubmatch(href); len(matches) > 1 {
		run.Base = matches[1]
	}
	for i := range run.Stages {
		run.Stages[i].Run = run
		href := run.Stages[i].URLs["self"]["href"]
		if matches := baseURLRegex.FindStringSubmatch(href); len(matches) > 1 {
			run.Stages[i].Base = matches[1]
		}
	}
}
993100
func (p *gateway) Pipeline() int64 {
	var totalForwarded int64
	for _, f := range p.forwarders {
		totalForwarded += f.Pipeline()
	}
	return totalForwarded
}
832194
func (s *StartChannelOutput) SetPipelinesRunningCount(v int64) *StartChannelOutput {
	s.PipelinesRunningCount = &v
	return s
}
1084872
func (c *Config) Pipeline(spec *yaml.Config) *Pipeline {

	pipeline := Pipeline{
		engine: c.Engine,
		pipe:   make(chan *Line, c.Buffer),
		next:   make(chan error),
		done:   make(chan error),
	}

	var containers []*yaml.Container
	containers = append(containers, spec.Services...)
	containers = append(containers, spec.Pipeline...)

	for _, c := range containers {
		if c.Disabled {
			continue
		}
		next := &element{Container: c}
		if pipeline.head == nil {
			pipeline.head = next
			pipeline.tail = next
		} else {
			pipeline.tail.next = next
			pipeline.tail = next
		}
	}

	go func() {
		pipeline.next <- nil
	}()

	return &pipeline
}
55009
func (s *UpdateByQueryService) FielddataFields(fielddataFields ...string) *UpdateByQueryService {
	s.fielddataFields = append(s.fielddataFields, fielddataFields...)
	return s
}
1344387
func (env *EnvironmentItemModel) FillMissingDefaults() error {
	options, err := env.GetOptions()
	if err != nil {
		return err
	}
	if options.Title == nil {
		options.Title = pointers.NewStringPtr("")
	}
	if options.Description == nil {
		options.Description = pointers.NewStringPtr("")
	}
	if options.Summary == nil {
		options.Summary = pointers.NewStringPtr("")
	}
	if options.Category == nil {
		options.Category = pointers.NewStringPtr("")
	}
	if options.ValueOptions == nil {
		options.ValueOptions = []string{}
	}
	if options.IsRequired == nil {
		options.IsRequired = pointers.NewBoolPtr(DefaultIsRequired)
	}
	if options.IsExpand == nil {
		options.IsExpand = pointers.NewBoolPtr(DefaultIsExpand)
	}
	if options.IsSensitive == nil {
		options.IsSensitive = pointers.NewBoolPtr(DefaultIsSensitive)
	}
	if options.IsDontChangeValue == nil {
		options.IsDontChangeValue = pointers.NewBoolPtr(DefaultIsDontChangeValue)
	}
	if options.IsTemplate == nil {
		options.IsTemplate = pointers.NewBoolPtr(DefaultIsTemplate)
	}
	if options.SkipIfEmpty == nil {
		options.SkipIfEmpty = pointers.NewBoolPtr(DefaultSkipIfEmpty)
	}
	if options.Meta == nil {
		options.Meta = map[string]interface{}{}
	}
	if options.Unset == nil {
		options.Unset = pointers.NewBoolPtr(DefaultUnset)
	}

	(*env)[OptionsKey] = options
	return nil
}
110206
func (s *Service) PipelineInfo(ctx context.Context, pipelineIdentity string) (*Pipeline, error) {
	var pipeline Pipeline
	return &pipeline, s.Get(ctx, &pipeline, fmt.Sprintf("/pipelines/%v", pipelineIdentity), nil, nil)
}
112911
func (u *DockerRegistryURL) baseString(includeCredentials bool) string {
	var base string
	if includeCredentials {
		base = u.BaseURL()
	} else {
		base = u.BaseURLNoCredentials()
	}

	s := u.Path()
	if s == "" {
		return base
	} else {
		return fmt.Sprintf("%s/%s", base, s)
	}
}
154954
func (s *UpdateByQueryService) Pipeline(pipeline string) *UpdateByQueryService {
	s.pipeline = pipeline
	return s
}
911311
func (p *Parser) overwriteFields(v reflect.Value, fullpath string, path []string, payload string) error {
	for v.Kind() == reflect.Ptr {
		if v.IsNil() {
			panic("encountered nil pointer while handling environment variable " + fullpath)
		}
		v = reflect.Indirect(v)
	}
	switch v.Kind() {
	case reflect.Struct:
		return p.overwriteStruct(v, fullpath, path, payload)
	case reflect.Map:
		return p.overwriteMap(v, fullpath, path, payload)
	case reflect.Interface:
		if v.NumMethod() == 0 {
			if !v.IsNil() {
				return p.overwriteFields(v.Elem(), fullpath, path, payload)
			}
			// Interface was empty; create an implicit map
			var template map[string]interface{}
			wrappedV := reflect.MakeMap(reflect.TypeOf(template))
			v.Set(wrappedV)
			return p.overwriteMap(wrappedV, fullpath, path, payload)
		}
	}
	return nil
}
917820
func updatePipelineConfigCommand() *cli.Command {
	return &cli.Command{
		Name:     UpdatePipelineConfigCommandName,
		Usage:    UpdatePipelineConfigCommandUsage,
		Action:   ActionWrapper(updatePipelineConfigAction),
		Category: "Pipeline Configs",
		Flags: []cli.Flag{
			cli.StringFlag{Name: "name"},
			cli.StringFlag{Name: "pipeline-version"},
			cli.StringFlag{Name: "pipeline"},
			cli.StringFlag{Name: "pipeline-file"},
		},
	}
}
974205
func createPipelineConfigAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
	group := c.String("group")
	if group == "" {
		return nil, nil, NewFlagError("group")
	}

	pipeline := c.String("pipeline-json")
	pipelineFile := c.String("pipeline-file")
	if pipeline == "" && pipelineFile == "" {
		return nil, nil, errors.New("One of '--pipeline-file' or '--pipeline-json' must be specified")
	}

	if pipeline != "" && pipelineFile != "" {
		return nil, nil, errors.New("Only one of '--pipeline-file' or '--pipeline-json' can be specified")
	}

	var pf []byte
	if pipelineFile != "" {
		pf, err = ioutil.ReadFile(pipelineFile)
		if err != nil {
			return nil, nil, err
		}
	} else {
		pf = []byte(pipeline)
	}
	p := &gocd.Pipeline{}
	err = json.Unmarshal(pf, &p)
	if err != nil {
		return nil, nil, err
	}

	return client.PipelineConfigs.Create(context.Background(), group, p)
}
1123423
func buildBaseRegisterOpts(config *Config, sourceImage *ec2.Image, rootVolumeSize int64, snapshotID string) *ec2.RegisterImageInput {
	var (
		mappings       []*ec2.BlockDeviceMapping
		rootDeviceName string
	)

	generatingNewBlockDeviceMappings := config.FromScratch || len(config.AMIMappings) > 0
	if generatingNewBlockDeviceMappings {
		mappings = config.AMIBlockDevices.BuildAMIDevices()
		rootDeviceName = config.RootDeviceName
	} else {
		// If config.FromScratch is false, source image must be set
		mappings = sourceImage.BlockDeviceMappings
		rootDeviceName = *sourceImage.RootDeviceName
	}

	newMappings := make([]*ec2.BlockDeviceMapping, len(mappings))
	for i, device := range mappings {
		newDevice := device
		if *newDevice.DeviceName == rootDeviceName {
			if newDevice.Ebs != nil {
				newDevice.Ebs.SnapshotId = aws.String(snapshotID)
			} else {
				newDevice.Ebs = &ec2.EbsBlockDevice{SnapshotId: aws.String(snapshotID)}
			}

			if generatingNewBlockDeviceMappings || rootVolumeSize > *newDevice.Ebs.VolumeSize {
				newDevice.Ebs.VolumeSize = aws.Int64(rootVolumeSize)
			}
		}

		// assume working from a snapshot, so we unset the Encrypted field if set,
		// otherwise AWS API will return InvalidParameter
		if newDevice.Ebs != nil && newDevice.Ebs.Encrypted != nil {
			newDevice.Ebs.Encrypted = nil
		}

		newMappings[i] = newDevice
	}

	if config.FromScratch {
		return &ec2.RegisterImageInput{
			Name:                &config.AMIName,
			Architecture:        aws.String(ec2.ArchitectureValuesX8664),
			RootDeviceName:      aws.String(rootDeviceName),
			VirtualizationType:  aws.String(config.AMIVirtType),
			BlockDeviceMappings: newMappings,
		}
	}

	return buildRegisterOptsFromExistingImage(config, sourceImage, newMappings, rootDeviceName)
}
13033
func (source *source) addBaseProfiles(flagBase, flagDiffBase []*string) error {
	base, diffBase := dropEmpty(flagBase), dropEmpty(flagDiffBase)
	if len(base) > 0 && len(diffBase) > 0 {
		return errors.New("-base and -diff_base flags cannot both be specified")
	}

	source.Base = base
	if len(diffBase) > 0 {
		source.Base, source.DiffBase = diffBase, true
	}
	return nil
}
458564
func PluginParams(conf *yaml.Config) error {
	for _, container := range conf.Pipeline {
		if len(container.Vargs) == 0 {
			continue
		}
		if container.Environment == nil {
			container.Environment = map[string]string{}
		}
		err := argsToEnv(container.Vargs, container.Environment)
		if err != nil {
			return err
		}
	}
	return nil
}
1125229
func applyFields(event EventBuilder, values []interface{}) EventBuilder {
	for _, v := range values {
		switch t := v.(type) {
		case string:
			event = event.String(t)
		case []byte:
			event = event.String(string(t))
		default:
			panic(fmt.Sprintf("Expected string or field when creating an event, got %T", v))
		}
	}

	return event
}
1105583
func baseProcess(lc fx.Lifecycle) goprocess.Process {
	p := goprocess.WithParent(goprocess.Background())
	lc.Append(fx.Hook{
		OnStop: func(_ context.Context) error {
			return p.Close()
		},
	})
	return p
}