// BindMasterArgs binds the options to the flags with prefix + default flag names
173209
func BindMasterArgs(args *MasterArgs, flags *pflag.FlagSet, prefix string) {
	flags.Var(&args.MasterAddr, prefix+"master", "The master address for use by OpenShift components (host, host:port, or URL). Scheme and port default to the --listen scheme and port. When unset, attempt to use the first public IPv4 non-loopback address registered on this host.")
	flags.Var(&args.MasterPublicAddr, prefix+"public-master", "The master address for use by public clients, if different (host, host:port, or URL). Defaults to same as --master.")
	flags.Var(&args.EtcdAddr, prefix+"etcd", "The address of the etcd server (host, host:port, or URL). If specified, no built-in etcd will be started.")
	flags.Var(&args.DNSBindAddr, prefix+"dns", "The address to listen for DNS requests on.")

	flags.StringVar(&args.EtcdDir, prefix+"etcd-dir", "openshift.local.etcd", "The etcd data directory.")

	flags.StringSliceVar(&args.APIServerCAFiles, prefix+"certificate-authority", args.APIServerCAFiles, "Optional files containing signing authorities to use (in addition to the generated signer) to verify the API server's serving certificate.")

	flags.StringSliceVar(&args.CORSAllowedOrigins, prefix+"cors-allowed-origins", []string{}, "List of allowed origins for CORS, comma separated.  An allowed origin can be a regular expression to support subdomain matching.  CORS is enabled for localhost, 127.0.0.1, and the asset server by default.")

	// autocompletion hints
	cobra.MarkFlagFilename(flags, prefix+"etcd-dir")
	cobra.MarkFlagFilename(flags, prefix+"certificate-authority")
}
407903
func (o *FilterOptions) Bind(flags *pflag.FlagSet) {
	flags.StringVar(&o.FilterByOS, "filter-by-os", o.FilterByOS, "A regular expression to control which images are considered when multiple variants are available. Images will be passed as '<platform>/<architecture>[/<variant>]'.")
}
472874
func (db *DB) BindNamed(query string, arg interface{}) (string, []interface{}, error) {
	return bindNamedMapper(BindType(db.driverName), query, arg, db.Mapper)
}
1121711
func (q *Queryx) BindStruct(arg interface{}) *Queryx {
	arglist, err := bindStructArgs(q.Names, arg, nil, q.Mapper)
	if err != nil {
		q.err = fmt.Errorf("bind error: %s", err)
	} else {
		q.err = nil
		q.Bind(arglist...)
	}

	return q
}
63995
func (c *Conn) SetMasterCommand(params *ConnParams, masterHost string, masterPort int, masterConnectRetry int) string {
	args := []string{
		fmt.Sprintf("MASTER_HOST = '%s'", masterHost),
		fmt.Sprintf("MASTER_PORT = %d", masterPort),
		fmt.Sprintf("MASTER_USER = '%s'", params.Uname),
		fmt.Sprintf("MASTER_PASSWORD = '%s'", params.Pass),
		fmt.Sprintf("MASTER_CONNECT_RETRY = %d", masterConnectRetry),
	}
	if params.SslEnabled() {
		args = append(args, "MASTER_SSL = 1")
	}
	if params.SslCa != "" {
		args = append(args, fmt.Sprintf("MASTER_SSL_CA = '%s'", params.SslCa))
	}
	if params.SslCaPath != "" {
		args = append(args, fmt.Sprintf("MASTER_SSL_CAPATH = '%s'", params.SslCaPath))
	}
	if params.SslCert != "" {
		args = append(args, fmt.Sprintf("MASTER_SSL_CERT = '%s'", params.SslCert))
	}
	if params.SslKey != "" {
		args = append(args, fmt.Sprintf("MASTER_SSL_KEY = '%s'", params.SslKey))
	}
	args = append(args, c.flavor.changeMasterArg())
	return "CHANGE MASTER TO\n  " + strings.Join(args, ",\n  ")
}
1315850
func (b *BuildArgs) AddArg(key string, value *string) {
	b.allowedBuildArgs[key] = value
	b.referencedArgs[key] = struct{}{}
}
1281756
func (r *PropResult) AddArgs(args ...*PropArg) *PropResult {
	r.Args = append(r.Args, args...)
	return r
}
68267
func (m *Master) SubmitArgs(filename, mimeType string, file io.Reader, args url.Values) (fid string, size int64, err error) {
	data, contentType, err := makeFormData(filename, mimeType, file)
	if err != nil {
		return
	}

	u := url.URL{
		Scheme:   "http",
		Host:     m.Url,
		Path:     "/submit",
		RawQuery: args.Encode(),
	}

	resp, err := upload(u.String(), contentType, data)
	if err == nil {
		fid = resp.Fid
		size = resp.Size
	}

	return
}
965760
func (*PreparedQueryIndex) PrefixFromArgs(args ...interface{}) ([]byte, error) {
	if len(args) != 1 {
		return nil, fmt.Errorf("must provide only a single argument")
	}
	arg, ok := args[0].(string)
	if !ok {
		return nil, fmt.Errorf("argument must be a string: %#v", args[0])
	}
	arg = "\x00" + strings.ToLower(arg)
	return []byte(arg), nil
}
524076
func (args MasterArgs) BuildSerializeableKubeMasterConfig() (*configapi.KubernetesMasterConfig, error) {
	masterAddr, err := args.GetMasterAddress()
	if err != nil {
		return nil, err
	}
	masterHost, _, err := net.SplitHostPort(masterAddr.Host)
	if err != nil {
		masterHost = masterAddr.Host
	}
	masterIP := ""
	if ip := net.ParseIP(masterHost); ip != nil {
		masterIP = ip.String()
	}

	config := &configapi.KubernetesMasterConfig{
		MasterIP:            masterIP,
		ServicesSubnet:      args.NetworkArgs.ServiceNetworkCIDR,
		SchedulerConfigFile: args.SchedulerConfigFile,
		ProxyClientInfo:     admin.DefaultProxyClientCertInfo(args.ConfigDir.Value()).CertLocation,
	}

	return config, nil
}
374288
func (launcher *Launcher) GetArgs() []string {
	launcher.Mutex.RLock()
	args := launcher.args
	launcher.Mutex.RUnlock()
	return args
}
645414
func (s *ServiceBroker) Bind(instanceID, bindingID string, details brokerapi.BindDetails) (brokerapi.Binding, error) {
	serviceBinding := NewServiceBinding()
	serviceBinding.SetInstanceID(instanceID)
	serviceBinding.SetBindingID(bindingID)
	serviceBinding.SetBindDetails(details)
	serviceBinding.SetActive(true)
	err := s.save(serviceBinding)
	return brokerapi.Binding{}, err
}
235885
func BindNamed(bindType int, query string, arg interface{}) (string, []interface{}, error) {
	return bindNamedMapper(bindType, query, arg, mapper())
}
214936
func (stmt *OCI8Stmt) bind(ctx context.Context, args []namedValue) ([]oci8Bind, error) {
	if len(args) == 0 {
		return nil, nil
	}

	var binds []oci8Bind
	var err error

	for i, arg := range args {
		var sbind oci8Bind
		sbind.length = (*C.ub2)(C.malloc(C.sizeof_ub2))
		*sbind.length = 0
		sbind.indicator = (*C.sb2)(C.malloc(C.sizeof_sb2))
		*sbind.indicator = 0

		argInterface := arg.Value
		var isOut bool
		var isNill bool
		sbind.out, isOut = argInterface.(sql.Out)
		if isOut {
			argInterface, err = driver.DefaultParameterConverter.ConvertValue(sbind.out.Dest)
			if err != nil {
				binds = append(binds, sbind)
				freeBinds(binds)
				return nil, err
			}
			switch argInterface.(type) {
			case nil:
				isNill = true
				argInterface = sbind.out.Dest
				switch argInterface.(type) {
				case *sql.NullBool:
					argInterface = false
				case *sql.NullFloat64:
					argInterface = float64(0)
				case *sql.NullInt64:
					argInterface = int64(0)
				case *sql.NullString:
					argInterface = ""
				}
			}
		}

		switch argValue := argInterface.(type) {

		case nil:
			sbind.dataType = C.SQLT_AFC
			sbind.pbuf = nil
			sbind.maxSize = 0
			*sbind.indicator = -1 // set to null

		case []byte:
			if isOut {

				sbind.dataType = C.SQLT_BIN
				sbind.pbuf = unsafe.Pointer(cByteN(argValue, 32768))
				sbind.maxSize = 32767
				if sbind.out.In && !isNill {
					*sbind.length = C.ub2(len(argValue))
				} else {
					*sbind.indicator = -1 // set to null
				}

			} else {
				sbind.dataType = C.SQLT_BIN
				sbind.pbuf = unsafe.Pointer(cByte(argValue))
				sbind.maxSize = C.sb4(len(argValue))
				*sbind.length = C.ub2(len(argValue))
			}

		case time.Time:
			sbind.dataType = C.SQLT_TIMESTAMP_TZ
			sbind.maxSize = C.sb4(sizeOfNilPointer)
			*sbind.length = C.ub2(sizeOfNilPointer)

			// TODO: wrap up date time construction into Go function

			var timestampP *unsafe.Pointer
			timestampP, _, err = stmt.conn.ociDescriptorAlloc(C.OCI_DTYPE_TIMESTAMP_TZ, 0)
			if err != nil {
				binds = append(binds, sbind)
				freeBinds(binds)
				return nil, err
			}
			pt := unsafe.Pointer(timestampP)

			zone, offset := argValue.Zone()
			size := len(zone)
			if size < 16 {
				size = 16
			}
			zoneText := cStringN(zone, size)
			defer C.free(unsafe.Pointer(zoneText))

			tryagain := false

			rv := C.OCIDateTimeConstruct(
				unsafe.Pointer(stmt.conn.env),
				stmt.conn.errHandle,
				(*C.OCIDateTime)(*(*unsafe.Pointer)(pt)),
				C.sb2(argValue.Year()),
				C.ub1(argValue.Month()),
				C.ub1(argValue.Day()),
				C.ub1(argValue.Hour()),
				C.ub1(argValue.Minute()),
				C.ub1(argValue.Second()),
				C.ub4(argValue.Nanosecond()),
				zoneText,
				C.size_t(len(zone)),
			)
			if rv != C.OCI_SUCCESS {
				tryagain = true
			} else {
				// check if oracle timezone offset is same ?
				rvz := C.WrapOCIDateTimeGetTimeZoneNameOffset(
					stmt.conn.env,
					stmt.conn.errHandle,
					(*C.OCIDateTime)(*(*unsafe.Pointer)(pt)))
				if rvz.rv != C.OCI_SUCCESS {
					binds = append(binds, sbind)
					freeBinds(binds)
					return nil, stmt.conn.getError(rvz.rv)
				}
				if offset != int(rvz.h)*60*60+int(rvz.m)*60 {
					// fmt.Println("oracle timezone offset dont match", zone, offset, int(rvz.h)*60*60+int(rvz.m)*60)
					tryagain = true
				}
			}

			if tryagain {
				sign := '+'
				if offset < 0 {
					offset = -offset
					sign = '-'
				}
				offset /= 60
				// oracle accept zones "[+-]hh:mm", try second time
				zone = fmt.Sprintf("%c%02d:%02d", sign, offset/60, offset%60)
				if size < len(zone) {
					size = len(zone)
					zoneText = cStringN(zone, size)
					defer C.free(unsafe.Pointer(zoneText))
				} else {
					copy((*[1 << 30]byte)(unsafe.Pointer(zoneText))[:len(zone)], zone)
				}

				rv := C.OCIDateTimeConstruct(
					unsafe.Pointer(stmt.conn.env),
					stmt.conn.errHandle,
					(*C.OCIDateTime)(*(*unsafe.Pointer)(pt)),
					C.sb2(argValue.Year()),
					C.ub1(argValue.Month()),
					C.ub1(argValue.Day()),
					C.ub1(argValue.Hour()),
					C.ub1(argValue.Minute()),
					C.ub1(argValue.Second()),
					C.ub4(argValue.Nanosecond()),
					zoneText,
					C.size_t(len(zone)),
				)
				if rv != C.OCI_SUCCESS {
					binds = append(binds, sbind)
					freeBinds(binds)
					return nil, stmt.conn.getError(rv)
				}
			}

			sbind.pbuf = unsafe.Pointer((*C.char)(pt))

		case string:
			if isOut {

				sbind.dataType = C.SQLT_CHR
				sbind.pbuf = unsafe.Pointer(cStringN(argValue, 32768))
				sbind.maxSize = 32767
				if sbind.out.In && !isNill {
					*sbind.length = C.ub2(len(argValue))
				} else {
					*sbind.indicator = -1 // set to null
				}

			} else {
				sbind.dataType = C.SQLT_AFC
				sbind.pbuf = unsafe.Pointer(C.CString(argValue))
				sbind.maxSize = C.sb4(len(argValue))
				*sbind.length = C.ub2(len(argValue))
			}

		case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, uintptr:
			buffer := bytes.Buffer{}
			err = binary.Write(&buffer, binary.LittleEndian, argValue)
			if err != nil {
				return nil, fmt.Errorf("binary read for column %v - error: %v", i, err)
			}
			sbind.dataType = C.SQLT_INT
			sbind.pbuf = unsafe.Pointer(cByte(buffer.Bytes()))
			sbind.maxSize = C.sb4(buffer.Len())
			*sbind.length = C.ub2(buffer.Len())
			if isOut && sbind.out.In && isNill {
				*sbind.indicator = -1 // set to null
			}

		case float32, float64:
			buffer := bytes.Buffer{}
			err = binary.Write(&buffer, binary.LittleEndian, argValue)
			if err != nil {
				return nil, fmt.Errorf("binary read for column %v - error: %v", i, err)
			}
			sbind.dataType = C.SQLT_BDOUBLE
			sbind.pbuf = unsafe.Pointer(cByte(buffer.Bytes()))
			sbind.maxSize = C.sb4(buffer.Len())
			*sbind.length = C.ub2(buffer.Len())
			if isOut && sbind.out.In && isNill {
				*sbind.indicator = -1 // set to null
			}

		case bool: // oracle does not have bool, handle as 0/1 int
			sbind.dataType = C.SQLT_INT
			if argValue {
				sbind.pbuf = unsafe.Pointer(cByte([]byte{1}))
			} else {
				sbind.pbuf = unsafe.Pointer(cByte([]byte{0}))
			}
			sbind.maxSize = 1
			*sbind.length = 1
			if isOut && sbind.out.In && isNill {
				*sbind.indicator = -1 // set to null
			}

		default:
			if isOut {
				// TODO: should this error instead of setting to null?
				sbind.dataType = C.SQLT_AFC
				sbind.pbuf = nil
				sbind.maxSize = 0
				*sbind.length = 0
				*sbind.indicator = -1 // set to null
			} else {
				d := fmt.Sprintf("%v", argValue)
				sbind.dataType = C.SQLT_AFC
				sbind.pbuf = unsafe.Pointer(C.CString(d))
				sbind.maxSize = C.sb4(len(d))
				*sbind.length = C.ub2(len(d))
			}
		}

		// add to binds now so if error will be freed by freeBinds call
		binds = append(binds, sbind)

		if arg.Name != "" {
			err = stmt.ociBindByName([]byte(":"+arg.Name), &sbind)
		} else {
			err = stmt.ociBindByPos(C.ub4(i+1), &sbind)
		}
		if err != nil {
			freeBinds(binds)
			return nil, err
		}

	}

	return binds, nil
}
1201480
func (a *Application) updateMasterConfig(current *Settings, validChanges charm.Settings) error {
	for name, value := range validChanges {
		if value == nil {
			current.Delete(name)
		} else {
			current.Set(name, value)
		}
	}
	_, err := current.Write()
	return errors.Trace(err)
}
412243
func (r *PropResult) WithArgs(args []*PropArg) *PropResult {
	r.Args = args
	return r
}
675842
func (args MasterArgs) GetMasterAddress() (*url.URL, error) {
	if args.MasterAddr.Provided {
		return args.MasterAddr.URL, nil
	}

	// Use the bind port by default
	port := args.ListenArg.ListenAddr.Port

	// Use the bind scheme by default
	scheme := args.ListenArg.ListenAddr.URL.Scheme

	addr := ""
	if ip, err := cmdutil.DefaultLocalIP4(); err == nil {
		addr = ip.String()
	} else if err == cmdutil.ErrorNoDefaultIP {
		addr = "127.0.0.1"
	} else if err != nil {
		return nil, fmt.Errorf("Unable to find a public IP address: %v", err)
	}

	masterAddr := scheme + "://" + net.JoinHostPort(addr, strconv.Itoa(port))
	return url.Parse(masterAddr)
}