func ParsePlacement(directive string) (*Placement, error) {
	if directive == "" {
		return nil, nil
	}
	if colon := strings.IndexRune(directive, ':'); colon != -1 {
		scope, directive := directive[:colon], directive[colon+1:]
		if scope == "" {
			return nil, ErrPlacementScopeMissing
		}
		// Sanity check: machine/container scopes require a machine ID as the value.
		if (scope == MachineScope || isContainerType(scope)) && !names.IsValidMachine(directive) {
			return nil, fmt.Errorf("invalid value %q for %q scope: expected machine-id", directive, scope)
		}
		return &Placement{Scope: scope, Directive: directive}, nil
	}
	if names.IsValidMachine(directive) {
		return &Placement{Scope: MachineScope, Directive: directive}, nil
	}
	if isContainerType(directive) {
		return &Placement{Scope: directive}, nil
	}
	return nil, ErrPlacementScopeMissing
}
// ParsePlacement attempts to parse the specified string and create a
// corresponding Placement structure.
//
// If the placement directive is non-empty and missing a scope,
// ErrPlacementScopeMissing will be returned as well as a Placement
// with an empty Scope field.
ParsePlacement attempts to parse the specified string and create a
corresponding Placement structure.

If the placement directive is non-empty and missing a scope,
ErrPlacementScopeMissing will be returned as well as a Placement
with an empty Scope field.
// ParsePlacement attempts to parse the specified string and create a // corresponding Placement structure . // // If the placement directive is non - empty and missing a scope // ErrPlacementScopeMissing will be returned as well as a Placement // with an empty Scope field .
func ParsePlacement(directive string) (*Placement, error) {
	if directive == "" {
		return nil, nil
	}
	if colon := strings.IndexRune(directive, ':'); colon != -1 {
		scope, directive := directive[:colon], directive[colon+1:]
		if scope == "" {
			return nil, ErrPlacementScopeMissing
		}
		if (scope == MachineScope || isContainerType(scope)) && !names.IsValidMachine(directive) {
			return nil, fmt.Errorf("invalid value %q for %q scope: expected machine-id", directive, scope)
		}
		return &Placement{Scope: scope, Directive: directive}, nil
	}
	if names.IsValidMachine(directive) {
		return &Placement{Scope: MachineScope, Directive: directive}, nil
	}
	if isContainerType(directive) {
		return &Placement{Scope: directive}, nil
	}
	return nil, ErrPlacementScopeMissing
}
func ParsePlacement ( directive string ) ( * Placement , error ) { if directive == " " { return nil , nil } if colon := strings . IndexRune ( directive , ':' ) ; colon != - 1 { scope , directive := directive [ : colon ] , directive [ colon + 1 : ] if scope == " " { return nil , ErrPlacementScopeMissing } if ( scope == MachineScope || isContainerType ( scope ) ) && ! names . IsValidMachine ( directive ) { return nil , fmt . Errorf ( " " , directive , scope ) } return & Placement { Scope : scope , Directive : directive } , nil } if names . IsValidMachine ( directive ) { return & Placement { Scope : MachineScope , Directive : directive } , nil } if isContainerType ( directive ) { return & Placement { Scope : directive } , nil } return nil , ErrPlacementScopeMissing }
ParsePlacement attempts to parse the specified string and create a
corresponding Placement structure.
ParsePlacement attempts to parse the specified string and create a corresponding Placement structure .
// Sanity check: machine/container scopes require a machine ID as the value.