func NewPartial(org, project string, envs, services, identities, instances []string) (*PathExp, *int, error) {
	orgValue := org
	if org == "" {
		orgValue = "*"
	}
	projValue := project
	if project == "" {
		projValue = "*"
	}

	pe := PathExp{
		org:     literal(orgValue),
		project: literal(projValue),
	}
	segmentCount := 0

	if org != "" && org != "*" && !slug.MatchString(org) {
		return nil, nil, errors.New("Invalid org")
	} else if org != "" {
		segmentCount++
	}

	if project != "" && project != "*" && !slug.MatchString(project) {
		return nil, nil, errors.New("Invalid project: " + project)
	} else if project != "" {
		segmentCount++
	}

	var err error

	pe.envs, err = parseMultiple("environment", envs)
	if err != nil {
		if !strings.Contains(err.Error(), "Empty") {
			return nil, nil, err
		}
		pe.envs = fullglob{}
	} else if pe.envs.String() != "" {
		segmentCount++
	}

	pe.services, err = parseMultiple("service", services)
	if err != nil {
		if !strings.Contains(err.Error(), "Empty") {
			return nil, nil, err
		}
		pe.services = fullglob{}
	} else if pe.services.String() != "" {
		segmentCount++
	}
	var originalEnv segment
	if pe.services.String() != "*" && pe.envs.String() != "*" {
		originalEnv = pe.envs
		pe.envs = fullglob{}
	}

	pe.identities, err = parseMultiple("identity", identities)
	if err != nil {
		if !strings.Contains(err.Error(), "Empty") {
			return nil, nil, err
		}
		pe.identities = fullglob{}
	} else if pe.identities.String() != "" {
		segmentCount++
	}

	pe.instances, err = parseMultiple("instance", instances)
	if err != nil {
		if !strings.Contains(err.Error(), "Empty") {
			return nil, nil, err
		}
		pe.instances = fullglob{}
	} else if pe.instances.String() != "" {
		segmentCount++
	}
	if segmentCount > 3 && originalEnv != nil {
		pe.envs = originalEnv
	}

	return &pe, &segmentCount, nil
}
// NewPartial creates a new path expression from the given path segments
// It returns an error if any of the values fail to validate
NewPartial creates a new path expression from the given path segments
It returns an error if any of the values fail to validate
// NewPartial creates a new path expression from the given path segments // It returns an error if any of the values fail to validate
func NewPartial(org, project string, envs, services, identities, instances []string) (*PathExp, *int, error) {
	orgValue := org
	if org == "" {
		orgValue = "*"
	}
	projValue := project
	if project == "" {
		projValue = "*"
	}
	pe := PathExp{
		org:     literal(orgValue),
		project: literal(projValue),
	}
	segmentCount := 0
	if org != "" && org != "*" && !slug.MatchString(org) {
		return nil, nil, errors.New("Invalid org")
	} else if org != "" {
		segmentCount++
	}
	if project != "" && project != "*" && !slug.MatchString(project) {
		return nil, nil, errors.New("Invalid project: " + project)
	} else if project != "" {
		segmentCount++
	}
	var err error
	pe.envs, err = parseMultiple("environment", envs)
	if err != nil {
		if !strings.Contains(err.Error(), "Empty") {
			return nil, nil, err
		}
		pe.envs = fullglob{}
	} else if pe.envs.String() != "" {
		segmentCount++
	}
	pe.services, err = parseMultiple("service", services)
	if err != nil {
		if !strings.Contains(err.Error(), "Empty") {
			return nil, nil, err
		}
		pe.services = fullglob{}
	} else if pe.services.String() != "" {
		segmentCount++
	}
	var originalEnv segment
	if pe.services.String() != "*" && pe.envs.String() != "*" {
		originalEnv = pe.envs
		pe.envs = fullglob{}
	}
	pe.identities, err = parseMultiple("identity", identities)
	if err != nil {
		if !strings.Contains(err.Error(), "Empty") {
			return nil, nil, err
		}
		pe.identities = fullglob{}
	} else if pe.identities.String() != "" {
		segmentCount++
	}
	pe.instances, err = parseMultiple("instance", instances)
	if err != nil {
		if !strings.Contains(err.Error(), "Empty") {
			return nil, nil, err
		}
		pe.instances = fullglob{}
	} else if pe.instances.String() != "" {
		segmentCount++
	}
	if segmentCount > 3 && originalEnv != nil {
		pe.envs = originalEnv
	}
	return &pe, &segmentCount, nil
}
func NewPartial ( org , project string , envs , services , identities , instances [ ] string ) ( * PathExp , * int , error ) { orgValue := org if org == " " { orgValue = " " } projValue := project if project == " " { projValue = " " } pe := PathExp { org : literal ( orgValue ) , project : literal ( projValue ) , } segmentCount := 0 if org != " " && org != " " && ! slug . MatchString ( org ) { return nil , nil , errors . New ( " " ) } else if org != " " { segmentCount ++ } if project != " " && project != " " && ! slug . MatchString ( project ) { return nil , nil , errors . New ( " " + project ) } else if project != " " { segmentCount ++ } var err error pe . envs , err = parseMultiple ( " " , envs ) if err != nil { if ! strings . Contains ( err . Error ( ) , " " ) { return nil , nil , err } pe . envs = fullglob { } } else if pe . envs . String ( ) != " " { segmentCount ++ } pe . services , err = parseMultiple ( " " , services ) if err != nil { if ! strings . Contains ( err . Error ( ) , " " ) { return nil , nil , err } pe . services = fullglob { } } else if pe . services . String ( ) != " " { segmentCount ++ } var originalEnv segment if pe . services . String ( ) != " " && pe . envs . String ( ) != " " { originalEnv = pe . envs pe . envs = fullglob { } } pe . identities , err = parseMultiple ( " " , identities ) if err != nil { if ! strings . Contains ( err . Error ( ) , " " ) { return nil , nil , err } pe . identities = fullglob { } } else if pe . identities . String ( ) != " " { segmentCount ++ } pe . instances , err = parseMultiple ( " " , instances ) if err != nil { if ! strings . Contains ( err . Error ( ) , " " ) { return nil , nil , err } pe . instances = fullglob { } } else if pe . instances . String ( ) != " " { segmentCount ++ } if segmentCount > 3 && originalEnv != nil { pe . envs = originalEnv } return & pe , & segmentCount , nil }
NewPartial creates a new path expression from the given path segments
It returns an error if any of the values fail to validate
NewPartial creates a new path expression from the given path segments It returns an error if any of the values fail to validate