44 "github.com/ucloud/ucloud-sdk-go/services/uaccount"
55 "github.com/ucloud/ucloud-sdk-go/services/ufile"
66 "github.com/ucloud/ucloud-sdk-go/services/uhost"
7+ "github.com/ucloud/ucloud-sdk-go/services/uk8s"
78 "github.com/ucloud/ucloud-sdk-go/services/unet"
89 "github.com/ucloud/ucloud-sdk-go/services/vpc"
910 "github.com/ucloud/ucloud-sdk-go/ucloud"
@@ -12,6 +13,7 @@ import (
1213
1314type UCloudClient struct {
1415 UHostConn * uhost.UHostClient
16+ UK8sConn * uk8s.UK8SClient
1517 UNetConn * unet.UNetClient
1618 VPCConn * vpc.VPCClient
1719 UAccountConn * uaccount.UAccountClient
@@ -140,3 +142,24 @@ func (c *UCloudClient) DescribeImageByInfo(projectId, regionId, imageId string)
140142 return & resp .ImageSet [0 ], nil
141143
142144}
145+
146+ func (c * UCloudClient ) DescribeUK8sNodeImageById (imageId string ) (* uk8s.ImageInfo , error ) {
147+ if imageId == "" {
148+ return nil , NewNotFoundError ("image" , imageId )
149+ }
150+ req := c .UK8sConn .NewDescribeUK8SImageRequest ()
151+ resp , err := c .UK8sConn .DescribeUK8SImage (req )
152+ if err != nil {
153+ return nil , err
154+ }
155+
156+ if len (resp .ImageSet ) < 1 {
157+ return nil , NewNotFoundError ("image" , imageId )
158+ }
159+ for _ , image := range resp .ImageSet {
160+ if image .ImageId == imageId {
161+ return & image , nil
162+ }
163+ }
164+ return nil , NewNotFoundError ("image" , imageId )
165+ }
0 commit comments