• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang aws.TimeValue函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/aws/aws-sdk-go/aws.TimeValue函数的典型用法代码示例。如果您正苦于以下问题:Golang TimeValue函数的具体用法?Golang TimeValue怎么用?Golang TimeValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: Marshal

// Marshal parses the response from the aws sdk into an awsm IAM User
func (i *IAMUser) Marshal(user *iam.User) {
	i.UserName = aws.StringValue(user.UserName)
	i.UserID = aws.StringValue(user.UserId)
	i.CreateDate = aws.TimeValue(user.CreateDate) // robots
	i.CreatedHuman = humanize.Time(i.CreateDate)  // humans
	i.Arn = aws.StringValue(user.Arn)
	i.PasswordLastUsed = aws.TimeValue(user.PasswordLastUsed)   // robots
	i.PasswordLastUsedHuman = humanize.Time(i.PasswordLastUsed) // humans
}
开发者ID:murdinc,项目名称:awsm,代码行数:10,代码来源:iam.go


示例2: GetAuthorizationToken

func (client *ecrClient) GetAuthorizationToken(registryId string) (*ecrapi.AuthorizationData, error) {
	cachedToken, found := client.tokenCache.Get(registryId)
	if found {
		cachedAuthData := cachedToken.(*ecrapi.AuthorizationData)

		if client.IsTokenValid(cachedAuthData) {
			return cachedAuthData, nil
		} else {
			log.Debugf("Token found, but expires at %s", aws.TimeValue(cachedAuthData.ExpiresAt))
		}
	}

	log.Debugf("Calling GetAuthorizationToken for %q", registryId)

	output, err := client.sdkClient.GetAuthorizationToken(&ecrapi.GetAuthorizationTokenInput{
		RegistryIds: []*string{aws.String(registryId)},
	})

	if err != nil {
		return nil, err
	}

	if len(output.AuthorizationData) != 1 {
		return nil, fmt.Errorf("Unexpected number of results in AuthorizationData (%d)", len(output.AuthorizationData))
	}
	authData := output.AuthorizationData[0]
	client.tokenCache.Set(registryId, authData)

	return authData, nil
}
开发者ID:umaptechnologies,项目名称:amazon-ecs-agent,代码行数:30,代码来源:client.go


示例3: Marshal

// Marshal parses the response from the aws sdk into an awsm LoadBalancer
func (l *LoadBalancer) Marshal(balancer *elb.LoadBalancerDescription, region string, secGrpList *SecurityGroups, vpcList *Vpcs, subList *Subnets) {

	// security groups
	secGroupNames := secGrpList.GetSecurityGroupNames(aws.StringValueSlice(balancer.SecurityGroups))
	secGroupNamesSorted := sort.StringSlice(secGroupNames[0:])
	secGroupNamesSorted.Sort()

	// subnets
	subnetNames := subList.GetSubnetNames(aws.StringValueSlice(balancer.Subnets))
	subnetNamesSorted := sort.StringSlice(subnetNames[0:])
	subnetNamesSorted.Sort()

	l.Name = aws.StringValue(balancer.LoadBalancerName)
	l.DNSName = aws.StringValue(balancer.DNSName)
	l.CreatedTime = aws.TimeValue(balancer.CreatedTime) // robots
	l.CreatedHuman = humanize.Time(l.CreatedTime)       // humans
	l.VpcID = aws.StringValue(balancer.VPCId)
	l.Vpc = vpcList.GetVpcName(l.VpcID)
	l.SubnetIDs = aws.StringValueSlice(balancer.Subnets)
	l.Subnets = strings.Join(subnetNamesSorted, ", ")
	l.HealthCheckTarget = aws.StringValue(balancer.HealthCheck.Target)
	l.HealthCheckInterval = fmt.Sprintf("%d seconds", *balancer.HealthCheck.Interval)
	l.Scheme = aws.StringValue(balancer.Scheme)
	l.SecurityGroups = strings.Join(secGroupNamesSorted, ", ")
	l.AvailabilityZones = strings.Join(aws.StringValueSlice(balancer.AvailabilityZones), ", ") // TODO
	l.Region = region
}
开发者ID:murdinc,项目名称:awsm,代码行数:28,代码来源:loadbalancers.go


示例4: IsTokenValid

// Ensure token is still within it's expiration window. We early expire to allow for timing in calls and add jitter to avoid
// refreshing all of the tokens at once.
func (client *ecrClient) IsTokenValid(authData *ecrapi.AuthorizationData) bool {
	if authData == nil || authData.ExpiresAt == nil {
		return false
	}

	refreshTime := aws.TimeValue(authData.ExpiresAt).Add(-1 * client.expirationJitter())
	return time.Now().Before(refreshTime)
}
开发者ID:umaptechnologies,项目名称:amazon-ecs-agent,代码行数:10,代码来源:client.go


示例5: Print

func (i *instance) Print(w io.Writer) {
	fmt.Fprintf(w, "============= AWS ==========\n")
	fmt.Fprintf(w, "InstanceId:\t%s\n", aws.StringValue(i.ec2.InstanceId))
	fmt.Fprintf(w, "IP Address:\t%s\n", aws.StringValue(i.ec2.PublicIpAddress))
	fmt.Fprintf(w, "State:\t%s\n", aws.StringValue(i.ec2.State.Name))
	fmt.Fprintf(w, "Image Id:\t%s\n", aws.StringValue(i.ec2.ImageId))
	fmt.Fprintf(w, "Availibility Zone:\t%s\n", aws.StringValue(i.status.AvailabilityZone))
	fmt.Fprintf(w, "Launch Time:\t%s\n", aws.TimeValue(i.ec2.LaunchTime))
	fmt.Fprintf(w, "Storage Size:\t%s\n", i.volumeSize())
}
开发者ID:koding,项目名称:koding,代码行数:10,代码来源:userdebug.go


示例6: GetCredentials

func (self *defaultClient) GetCredentials(registry, image string) (string, string, error) {
	log.Debugf("GetCredentials for %s", registry)

	cachedEntry := self.credentialCache.Get(registry)

	if cachedEntry != nil {
		if cachedEntry.IsValid(time.Now()) {
			log.Debugf("Using cached token for %s", registry)
			return extractToken(cachedEntry.AuthorizationToken)
		} else {
			log.Debugf("Cached token is no longer valid. RequestAt: %s, ExpiresAt: %s", cachedEntry.RequestedAt, cachedEntry.ExpiresAt)
		}
	}

	log.Debugf("Calling ECR.GetAuthorizationToken for %s", registry)

	input := &ecr.GetAuthorizationTokenInput{
		RegistryIds: []*string{aws.String(registry)},
	}

	output, err := self.ecrClient.GetAuthorizationToken(input)

	if err != nil || output == nil {
		if err == nil {
			err = fmt.Errorf("Missing AuthorizationData in ECR response for %s", registry)
		}

		// if we have a cached token, fall back to avoid failing the request. This may result an expired token
		// being returned, but if there is a 500 or timeout from the service side, we'd like to attempt to re-use an
		// old token. We invalidate tokens prior to their expiration date to help mitigate this scenario.
		if cachedEntry != nil {
			log.Infof("Got error fetching authorization token. Falling back to cached token. Error was: %s", err)
			return extractToken(cachedEntry.AuthorizationToken)
		}

		return "", "", err
	}
	for _, authData := range output.AuthorizationData {
		if authData.ProxyEndpoint != nil &&
			strings.HasPrefix(proxyEndpointScheme+image, aws.StringValue(authData.ProxyEndpoint)) &&
			authData.AuthorizationToken != nil {
			authEntry := cache.AuthEntry{
				AuthorizationToken: aws.StringValue(authData.AuthorizationToken),
				RequestedAt:        time.Now(),
				ExpiresAt:          aws.TimeValue(authData.ExpiresAt),
				ProxyEndpoint:      aws.StringValue(authData.ProxyEndpoint),
			}

			self.credentialCache.Set(registry, &authEntry)
			return extractToken(aws.StringValue(authData.AuthorizationToken))
		}
	}
	return "", "", fmt.Errorf("No AuthorizationToken found for %s", registry)
}
开发者ID:concourse,项目名称:docker-image-resource,代码行数:54,代码来源:client.go


示例7: Retrieve

// Retrieve implements the credentials.Provider interface.
func (p *Provider) Retrieve() (v credentials.Value, err error) {
	client := p.cfg.Kite.NewClient(p.cfg.ServerURL)
	client.Auth = &kite.Auth{
		Type: "kiteKey",
		Key:  p.cfg.Kite.KiteKey(),
	}

	if err := client.DialTimeout(p.timeout()); err != nil {
		return v, err
	}

	defer client.Close()

	req := &AuthRequest{
		Type: p.typ(),
	}

	part, err := client.TellWithTimeout("keygen.auth", p.timeout(), req)
	if err != nil {
		return v, err
	}

	var cred sts.Credentials

	resp := &AuthResponse{
		Value: &cred,
	}

	if err := part.Unmarshal(resp); err != nil {
		return v, err
	}

	if resp.Type != req.Type {
		return v, fmt.Errorf("authorization type not expected: %q", resp.Type)
	}

	p.expire = aws.TimeValue(cred.Expiration)

	p.cfg.log().Debug("Retrieve()=%+v", resp)

	return credentials.Value{
		AccessKeyID:     aws.StringValue(cred.AccessKeyId),
		SecretAccessKey: aws.StringValue(cred.SecretAccessKey),
		SessionToken:    aws.StringValue(cred.SessionToken),
		ProviderName:    "keygen",
	}, nil
}
开发者ID:koding,项目名称:koding,代码行数:48,代码来源:keygen.go


示例8: Marshal

// Marshal parses the response from the aws sdk into an awsm LaunchConfig
func (l *LaunchConfig) Marshal(config *autoscaling.LaunchConfiguration, region string, secGrpList *SecurityGroups, imgList *Images) {
	secGroupNames := secGrpList.GetSecurityGroupNames(aws.StringValueSlice(config.SecurityGroups))
	secGroupNamesSorted := sort.StringSlice(secGroupNames[0:])
	secGroupNamesSorted.Sort()

	l.Name = aws.StringValue(config.LaunchConfigurationName)
	l.ImageID = aws.StringValue(config.ImageId)
	l.ImageName = imgList.GetImageName(l.ImageID)
	l.InstanceType = aws.StringValue(config.InstanceType)
	l.KeyName = aws.StringValue(config.KeyName)
	l.CreationTime = aws.TimeValue(config.CreatedTime) // robots
	l.CreatedHuman = humanize.Time(l.CreationTime)     // humans
	l.EbsOptimized = aws.BoolValue(config.EbsOptimized)
	l.SecurityGroups = strings.Join(secGroupNamesSorted, ", ")
	l.Region = region

	for _, snapshot := range config.BlockDeviceMappings {
		l.SnapshotIDs = append(l.SnapshotIDs, *snapshot.Ebs.SnapshotId)
	}
}
开发者ID:murdinc,项目名称:awsm,代码行数:21,代码来源:launchconfigurations.go


示例9: ListDir

// ListDir lists the buckets
func (f *FsS3) ListDir() fs.DirChan {
	out := make(fs.DirChan, fs.Config.Checkers)
	if f.bucket == "" {
		// List the buckets
		go func() {
			defer close(out)
			req := s3.ListBucketsInput{}
			resp, err := f.c.ListBuckets(&req)
			if err != nil {
				fs.Stats.Error()
				fs.ErrorLog(f, "Couldn't list buckets: %s", err)
			} else {
				for _, bucket := range resp.Buckets {
					out <- &fs.Dir{
						Name:  aws.StringValue(bucket.Name),
						When:  aws.TimeValue(bucket.CreationDate),
						Bytes: -1,
						Count: -1,
					}
				}
			}
		}()
	} else {
		// List the directories in the path in the bucket
		go func() {
			defer close(out)
			f.list(true, func(remote string, object *s3.Object) {
				size := int64(0)
				if object.Size != nil {
					size = *object.Size
				}
				out <- &fs.Dir{
					Name:  remote,
					Bytes: size,
					Count: 0,
				}
			})
		}()
	}
	return out
}
开发者ID:JoeyGo23,项目名称:rclone,代码行数:42,代码来源:s3.go


示例10: Marshal

// Marshal parses the response from the aws sdk into an awsm LoadBalancerV2
func (l *LoadBalancerV2) Marshal(balancer *elbv2.LoadBalancer, region string, secGrpList *SecurityGroups) {

	secGroupNames := secGrpList.GetSecurityGroupNames(aws.StringValueSlice(balancer.SecurityGroups))
	secGroupNamesSorted := sort.StringSlice(secGroupNames[0:])
	secGroupNamesSorted.Sort()

	l.Name = aws.StringValue(balancer.LoadBalancerName)
	l.DNSName = aws.StringValue(balancer.DNSName)
	l.CreatedTime = aws.TimeValue(balancer.CreatedTime) // robots
	l.CreatedHuman = humanize.Time(l.CreatedTime)       // humans
	l.VpcID = aws.StringValue(balancer.VpcId)
	l.Type = aws.StringValue(balancer.Type)
	l.State = balancer.State.String()
	l.Scheme = aws.StringValue(balancer.Scheme)
	l.CanonicalHostedZoneID = aws.StringValue(balancer.CanonicalHostedZoneId)
	l.LoadBalancerArn = aws.StringValue(balancer.LoadBalancerArn)
	l.SecurityGroups = strings.Join(secGroupNamesSorted, ", ")
	//	l.AvailabilityZones = strings.Join(aws.StringValueSlice(balancer.AvailabilityZones), ", ") // TODO
	l.Region = region

}
开发者ID:murdinc,项目名称:awsm,代码行数:22,代码来源:loadbalancersV2.go


示例11: Marshal

// Marshal parses the response from the aws sdk into an awsm Snapshot
func (s *Snapshot) Marshal(snapshot *ec2.Snapshot, region string) {
	s.Name = GetTagValue("Name", snapshot.Tags)
	s.Class = GetTagValue("Class", snapshot.Tags)
	s.Description = aws.StringValue(snapshot.Description)
	s.SnapshotID = aws.StringValue(snapshot.SnapshotId)
	s.VolumeID = aws.StringValue(snapshot.VolumeId)
	s.State = aws.StringValue(snapshot.State)
	s.StartTime = *snapshot.StartTime                                 // robots
	s.CreatedHuman = humanize.Time(aws.TimeValue(snapshot.StartTime)) // humans
	s.Progress = aws.StringValue(snapshot.Progress)
	s.VolumeSize = fmt.Sprint(aws.Int64Value(snapshot.VolumeSize))
	s.Region = region

	switch s.State {

	case "error":
		s.Progress = "failed!"

	case "completed":
		s.Progress = "ready"
	}
}
开发者ID:murdinc,项目名称:awsm,代码行数:23,代码来源:snapshots.go


示例12: Marshal

// Marshal parses the response from the aws sdk into an awsm Volume
func (v *Volume) Marshal(volume *ec2.Volume, region string, instList *Instances) {
	v.Name = GetTagValue("Name", volume.Tags)
	v.Class = GetTagValue("Class", volume.Tags)
	v.VolumeID = aws.StringValue(volume.VolumeId)
	v.Size = int(aws.Int64Value(volume.Size))
	v.SizeHuman = fmt.Sprintf("%d GB", v.Size)
	v.State = aws.StringValue(volume.State)
	v.Iops = fmt.Sprint(aws.Int64Value(volume.Iops))
	v.CreationTime = *volume.CreateTime                              // robots
	v.CreatedHuman = humanize.Time(aws.TimeValue(volume.CreateTime)) // humans
	v.VolumeType = aws.StringValue(volume.VolumeType)
	v.SnapshoID = aws.StringValue(volume.SnapshotId)
	v.AvailabilityZone = aws.StringValue(volume.AvailabilityZone)
	v.Region = region

	if v.State == "in-use" {
		v.InstanceID = aws.StringValue(volume.Attachments[0].InstanceId)
		instance := instList.GetInstanceName(v.InstanceID)
		v.Attachment = instance
		v.DeleteOnTerm = aws.BoolValue(volume.Attachments[0].DeleteOnTermination)

	}

}
开发者ID:murdinc,项目名称:awsm,代码行数:25,代码来源:volumes.go


示例13: listBuckets

// listBuckets lists the buckets to out
func (f *Fs) listBuckets(out fs.ListOpts, dir string) {
	defer out.Finished()
	if dir != "" {
		out.SetError(fs.ErrorListOnlyRoot)
		return
	}
	req := s3.ListBucketsInput{}
	resp, err := f.c.ListBuckets(&req)
	if err != nil {
		out.SetError(err)
		return
	}
	for _, bucket := range resp.Buckets {
		dir := &fs.Dir{
			Name:  aws.StringValue(bucket.Name),
			When:  aws.TimeValue(bucket.CreationDate),
			Bytes: -1,
			Count: -1,
		}
		if out.AddDir(dir) {
			break
		}
	}
}
开发者ID:yut148,项目名称:rclone,代码行数:25,代码来源:s3.go


示例14: resourceAwsSpotFleetRequestRead

func resourceAwsSpotFleetRequestRead(d *schema.ResourceData, meta interface{}) error {
	// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSpotFleetRequests.html
	conn := meta.(*AWSClient).ec2conn

	req := &ec2.DescribeSpotFleetRequestsInput{
		SpotFleetRequestIds: []*string{aws.String(d.Id())},
	}
	resp, err := conn.DescribeSpotFleetRequests(req)

	if err != nil {
		// If the spot request was not found, return nil so that we can show
		// that it is gone.
		ec2err, ok := err.(awserr.Error)
		if ok && ec2err.Code() == "InvalidSpotFleetRequestID.NotFound" {
			d.SetId("")
			return nil
		}

		// Some other error, report it
		return err
	}

	sfr := resp.SpotFleetRequestConfigs[0]

	// if the request is cancelled, then it is gone
	cancelledStates := map[string]bool{
		"cancelled":             true,
		"cancelled_running":     true,
		"cancelled_terminating": true,
	}
	if _, ok := cancelledStates[*sfr.SpotFleetRequestState]; ok {
		d.SetId("")
		return nil
	}

	d.SetId(*sfr.SpotFleetRequestId)
	d.Set("spot_request_state", aws.StringValue(sfr.SpotFleetRequestState))

	config := sfr.SpotFleetRequestConfig

	if config.AllocationStrategy != nil {
		d.Set("allocation_strategy", aws.StringValue(config.AllocationStrategy))
	}

	if config.ClientToken != nil {
		d.Set("client_token", aws.StringValue(config.ClientToken))
	}

	if config.ExcessCapacityTerminationPolicy != nil {
		d.Set("excess_capacity_termination_policy",
			aws.StringValue(config.ExcessCapacityTerminationPolicy))
	}

	if config.IamFleetRole != nil {
		d.Set("iam_fleet_role", aws.StringValue(config.IamFleetRole))
	}

	if config.SpotPrice != nil {
		d.Set("spot_price", aws.StringValue(config.SpotPrice))
	}

	if config.TargetCapacity != nil {
		d.Set("target_capacity", aws.Int64Value(config.TargetCapacity))
	}

	if config.TerminateInstancesWithExpiration != nil {
		d.Set("terminate_instances_with_expiration",
			aws.BoolValue(config.TerminateInstancesWithExpiration))
	}

	if config.ValidFrom != nil {
		d.Set("valid_from",
			aws.TimeValue(config.ValidFrom).Format(awsAutoscalingScheduleTimeLayout))
	}

	if config.ValidUntil != nil {
		d.Set("valid_until",
			aws.TimeValue(config.ValidUntil).Format(awsAutoscalingScheduleTimeLayout))
	}

	d.Set("launch_specification", launchSpecsToSet(config.LaunchSpecifications, conn))

	return nil
}
开发者ID:mhlias,项目名称:terraform,代码行数:84,代码来源:resource_aws_spot_fleet_request.go



注:本文中的github.com/aws/aws-sdk-go/aws.TimeValue函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang aws.Config类代码示例发布时间:2022-05-24
下一篇:
Golang aws.Time函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap