当前位置: 首页>>代码示例>>Golang>>正文


Golang Resource.Params方法代码示例

本文整理汇总了Golang中github.com/jrperritt/rack/handler.Resource.Params方法的典型用法代码示例。如果您正苦于以下问题:Golang Resource.Params方法的具体用法?Golang Resource.Params怎么用?Golang Resource.Params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/jrperritt/rack/handler.Resource的用法示例。


在下文中一共展示了Resource.Params方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: HandleFlags

func (command *commandUpload) HandleFlags(resource *handler.Resource) error {
	err := command.Ctx.CheckFlagsSet([]string{"container", "name"})
	if err != nil {
		return err
	}

	c := command.Ctx.CLIContext

	opts := osObjects.CreateOpts{
		ContentLength: int64(c.Int("content-length")),
		ContentType:   c.String("content-type"),
	}

	if c.IsSet("content-encoding") && c.String("content-encoding") != "gzip" {
		opts.ContentEncoding = c.String("content-encoding")
	}

	resource.Params = &paramsUpload{
		container: c.String("container"),
		object:    c.String("name"),
		opts:      opts,
	}

	return nil
}
开发者ID:hdansou,项目名称:rack,代码行数:25,代码来源:upload.go

示例2: HandleFlags

func (command *commandGetMetadata) HandleFlags(resource *handler.Resource) error {
	serverID, err := command.Ctx.IDOrName(osServers.IDFromName)
	resource.Params = &paramsGetMetadata{
		serverID: serverID,
	}
	return err
}
开发者ID:harshalhshah,项目名称:rack,代码行数:7,代码来源:getmetadata.go

示例3: HandleFlags

func (command *commandList) HandleFlags(resource *handler.Resource) error {
	c := command.Ctx.CLIContext
	opts := &osNetworks.ListOpts{
		Name:     c.String("name"),
		TenantID: c.String("tenant-id"),
		Status:   c.String("status"),
		Marker:   c.String("marker"),
		Limit:    c.Int("limit"),
	}
	if c.IsSet("up") {
		upRaw := c.String("up")
		up, err := strconv.ParseBool(upRaw)
		if err != nil {
			return fmt.Errorf("Invalid value for flag `up`: %s. Options are: true, false", upRaw)
		}
		opts.AdminStateUp = &up
	}
	if c.IsSet("shared") {
		sharedRaw := c.String("shared")
		shared, err := strconv.ParseBool(sharedRaw)
		if err != nil {
			return fmt.Errorf("Invalid value for flag `shared`: %s. Options are: true, false", sharedRaw)
		}
		opts.Shared = &shared
	}
	resource.Params = &paramsList{
		opts:     opts,
		allPages: c.Bool("all-pages"),
	}
	return nil
}
开发者ID:harshalhshah,项目名称:rack,代码行数:31,代码来源:list.go

示例4: HandleFlags

func (command *commandUpdate) HandleFlags(resource *handler.Resource) error {
	c := command.Ctx.CLIContext

	err := command.Ctx.CheckFlagsSet([]string{"name"})
	if err != nil {
		return err
	}

	opts := containers.UpdateOpts{
		ContainerRead:  c.String("container-read"),
		ContainerWrite: c.String("container-write"),
	}
	if c.IsSet("metadata") {
		metadata, err := command.Ctx.CheckKVFlag("metadata")
		if err != nil {
			return err
		}
		opts.Metadata = metadata
	}
	resource.Params = &paramsUpdate{
		container: c.String("name"),
		opts:      opts,
	}
	return nil
}
开发者ID:stephamon,项目名称:rack,代码行数:25,代码来源:update.go

示例5: HandleFlags

func (command *commandList) HandleFlags(resource *handler.Resource) error {
	c := command.Ctx.CLIContext
	opts := &osSubnets.ListOpts{
		Name:      c.String("name"),
		NetworkID: c.String("network-id"),
		IPVersion: c.Int("ip-version"),
		GatewayIP: c.String("gateway-ip"),
		TenantID:  c.String("tenant-id"),
		CIDR:      c.String("cidr"),
		Marker:    c.String("marker"),
		Limit:     c.Int("limit"),
	}
	if c.IsSet("enable-dhcp") {
		dhcpRaw := c.String("enable-dhcp")
		dhcp, err := strconv.ParseBool(dhcpRaw)
		if err != nil {
			return fmt.Errorf("Invalid value for flag `enable-dhcp`: %s. Options are: true, false", dhcpRaw)
		}
		opts.EnableDHCP = &dhcp
	}
	resource.Params = &paramsList{
		opts:     opts,
		allPages: c.Bool("all-pages"),
	}
	return nil
}
开发者ID:flazz,项目名称:rack,代码行数:26,代码来源:list.go

示例6: HandleFlags

func (command *commandEmpty) HandleFlags(resource *handler.Resource) error {
	resource.Params = &paramsEmpty{
		quiet:       command.Ctx.CLIContext.Bool("quiet"),
		concurrency: command.Ctx.CLIContext.Int("concurrency"),
	}
	return nil
}
开发者ID:harshalhshah,项目名称:rack,代码行数:7,代码来源:empty.go

示例7: HandleFlags

func (command *commandUploadDir) HandleFlags(resource *handler.Resource) error {
	if err := command.Ctx.CheckFlagsSet([]string{"container"}); err != nil {
		return err
	}

	c := command.Ctx.CLIContext

	opts := objects.CreateOpts{
		ContentType: c.String("content-type"),
	}

	conc := c.Int("concurrency")
	if conc <= 0 {
		conc = 100
	}

	resource.Params = &paramsUploadDir{
		container:   c.String("container"),
		dir:         c.String("dir"),
		opts:        opts,
		concurrency: conc,
		quiet:       c.Bool("quiet"),
		recurse:     c.Bool("recurse"),
	}

	return nil
}
开发者ID:harshalhshah,项目名称:rack,代码行数:27,代码来源:uploaddir.go

示例8: HandleFlags

func (command *commandUpload) HandleFlags(resource *handler.Resource) error {
	err := command.Ctx.CheckFlagsSet([]string{"name"})
	if err != nil {
		return err
	}

	opts := &osKeypairs.CreateOpts{
		Name: command.Ctx.CLIContext.String("name"),
	}

	if command.Ctx.CLIContext.IsSet("file") {
		s := command.Ctx.CLIContext.String("file")
		pk, err := ioutil.ReadFile(s)
		if err != nil {
			return err
		}
		opts.PublicKey = string(pk)
	} else if command.Ctx.CLIContext.IsSet("public-key") {
		s := command.Ctx.CLIContext.String("public-key")
		opts.PublicKey = s
	} else {
		return fmt.Errorf("One of 'public-key' and 'file' must be provided.")
	}

	resource.Params = &paramsUpload{
		opts: opts,
	}

	return nil
}
开发者ID:hdansou,项目名称:rack,代码行数:30,代码来源:upload.go

示例9: HandleFlags

func (command *commandUpdate) HandleFlags(resource *handler.Resource) error {
	portID, err := command.Ctx.IDOrName(osPorts.IDFromName)
	if err != nil {
		return err
	}

	c := command.Ctx.CLIContext
	opts := &osPorts.UpdateOpts{
		Name:     c.String("rename"),
		DeviceID: c.String("device-id"),
	}

	if c.IsSet("up") {
		upRaw := c.String("up")
		up, err := strconv.ParseBool(upRaw)
		if err != nil {
			return fmt.Errorf("Invalid value for flag `up`: %s. Options are: true, false", upRaw)
		}
		opts.AdminStateUp = &up
	}

	if c.IsSet("security-groups") {
		opts.SecurityGroups = strings.Split(c.String("security-groups"), ",")
	}

	resource.Params = &paramsUpdate{
		portID: portID,
		opts:   opts,
	}

	return nil
}
开发者ID:harshalhshah,项目名称:rack,代码行数:32,代码来源:update.go

示例10: HandleFlags

func (command *commandDelete) HandleFlags(resource *handler.Resource) error {
	resource.Params = &paramsDelete{
		purge:       command.Ctx.CLIContext.Bool("purge"),
		quiet:       command.Ctx.CLIContext.Bool("quiet"),
		concurrency: command.Ctx.CLIContext.Int("concurrency"),
	}
	return nil
}
开发者ID:harshalhshah,项目名称:rack,代码行数:8,代码来源:delete.go

示例11: HandleFlags

func (command *commandDelete) HandleFlags(resource *handler.Resource) error {
	err := command.Ctx.CheckFlagsSet([]string{"container"})
	if err != nil {
		return err
	}
	container := command.Ctx.CLIContext.String("container")
	resource.Params = &paramsDelete{
		container: container,
	}
	return nil
}
开发者ID:flazz,项目名称:rack,代码行数:11,代码来源:delete.go

示例12: HandleFlags

func (command *commandGetMetadata) HandleFlags(resource *handler.Resource) error {
	err := command.Ctx.CheckFlagsSet([]string{"name"})
	if err != nil {
		return err
	}

	resource.Params = &paramsGetMetadata{
		containerName: command.Ctx.CLIContext.String("name"),
	}
	return err
}
开发者ID:harshalhshah,项目名称:rack,代码行数:11,代码来源:getmetadata.go

示例13: HandleFlags

func (command *commandUpdate) HandleFlags(resource *handler.Resource) error {
	subnetID, err := command.Ctx.IDOrName(osSubnets.IDFromName)
	if err != nil {
		return err
	}

	c := command.Ctx.CLIContext

	opts := &osSubnets.UpdateOpts{
		Name:      c.String("rename"),
		GatewayIP: c.String("gateway-ip"),
	}

	/*
		if c.IsSet("enable-dhcp") {
			enableDHCPRaw := c.String("enable-dhcp")
			enableDHCP, err := strconv.ParseBool(enableDHCPRaw)
			if err != nil {
				return fmt.Errorf("Invalid value for flag `shared`: %s. Options are: true, false", enableDHCPRaw)
			}
			opts.EnableDHCP = &enableDHCP
		}
	*/

	if c.IsSet("dns-nameservers") {
		opts.DNSNameservers = strings.Split(c.String("dns-nameservers"), ",")
	}

	/*
		if c.IsSet("host-route") {
			hostRoutesRaw := c.StringSlice("host-route")
			hostRoutesRawSlice, err := command.Ctx.CheckStructFlag(hostRoutesRaw)
			if err != nil {
				return err
			}
			hostRoutes := make([]osSubnets.HostRoute, len(hostRoutesRawSlice))
			for i, hostRouteMap := range hostRoutesRawSlice {
				hostRoutes[i] = osSubnets.HostRoute{
					DestinationCIDR: hostRouteMap["dest"].(string),
					NextHop:         hostRouteMap["next"].(string),
				}
			}
			opts.HostRoutes = hostRoutes
		}
	*/

	resource.Params = &paramsUpdate{
		opts:     opts,
		subnetID: subnetID,
	}

	return nil
}
开发者ID:flazz,项目名称:rack,代码行数:53,代码来源:update.go

示例14: HandleFlags

func (command *commandDeleteMetadata) HandleFlags(resource *handler.Resource) error {
	err := command.Ctx.CheckFlagsSet([]string{"metadata"})
	if err != nil {
		return err
	}

	serverID, err := command.Ctx.IDOrName(osServers.IDFromName)
	resource.Params = &paramsDeleteMetadata{
		serverID:     serverID,
		metadataKeys: strings.Split(command.Ctx.CLIContext.String("metadata"), ","),
	}
	return err
}
开发者ID:stephamon,项目名称:rack,代码行数:13,代码来源:deletemetadata.go

示例15: HandleFlags

func (command *commandDownload) HandleFlags(resource *handler.Resource) error {
	err := command.Ctx.CheckFlagsSet([]string{"container", "name"})
	if err != nil {
		return err
	}
	container := command.Ctx.CLIContext.String("container")
	object := command.Ctx.CLIContext.String("name")
	resource.Params = &paramsDownload{
		container: container,
		object:    object,
	}
	return nil
}
开发者ID:mrhillsman,项目名称:rack,代码行数:13,代码来源:download.go


注:本文中的github.com/jrperritt/rack/handler.Resource.Params方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。