From 9312732a91e13e755e8bf479dcb87dea17a3076b Mon Sep 17 00:00:00 2001 From: xuyaming Date: Thu, 16 Jun 2022 20:20:40 +0800 Subject: [PATCH 01/21] feat: support tos --- common/common_vestack_tos_client.go | 123 +++++++++ common/common_vestack_tos_handler.go | 381 +++++++++++++++++++++++++++ 2 files changed, 504 insertions(+) create mode 100644 common/common_vestack_tos_client.go create mode 100644 common/common_vestack_tos_handler.go diff --git a/common/common_vestack_tos_client.go b/common/common_vestack_tos_client.go new file mode 100644 index 00000000..d2a14c06 --- /dev/null +++ b/common/common_vestack_tos_client.go @@ -0,0 +1,123 @@ +package common + +import ( + "fmt" + "io/ioutil" + + "github.com/volcengine/volcstack-go-sdk/volcstack/client" + "github.com/volcengine/volcstack-go-sdk/volcstack/client/metadata" + "github.com/volcengine/volcstack-go-sdk/volcstack/corehandlers" + "github.com/volcengine/volcstack-go-sdk/volcstack/request" + "github.com/volcengine/volcstack-go-sdk/volcstack/session" +) + +type Tos struct { + Session *session.Session +} + +type TosInfo struct { + HttpMethod HttpMethod + Query map[string]interface{} + Path []string + Header map[string]string + Domain string + ContentPath string +} + +func NewTosClient(session *session.Session) *Tos { + return &Tos{ + Session: session, + } +} + +func (u *Tos) getMethod(m HttpMethod) string { + switch m { + case GET: + return "GET" + case POST: + return "POST" + case PUT: + return "PUT" + case DELETE: + return "DELETE" + default: + return "GET" + } +} + +func (u *Tos) newTosClient(domain string) *client.Client { + svc := "tos" + config := u.Session.ClientConfig(svc) + var ( + endpoint string + ) + if domain == "" { + if config.Config.DisableSSL != nil && *config.Config.DisableSSL { + endpoint = fmt.Sprintf("%s://tos-%s.volces.com", "http", config.SigningRegion) + } else { + endpoint = fmt.Sprintf("%s://tos-%s.volces.com", "https", config.SigningRegion) + } + } else { + if config.Config.DisableSSL != nil && *config.Config.DisableSSL { + endpoint = fmt.Sprintf("%s://%s.tos-%s.volces.com", "http", domain, config.SigningRegion) + } else { + endpoint = fmt.Sprintf("%s://%s.tos-%s.volces.com", "https", domain, config.SigningRegion) + } + + } + + c := client.New( + *config.Config, + metadata.ClientInfo{ + SigningName: config.SigningName, + SigningRegion: config.SigningRegion, + Endpoint: endpoint, + ServiceName: svc, + ServiceID: svc, + }, + config.Handlers, + ) + c.Handlers.Build.PushBackNamed(corehandlers.SDKVersionUserAgentHandler) + c.Handlers.Build.PushBackNamed(corehandlers.AddHostExecEnvUserAgentHandler) + c.Handlers.Sign.PushBackNamed(tosSignRequestHandler) + c.Handlers.Build.PushBackNamed(tosBuildHandler) + c.Handlers.Unmarshal.PushBackNamed(tosUnmarshalHandler) + c.Handlers.UnmarshalError.PushBackNamed(tosUnmarshalErrorHandler) + + return c +} + +func (u *Tos) DoTosCall(info TosInfo, input *map[string]interface{}) (output *map[string]interface{}, err error) { + c := u.newTosClient(info.Domain) + var httpPath string + + if len(info.Path) > 0 { + for _, v := range info.Path { + httpPath = httpPath + "/" + v + } + } + + op := &request.Operation{ + HTTPMethod: u.getMethod(info.HttpMethod), + HTTPPath: httpPath, + } + if input == nil { + input = &map[string]interface{}{} + } + output = &map[string]interface{}{} + req := c.NewRequest(op, input, output) + + if info.ContentPath != "" && (op.HTTPMethod == "PUT" || op.HTTPMethod == "POST") { + content, _ := ioutil.ReadFile(info.ContentPath) + req.SetBufferBody(content) + } + + if len(info.Header) > 0 { + for k, v := range info.Header { + req.HTTPRequest.Header.Set(k, v) + } + } + + err = req.Send() + return output, err +} diff --git a/common/common_vestack_tos_handler.go b/common/common_vestack_tos_handler.go new file mode 100644 index 00000000..c94da0a1 --- /dev/null +++ b/common/common_vestack_tos_handler.go @@ -0,0 +1,381 @@ +package common + +import ( + "bytes" + "crypto/hmac" + "crypto/md5" + "crypto/sha256" + "encoding/base64" + "encoding/hex" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "net/url" + "reflect" + "sort" + "strings" + "time" + + "github.com/volcengine/volcstack-go-sdk/volcstack" + "github.com/volcengine/volcstack-go-sdk/volcstack/request" + "github.com/volcengine/volcstack-go-sdk/volcstack/volcstackerr" +) + +var tosSignRequestHandler = request.NamedHandler{Name: "TosSignRequestHandler", Fn: tosSign} +var tosBuildHandler = request.NamedHandler{Name: "TosBuildHandler", Fn: tosBuild} +var tosUnmarshalHandler = request.NamedHandler{Name: "TosUnmarshalHandler", Fn: tosUnmarshal} +var tosUnmarshalErrorHandler = request.NamedHandler{Name: "TosUnmarshalErrorHandler", Fn: tosUnmarshalError} + +func tosSign(req *request.Request) { + region := req.ClientInfo.SigningRegion + + var ( + c Credentials + ) + + region = volcstack.StringValue(req.Config.Region) + + name := req.ClientInfo.SigningName + if name == "" { + name = req.ClientInfo.ServiceID + } + + value, _ := req.Config.Credentials.Get() + + c = Credentials{ + AccessKeyID: value.AccessKeyID, + SecretAccessKey: value.SecretAccessKey, + SessionToken: value.SessionToken, + Region: region, + Service: "tos", + } + r := sign(req.HTTPRequest, c) + req.HTTPRequest.Header = r.Header +} + +func tosBuild(r *request.Request) { + body := url.Values{} + + if r.Config.ExtraUserAgent != nil && *r.Config.ExtraUserAgent != "" { + if strings.HasPrefix(*r.Config.ExtraUserAgent, "/") { + request.AddToUserAgent(r, *r.Config.ExtraUserAgent) + } else { + request.AddToUserAgent(r, "/"+*r.Config.ExtraUserAgent) + } + + } + + r.HTTPRequest.URL.RawQuery = body.Encode() + r.HTTPRequest.Host = r.HTTPRequest.URL.Host + + if reflect.TypeOf(r.Params) == reflect.TypeOf(&map[string]interface{}{}) { + m := *(r.Params).(*map[string]interface{}) + for k, v := range m { + if reflect.TypeOf(v).String() == "string" { + body.Add(k, v.(string)) + } else { + body.Add(k, fmt.Sprintf("%v", v)) + } + } + } + + r.HTTPRequest.URL.Query() + if r.Config.ExtraHttpParameters != nil { + extra := r.Config.ExtraHttpParameters(r.Context()) + if extra != nil { + for k, value := range extra { + body.Add(k, value) + } + } + } + r.HTTPRequest.URL.RawQuery = body.Encode() +} + +type tosMetadata struct { + algorithm string + credentialScope string + signedHeaders string + date string + region string + service string +} + +type Credentials struct { + AccessKeyID string + SecretAccessKey string + Service string + Region string + SessionToken string +} + +func sign(request *http.Request, c Credentials) *http.Request { + query := request.URL.Query() + + request.URL.RawQuery = query.Encode() + return sign4(request, c) +} + +// Sign4 signs a request with Signed Signature Version 4. +func sign4(request *http.Request, credential Credentials) *http.Request { + keys := credential + + prepareRequestV4(request) + meta := new(tosMetadata) + meta.service, meta.region = keys.Service, keys.Region + + // Task 0 设置SessionToken的header + if credential.SessionToken != "" { + request.Header.Set("X-Tos-Security-Token", credential.SessionToken) + } + + // Task 1 + hashedCanonReq := hashedCanonicalRequestV4(request, meta) + + // Task 2 + stringToSign := stringToSignV4(request, hashedCanonReq, meta) + + // Task 3 + signingKey := signingKeyV4(keys.SecretAccessKey, meta.date, meta.region, meta.service) + signature := signatureV4(signingKey, stringToSign) + + request.Header.Set("Authorization", buildAuthHeaderV4(signature, meta, keys)) + + return request +} + +func hashedCanonicalRequestV4(request *http.Request, meta *tosMetadata) string { + payload := readAndReplaceBody(request) + payloadHash := hashSHA256(payload) + request.Header.Set("X-Tos-Content-Sha256", payloadHash) + + request.Header.Set("Host", request.Host) + + var sortedHeaderKeys []string + for key := range request.Header { + switch key { + case "Content-Type", "Content-Md5", "Host", "X-Tos-Security-Token": + default: + if !strings.HasPrefix(key, "X-") { + continue + } + } + sortedHeaderKeys = append(sortedHeaderKeys, strings.ToLower(key)) + } + sort.Strings(sortedHeaderKeys) + + var headersToSign string + for _, key := range sortedHeaderKeys { + value := strings.TrimSpace(request.Header.Get(key)) + if key == "host" { + if strings.Contains(value, ":") { + split := strings.Split(value, ":") + port := split[1] + if port == "80" || port == "443" { + value = split[0] + } + } + } + headersToSign += key + ":" + value + "\n" + } + meta.signedHeaders = concat(";", sortedHeaderKeys...) + canonicalRequest := concat("\n", request.Method, normuri(request.URL.Path), normquery(request.URL.Query()), headersToSign, meta.signedHeaders, payloadHash) + + return hashSHA256([]byte(canonicalRequest)) +} + +func stringToSignV4(request *http.Request, hashedCanonReq string, meta *tosMetadata) string { + requestTs := request.Header.Get("X-Tos-Date") + + meta.algorithm = "TOS4-HMAC-SHA256" + meta.date = tsDateV4(requestTs) + meta.credentialScope = concat("/", meta.date, meta.region, meta.service, "request") + + return concat("\n", meta.algorithm, requestTs, meta.credentialScope, hashedCanonReq) +} + +func signatureV4(signingKey []byte, stringToSign string) string { + return hex.EncodeToString(hmacSHA256(signingKey, stringToSign)) +} + +func prepareRequestV4(request *http.Request) *http.Request { + necessaryDefaults := map[string]string{ + "X-Tos-Date": timestampV4(), + } + + for header, value := range necessaryDefaults { + if request.Header.Get(header) == "" { + request.Header.Set(header, value) + } + } + + if request.URL.Path == "" { + request.URL.Path += "/" + } + + return request +} + +func signingKeyV4(secretKey, date, region, service string) []byte { + kDate := hmacSHA256([]byte(secretKey), date) + kRegion := hmacSHA256(kDate, region) + kService := hmacSHA256(kRegion, service) + kSigning := hmacSHA256(kService, "request") + return kSigning +} + +func buildAuthHeaderV4(signature string, meta *tosMetadata, keys Credentials) string { + credential := keys.AccessKeyID + "/" + meta.credentialScope + + return meta.algorithm + + " Credential=" + credential + + ", SignedHeaders=" + meta.signedHeaders + + ", Signature=" + signature +} + +func timestampV4() string { + return now().Format("20060102T150405Z") +} + +func tsDateV4(timestamp string) string { + return timestamp[:8] +} + +func hmacSHA256(key []byte, content string) []byte { + mac := hmac.New(sha256.New, key) + mac.Write([]byte(content)) + return mac.Sum(nil) +} + +func hashSHA256(content []byte) string { + h := sha256.New() + h.Write(content) + return fmt.Sprintf("%x", h.Sum(nil)) +} + +func hashMD5(content []byte) string { + h := md5.New() + h.Write(content) + return base64.StdEncoding.EncodeToString(h.Sum(nil)) +} + +func readAndReplaceBody(request *http.Request) []byte { + if request.Body == nil { + return []byte{} + } + payload, _ := ioutil.ReadAll(request.Body) + request.Body = ioutil.NopCloser(bytes.NewReader(payload)) + return payload +} + +func concat(delim string, str ...string) string { + return strings.Join(str, delim) +} + +var now = func() time.Time { + return time.Now().UTC() +} + +func normuri(uri string) string { + parts := strings.Split(uri, "/") + for i := range parts { + parts[i] = encodePathFrag(parts[i]) + } + return strings.Join(parts, "/") +} + +func encodePathFrag(s string) string { + hexCount := 0 + for i := 0; i < len(s); i++ { + c := s[i] + if shouldEscape(c) { + hexCount++ + } + } + t := make([]byte, len(s)+2*hexCount) + j := 0 + for i := 0; i < len(s); i++ { + c := s[i] + if shouldEscape(c) { + t[j] = '%' + t[j+1] = "0123456789ABCDEF"[c>>4] + t[j+2] = "0123456789ABCDEF"[c&15] + j += 3 + } else { + t[j] = c + j++ + } + } + return string(t) +} + +func shouldEscape(c byte) bool { + if 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' { + return false + } + if '0' <= c && c <= '9' { + return false + } + if c == '-' || c == '_' || c == '.' || c == '~' { + return false + } + return true +} + +func normquery(v url.Values) string { + queryString := v.Encode() + + return strings.Replace(queryString, "+", "%20", -1) +} + +func tosUnmarshal(r *request.Request) { + defer r.HTTPResponse.Body.Close() + if r.DataFilled() { + body, err := ioutil.ReadAll(r.HTTPResponse.Body) + if err != nil { + fmt.Printf("read volcstackbody err, %v\n", err) + r.Error = err + return + } + + if reflect.TypeOf(r.Data) == reflect.TypeOf(&map[string]interface{}{}) { + if len(body) == 0 { + return + } + if err = json.Unmarshal(body, &r.Data); err != nil { + fmt.Printf("Unmarshal err, %v\n", err) + r.Error = err + return + } + } + + } +} + +func tosUnmarshalError(r *request.Request) { + defer r.HTTPResponse.Body.Close() + if r.DataFilled() { + body, err := ioutil.ReadAll(r.HTTPResponse.Body) + if err != nil { + fmt.Printf("read volcstackbody err, %v\n", err) + r.Error = err + return + } + if reflect.TypeOf(r.Data) != reflect.TypeOf(&map[string]interface{}{}) { + mm := map[string]interface{}{} + if err = json.Unmarshal(body, &mm); err != nil { + fmt.Printf("Unmarshal err, %v\n", err) + r.Error = err + return + } + } + return + } else { + r.Error = volcstackerr.NewRequestFailure( + volcstackerr.New("ServiceUnavailableException", "service is unavailable", nil), + r.HTTPResponse.StatusCode, + r.RequestID, + ) + return + } +} From b0bb1ec2ea6437b40be61039c844fdda757b1a26 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Fri, 17 Jun 2022 19:29:34 +0800 Subject: [PATCH 02/21] feat: support tos --- common/common_vestack_client.go | 1 + common/common_vestack_config.go | 1 + common/common_vestack_const.go | 15 ++ common/common_vestack_convert.go | 5 + common/common_vestack_data_source.go | 1 + common/common_vestack_dispatcher.go | 10 ++ common/common_vestack_tos_client.go | 3 +- common/common_vestack_tos_handler.go | 25 +++- common/common_vestack_tos_utils.go | 82 +++++++++++ common/common_vestack_universal_client.go | 3 + example/dataTosBuckets/main.tf | 3 + vestack/provider.go | 4 + .../bucket/data_source_vestack_tos_buckets.go | 77 ++++++++++ .../tos/bucket/service_vestack_tos_bucket.go | 131 ++++++++++++++++++ 14 files changed, 353 insertions(+), 8 deletions(-) create mode 100644 common/common_vestack_tos_utils.go create mode 100644 example/dataTosBuckets/main.tf create mode 100644 vestack/tos/bucket/data_source_vestack_tos_buckets.go create mode 100644 vestack/tos/bucket/service_vestack_tos_bucket.go diff --git a/common/common_vestack_client.go b/common/common_vestack_client.go index ad92bed3..f8e79b7b 100644 --- a/common/common_vestack_client.go +++ b/common/common_vestack_client.go @@ -24,4 +24,5 @@ type SdkClient struct { RdsClient *rdsmysql.RDSMYSQL RdsClientV2 *rdsmysqlv2.RDSMYSQLV2 UniversalClient *Universal + TosClient *Tos } diff --git a/common/common_vestack_config.go b/common/common_vestack_config.go index 6b435458..66ac98bd 100644 --- a/common/common_vestack_config.go +++ b/common/common_vestack_config.go @@ -54,6 +54,7 @@ func (c *Config) Client() (*SdkClient, error) { client.RdsClient = rdsmysql.New(sess) client.RdsClientV2 = rdsmysqlv2.New(sess) client.UniversalClient = NewUniversalClient(sess) + client.TosClient = NewTosClient(sess) InitLocks() InitSyncLimit() diff --git a/common/common_vestack_const.go b/common/common_vestack_const.go index 30227a4c..853d7843 100644 --- a/common/common_vestack_const.go +++ b/common/common_vestack_const.go @@ -29,3 +29,18 @@ const ( ContentTypeDefault RequestContentType = iota ContentTypeJson ) + +type ServiceCategory int + +const ( + DefaultServiceCategory ServiceCategory = iota + ServiceTos +) + +type SpecialParamType int + +const ( + DomainParam SpecialParamType = iota + HeaderParam + PathParam +) diff --git a/common/common_vestack_convert.go b/common/common_vestack_convert.go index 2a39ced2..97e4767a 100644 --- a/common/common_vestack_convert.go +++ b/common/common_vestack_convert.go @@ -28,6 +28,11 @@ type RequestConvert struct { TargetField string NextLevelConvert map[string]RequestConvert StartIndex int + SpecialParam *SpecialParam +} +type SpecialParam struct { + Type SpecialParamType + Index int } var supportRequestConvertType = map[RequestContentType]map[RequestConvertType]bool{ diff --git a/common/common_vestack_data_source.go b/common/common_vestack_data_source.go index db088f28..d46bf486 100644 --- a/common/common_vestack_data_source.go +++ b/common/common_vestack_data_source.go @@ -26,6 +26,7 @@ type DataSourceInfo struct { CollectField string ContentType RequestContentType ExtraData ExtraData + ServiceCategory ServiceCategory } func DataSourceToRequest(d *schema.ResourceData, r *schema.Resource, info DataSourceInfo) (req map[string]interface{}, err error) { diff --git a/common/common_vestack_dispatcher.go b/common/common_vestack_dispatcher.go index 41093239..eece172e 100644 --- a/common/common_vestack_dispatcher.go +++ b/common/common_vestack_dispatcher.go @@ -96,6 +96,16 @@ func (d *Dispatcher) Data(resourceService ResourceService, resourceDate *schema. if info.ContentType == ContentTypeJson { condition = sortAndStartTransJson(condition) } + switch info.ServiceCategory { + case ServiceTos: + condition, err = convertToTosParams(info.RequestConverts, condition) + if err != nil { + return err + } + break + default: + break + } collection, err = resourceService.ReadResources(condition) if err != nil { return err diff --git a/common/common_vestack_tos_client.go b/common/common_vestack_tos_client.go index d2a14c06..bfffbb0f 100644 --- a/common/common_vestack_tos_client.go +++ b/common/common_vestack_tos_client.go @@ -17,7 +17,6 @@ type Tos struct { type TosInfo struct { HttpMethod HttpMethod - Query map[string]interface{} Path []string Header map[string]string Domain string @@ -40,6 +39,8 @@ func (u *Tos) getMethod(m HttpMethod) string { return "PUT" case DELETE: return "DELETE" + case HEAD: + return "HEAD" default: return "GET" } diff --git a/common/common_vestack_tos_handler.go b/common/common_vestack_tos_handler.go index c94da0a1..87147674 100644 --- a/common/common_vestack_tos_handler.go +++ b/common/common_vestack_tos_handler.go @@ -109,6 +109,13 @@ type Credentials struct { SessionToken string } +type tosError struct { + Code string + RequestId string + HostId string + Message string +} + func sign(request *http.Request, c Credentials) *http.Request { query := request.URL.Query() @@ -361,14 +368,18 @@ func tosUnmarshalError(r *request.Request) { r.Error = err return } - if reflect.TypeOf(r.Data) != reflect.TypeOf(&map[string]interface{}{}) { - mm := map[string]interface{}{} - if err = json.Unmarshal(body, &mm); err != nil { - fmt.Printf("Unmarshal err, %v\n", err) - r.Error = err - return - } + tos := tosError{} + if err = json.Unmarshal(body, &tos); err != nil { + fmt.Printf("Unmarshal err, %v\n", err) + r.Error = err + return } + r.Error = volcstackerr.NewRequestFailure( + volcstackerr.New(tos.Code, tos.Message, nil), + r.HTTPResponse.StatusCode, + tos.RequestId, + ) + return } else { r.Error = volcstackerr.NewRequestFailure( diff --git a/common/common_vestack_tos_utils.go b/common/common_vestack_tos_utils.go new file mode 100644 index 00000000..4666552d --- /dev/null +++ b/common/common_vestack_tos_utils.go @@ -0,0 +1,82 @@ +package common + +import ( + "fmt" + "sort" + "strconv" + "strings" +) + +const ( + TosPath = "PATH" + TosDomain = "DOMAIN" + TosHeader = "HEADER" + TosParam = "PARAM" +) + +func convertToTosParams(convert map[string]RequestConvert, condition map[string]interface{}) (result map[string]interface{}, err error) { + if len(condition) > 0 { + result = map[string]interface{}{ + TosDomain: "", + TosHeader: make(map[string]string), + TosPath: []string{}, + TosParam: condition, + } + + if len(convert) > 0 { + + for k, v := range convert { + k1 := DownLineToHump(k) + if v.TargetField != "" { + k1 = v.TargetField + } + if v.SpecialParam != nil { + switch v.SpecialParam.Type { + case DomainParam: + if v1, ok := condition[k1]; ok { + if _, ok1 := v1.(string); !ok1 { + return result, fmt.Errorf("%s must a string type", k) + } + result[TosDomain] = v1 + delete(condition, k1) + } + break + case HeaderParam: + if v1, ok := condition[k1]; ok { + if _, ok1 := v1.(string); !ok1 { + return result, fmt.Errorf("%s must a string type", k) + } + result[TosHeader].(map[string]string)[k1] = v1.(string) + delete(condition, k1) + } + break + case PathParam: + if v1, ok := condition[k1]; ok { + if _, ok1 := v1.(string); !ok1 { + return result, fmt.Errorf("%s must a string type", k) + } + temp := result[TosPath].([]string) + temp = append(temp, strconv.Itoa(v.SpecialParam.Index)+":"+v1.(string)) + result[TosPath] = temp + delete(condition, k1) + } + } + break + } + } + //sort + if v, ok := result[TosPath]; ok { + temp := v.([]string) + sort.Strings(temp) + var afterSort []string + for _, v1 := range temp { + afterSort = append(afterSort, v1[strings.Index(v1, ":")+1:]) + } + result[TosPath] = afterSort + } + //query + result[TosParam] = condition + } + } + return result, err +} diff --git a/common/common_vestack_universal_client.go b/common/common_vestack_universal_client.go index 1bc087d0..9ad3c210 100644 --- a/common/common_vestack_universal_client.go +++ b/common/common_vestack_universal_client.go @@ -14,6 +14,7 @@ type HttpMethod int const ( GET HttpMethod = iota + HEAD POST PUT DELETE @@ -79,6 +80,8 @@ func (u *Universal) getMethod(m HttpMethod) string { return "PUT" case DELETE: return "DELETE" + case HEAD: + return "HEAD" default: return "GET" } diff --git a/example/dataTosBuckets/main.tf b/example/dataTosBuckets/main.tf new file mode 100644 index 00000000..a6ca42fe --- /dev/null +++ b/example/dataTosBuckets/main.tf @@ -0,0 +1,3 @@ +data "vestack_tos_buckets" "default" { + name_regex= "test" +} \ No newline at end of file diff --git a/vestack/provider.go b/vestack/provider.go index 9fedfa0b..b8b71db5 100644 --- a/vestack/provider.go +++ b/vestack/provider.go @@ -22,6 +22,7 @@ import ( "github.com/volcengine/terraform-provider-vestack/vestack/eip/eip_associate" "github.com/volcengine/terraform-provider-vestack/vestack/nat/nat_gateway" "github.com/volcengine/terraform-provider-vestack/vestack/nat/snat_entry" + "github.com/volcengine/terraform-provider-vestack/vestack/tos/bucket" "github.com/volcengine/terraform-provider-vestack/vestack/vpc/network_interface" "github.com/volcengine/terraform-provider-vestack/vestack/vpc/network_interface_attach" "github.com/volcengine/terraform-provider-vestack/vestack/vpc/route_entry" @@ -104,6 +105,9 @@ func Provider() terraform.ResourceProvider { // ================ NAT ================ "vestack_snat_entries": snat_entry.DataSourceVestackSnatEntries(), "vestack_nat_gateways": nat_gateway.DataSourceVestackNatGateways(), + + // ================ TOS ================ + "vestack_tos_buckets": bucket.DataSourceVestackTosBuckets(), }, ResourcesMap: map[string]*schema.Resource{ "vestack_vpc": vpc.ResourceVestackVpc(), diff --git a/vestack/tos/bucket/data_source_vestack_tos_buckets.go b/vestack/tos/bucket/data_source_vestack_tos_buckets.go new file mode 100644 index 00000000..3b3f1517 --- /dev/null +++ b/vestack/tos/bucket/data_source_vestack_tos_buckets.go @@ -0,0 +1,77 @@ +package bucket + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + ve "github.com/volcengine/terraform-provider-vestack/common" +) + +func DataSourceVestackTosBuckets() *schema.Resource { + return &schema.Resource{ + Read: dataSourceVestackTosBucketsRead, + Schema: map[string]*schema.Schema{ + "bucket_name": { + Type: schema.TypeString, + Optional: true, + Description: "The name the TOS bucket.", + }, + "name_regex": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringIsValidRegExp, + Description: "A Name Regex of TOS bucket.", + }, + + "output_file": { + Type: schema.TypeString, + Optional: true, + Description: "File name where to save data source results.", + }, + + "total_count": { + Type: schema.TypeInt, + Computed: true, + Description: "The total count of TOS bucket query.", + }, + "buckets": { + Description: "The collection of TOS bucket query.", + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Computed: true, + Description: "The name the TOS bucket.", + }, + "is_truncated": { + Type: schema.TypeBool, + Computed: true, + Description: "The truncated the TOS bucket.", + }, + "marker": { + Type: schema.TypeString, + Computed: true, + Description: "The marker the TOS bucket.", + }, + "max_keys": { + Type: schema.TypeInt, + Computed: true, + Description: "The max keys the TOS bucket.", + }, + "prefix": { + Type: schema.TypeString, + Computed: true, + Description: "The prefix the TOS bucket.", + }, + }, + }, + }, + }, + } +} + +func dataSourceVestackTosBucketsRead(d *schema.ResourceData, meta interface{}) error { + tosBucketService := NewTosBucketService(meta.(*ve.SdkClient)) + return tosBucketService.Dispatcher.Data(tosBucketService, d, DataSourceVestackTosBuckets()) +} diff --git a/vestack/tos/bucket/service_vestack_tos_bucket.go b/vestack/tos/bucket/service_vestack_tos_bucket.go new file mode 100644 index 00000000..12a867d4 --- /dev/null +++ b/vestack/tos/bucket/service_vestack_tos_bucket.go @@ -0,0 +1,131 @@ +package bucket + +import ( + "fmt" + "strings" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + ve "github.com/volcengine/terraform-provider-vestack/common" + "github.com/volcengine/terraform-provider-vestack/logger" +) + +type VestackTosBucketService struct { + Client *ve.SdkClient + Dispatcher *ve.Dispatcher +} + +func NewTosBucketService(c *ve.SdkClient) *VestackTosBucketService { + return &VestackTosBucketService{ + Client: c, + Dispatcher: &ve.Dispatcher{}, + } +} + +func (s *VestackTosBucketService) GetClient() *ve.SdkClient { + return s.Client +} + +func (s *VestackTosBucketService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { + tos := s.Client.TosClient + var ( + action string + resp *map[string]interface{} + results interface{} + ) + action = "ListBuckets" + logger.Debug(logger.ReqFormat, action, nil) + resp, err = tos.DoTosCall(ve.TosInfo{ + HttpMethod: ve.GET, + }, nil) + if err != nil { + return data, err + } + results, err = ve.ObtainSdkValue("Buckets", *resp) + if err != nil { + return data, err + } + data = results.([]interface{}) + return data, err +} + +func (s *VestackTosBucketService) ReadResource(resourceData *schema.ResourceData, instanceId string) (data map[string]interface{}, err error) { + var ( + results []interface{} + ok bool + ) + results, err = s.ReadResources(nil) + if err != nil { + return data, err + } + for _, v := range results { + if data, ok = v.(map[string]interface{}); !ok { + return data, fmt.Errorf("Value is not map ") + } + } + + if len(data) == 0 { + return data, fmt.Errorf("bucket %s not exist ", instanceId) + } + return data, nil +} + +func (VestackTosBucketService) RefreshResourceState(data *schema.ResourceData, strings []string, duration time.Duration, s string) *resource.StateChangeConf { + return nil +} + +func (VestackTosBucketService) WithResourceResponseHandlers(m map[string]interface{}) []ve.ResourceResponseHandler { + return nil +} + +func (VestackTosBucketService) CreateResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { + return nil +} + +func (VestackTosBucketService) ModifyResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { + return nil +} + +func (VestackTosBucketService) RemoveResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { + return nil +} + +func (s *VestackTosBucketService) DatasourceResources(data *schema.ResourceData, resource *schema.Resource) ve.DataSourceInfo { + + name, ok := data.GetOk("bucket_name") + return ve.DataSourceInfo{ + ServiceCategory: ve.ServiceTos, + RequestConverts: map[string]ve.RequestConvert{ + "bucket_name": { + Ignore: true, + }, + }, + NameField: "Name", + IdField: "BucketId", + CollectField: "buckets", + ResponseConverts: map[string]ve.ResponseConvert{}, + ExtraData: func(sourceData []interface{}) (extraData []interface{}, err error) { + for _, v := range sourceData { + if ok { + if name.(string) == v.(map[string]interface{})["Name"].(string) { + v.(map[string]interface{})["BucketId"] = s.Client.Region + ":" + v.(map[string]interface{})["Name"].(string) + extraData = append(extraData, v) + break + } else { + continue + } + } else { + v.(map[string]interface{})["BucketId"] = s.Client.Region + ":" + v.(map[string]interface{})["Name"].(string) + extraData = append(extraData, v) + } + + } + return extraData, err + }, + } +} + +func (VestackTosBucketService) ReadResourceId(s string) string { + return s[strings.Index(s, ":")+1:] +} From 3ccb496a083461e00bcecea990458d7585c38c60 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Mon, 20 Jun 2022 11:15:39 +0800 Subject: [PATCH 03/21] feat: support tos --- common/common_vestack_callback.go | 40 +++++++++----- example/dataTosBuckets/main.tf | 2 +- .../tos/bucket/service_vestack_tos_bucket.go | 53 +++++++++++++++++-- 3 files changed, 78 insertions(+), 17 deletions(-) diff --git a/common/common_vestack_callback.go b/common/common_vestack_callback.go index ecb7ec52..1d19de86 100644 --- a/common/common_vestack_callback.go +++ b/common/common_vestack_callback.go @@ -15,19 +15,20 @@ type Callback struct { } type SdkCall struct { - Action string - BeforeCall BeforeCallFunc - ExecuteCall ExecuteCallFunc - CallError CallErrorFunc - AfterCall AfterCallFunc - Convert map[string]RequestConvert - ConvertMode RequestConvertMode - SdkParam *map[string]interface{} - RequestIdField string - Refresh *StateRefresh - ExtraRefresh map[ResourceService]*StateRefresh - ContentType RequestContentType - LockId LockId + Action string + BeforeCall BeforeCallFunc + ExecuteCall ExecuteCallFunc + CallError CallErrorFunc + AfterCall AfterCallFunc + Convert map[string]RequestConvert + ConvertMode RequestConvertMode + SdkParam *map[string]interface{} + RequestIdField string + Refresh *StateRefresh + ExtraRefresh map[ResourceService]*StateRefresh + ContentType RequestContentType + LockId LockId + ServiceCategory ServiceCategory } type StateRefresh struct { @@ -159,6 +160,19 @@ func CallProcess(calls []SdkCall, d *schema.ResourceData, client *SdkClient, ser resp *map[string]interface{} ) doExecute := true + + switch fn.ServiceCategory { + case ServiceTos: + var trans map[string]interface{} + trans, err = convertToTosParams(fn.Convert, *fn.SdkParam) + if err != nil { + return err + } + fn.SdkParam = &trans + case DefaultServiceCategory: + break + } + if fn.BeforeCall != nil { doExecute, err = fn.BeforeCall(d, client, fn) } diff --git a/example/dataTosBuckets/main.tf b/example/dataTosBuckets/main.tf index a6ca42fe..c6fe63a4 100644 --- a/example/dataTosBuckets/main.tf +++ b/example/dataTosBuckets/main.tf @@ -1,3 +1,3 @@ data "vestack_tos_buckets" "default" { - name_regex= "test" +# name_regex= "test" } \ No newline at end of file diff --git a/vestack/tos/bucket/service_vestack_tos_bucket.go b/vestack/tos/bucket/service_vestack_tos_bucket.go index 12a867d4..45a2a4f1 100644 --- a/vestack/tos/bucket/service_vestack_tos_bucket.go +++ b/vestack/tos/bucket/service_vestack_tos_bucket.go @@ -79,15 +79,59 @@ func (VestackTosBucketService) WithResourceResponseHandlers(m map[string]interfa return nil } -func (VestackTosBucketService) CreateResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { - return nil +func (s *VestackTosBucketService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { + //create bucket + callback := ve.Callback{ + Call: ve.SdkCall{ + ServiceCategory: ve.ServiceTos, + Action: "CreateBucket", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "bucket_name": { + ConvertType: ve.ConvertDefault, + TargetField: "BucketName", + SpecialParam: &ve.SpecialParam{ + Type: ve.DomainParam, + }, + }, + "tos_acl": { + ConvertType: ve.ConvertDefault, + TargetField: "x-tos-acl", + SpecialParam: &ve.SpecialParam{ + Type: ve.HeaderParam, + }, + }, + "tos_storage_class": { + ConvertType: ve.ConvertDefault, + TargetField: "tos-storage-class", + SpecialParam: &ve.SpecialParam{ + Type: ve.HeaderParam, + }, + }, + }, + ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + //创建Bucket + return s.Client.TosClient.DoTosCall(ve.TosInfo{ + HttpMethod: ve.PUT, + Domain: (*call.SdkParam)[ve.TosDomain].(string), + Header: (*call.SdkParam)[ve.TosHeader].(map[string]string), + }, nil) + }, + AfterCall: func(d *schema.ResourceData, client *ve.SdkClient, resp *map[string]interface{}, call ve.SdkCall) error { + d.SetId(s.Client.Region + ":" + (*call.SdkParam)[ve.TosDomain].(string)) + return nil + }, + }, + } + return []ve.Callback{callback} } func (VestackTosBucketService) ModifyResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { return nil } -func (VestackTosBucketService) RemoveResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VestackTosBucketService) RemoveResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { return nil } @@ -107,6 +151,9 @@ func (s *VestackTosBucketService) DatasourceResources(data *schema.ResourceData, ResponseConverts: map[string]ve.ResponseConvert{}, ExtraData: func(sourceData []interface{}) (extraData []interface{}, err error) { for _, v := range sourceData { + if v.(map[string]interface{})["Location"].(string) != s.Client.Region { + continue + } if ok { if name.(string) == v.(map[string]interface{})["Name"].(string) { v.(map[string]interface{})["BucketId"] = s.Client.Region + ":" + v.(map[string]interface{})["Name"].(string) From cbbe5b2750e11a76e61b476291f8f04f1b9f27f1 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Mon, 20 Jun 2022 20:50:04 +0800 Subject: [PATCH 04/21] feat: for_tos --- common/common_vestack_tos_handler.go | 6 +- common/common_vestack_tos_utils.go | 12 +- example/dataTosBuckets/main.tf | 2 +- example/tosBucket/main.tf | 5 + vestack/provider.go | 3 + .../tos/bucket/resource_vestack_tos_bucket.go | 100 +++++++++++ .../tos/bucket/service_vestack_tos_bucket.go | 156 ++++++++++++++++-- 7 files changed, 262 insertions(+), 22 deletions(-) create mode 100644 example/tosBucket/main.tf create mode 100644 vestack/tos/bucket/resource_vestack_tos_bucket.go diff --git a/common/common_vestack_tos_handler.go b/common/common_vestack_tos_handler.go index 87147674..0a2f4b84 100644 --- a/common/common_vestack_tos_handler.go +++ b/common/common_vestack_tos_handler.go @@ -346,14 +346,18 @@ func tosUnmarshal(r *request.Request) { } if reflect.TypeOf(r.Data) == reflect.TypeOf(&map[string]interface{}{}) { + (*r.Data.(*map[string]interface{}))[TosHeader] = r.HTTPResponse.Header + temp := make(map[string]interface{}) if len(body) == 0 { + (*r.Data.(*map[string]interface{}))[TosResponse] = temp return } - if err = json.Unmarshal(body, &r.Data); err != nil { + if err = json.Unmarshal(body, &temp); err != nil { fmt.Printf("Unmarshal err, %v\n", err) r.Error = err return } + (*r.Data.(*map[string]interface{}))[TosResponse] = temp } } diff --git a/common/common_vestack_tos_utils.go b/common/common_vestack_tos_utils.go index 4666552d..6d5c0709 100644 --- a/common/common_vestack_tos_utils.go +++ b/common/common_vestack_tos_utils.go @@ -8,10 +8,11 @@ import ( ) const ( - TosPath = "PATH" - TosDomain = "DOMAIN" - TosHeader = "HEADER" - TosParam = "PARAM" + TosPath = "PATH" + TosDomain = "DOMAIN" + TosHeader = "HEADER" + TosParam = "PARAM" + TosResponse = "RESPONSE" ) func convertToTosParams(convert map[string]RequestConvert, condition map[string]interface{}) (result map[string]interface{}, err error) { @@ -40,7 +41,6 @@ func convertToTosParams(convert map[string]RequestConvert, condition map[string] result[TosDomain] = v1 delete(condition, k1) } - break case HeaderParam: if v1, ok := condition[k1]; ok { if _, ok1 := v1.(string); !ok1 { @@ -49,7 +49,6 @@ func convertToTosParams(convert map[string]RequestConvert, condition map[string] result[TosHeader].(map[string]string)[k1] = v1.(string) delete(condition, k1) } - break case PathParam: if v1, ok := condition[k1]; ok { if _, ok1 := v1.(string); !ok1 { @@ -61,7 +60,6 @@ func convertToTosParams(convert map[string]RequestConvert, condition map[string] delete(condition, k1) } } - break } } //sort diff --git a/example/dataTosBuckets/main.tf b/example/dataTosBuckets/main.tf index c6fe63a4..a6ca42fe 100644 --- a/example/dataTosBuckets/main.tf +++ b/example/dataTosBuckets/main.tf @@ -1,3 +1,3 @@ data "vestack_tos_buckets" "default" { -# name_regex= "test" + name_regex= "test" } \ No newline at end of file diff --git a/example/tosBucket/main.tf b/example/tosBucket/main.tf new file mode 100644 index 00000000..e53595a1 --- /dev/null +++ b/example/tosBucket/main.tf @@ -0,0 +1,5 @@ +resource "vestack_tos_bucket" "default" { + bucket_name = "test-xym-tf" + tos_storage_class ="IA" + tos_acl = "public-read" +} \ No newline at end of file diff --git a/vestack/provider.go b/vestack/provider.go index b8b71db5..9cd35177 100644 --- a/vestack/provider.go +++ b/vestack/provider.go @@ -145,6 +145,9 @@ func Provider() terraform.ResourceProvider { // ================ NAT ================ "vestack_snat_entry": snat_entry.ResourceVestackSnatEntry(), "vestack_nat_gateway": nat_gateway.ResourceVestackNatGateway(), + + //================= TOS ================= + "vestack_tos_bucket": bucket.ResourceVestackTosBucket(), }, ConfigureFunc: ProviderConfigure, } diff --git a/vestack/tos/bucket/resource_vestack_tos_bucket.go b/vestack/tos/bucket/resource_vestack_tos_bucket.go new file mode 100644 index 00000000..b3bca0ad --- /dev/null +++ b/vestack/tos/bucket/resource_vestack_tos_bucket.go @@ -0,0 +1,100 @@ +package bucket + +import ( + "fmt" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + ve "github.com/volcengine/terraform-provider-vestack/common" +) + +/* + +Import +VPC can be imported using the id, e.g. +``` +$ terraform import vestack_vpc.default vpc-mizl7m1kqccg5smt1bdpijuj +``` + +*/ + +func ResourceVestackTosBucket() *schema.Resource { + resource := &schema.Resource{ + Create: resourceVestackTosBucketCreate, + Read: resourceVestackTosBucketRead, + Update: resourceVestackTosBucketUpdate, + Delete: resourceVestackTosBucketDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "bucket_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The name of the bucket.", + }, + "tos_acl": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "private", + "public-read", + "public-read-write", + "authenticated-read", + "bucket-owner-read", + }, false), + Default: "private", + Description: "The public acl control of bucket.", + }, + "tos_storage_class": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + "STANDARD", + "IA", + }, false), + Default: "STANDARD", + Description: "The storage type of the bucket.", + }, + }, + } + return resource +} + +func resourceVestackTosBucketCreate(d *schema.ResourceData, meta interface{}) (err error) { + tosBucketService := NewTosBucketService(meta.(*ve.SdkClient)) + err = tosBucketService.Dispatcher.Create(tosBucketService, d, ResourceVestackTosBucket()) + if err != nil { + return fmt.Errorf("error on creating tos bucket %q, %s", d.Id(), err) + } + return resourceVestackTosBucketRead(d, meta) +} + +func resourceVestackTosBucketRead(d *schema.ResourceData, meta interface{}) (err error) { + tosBucketService := NewTosBucketService(meta.(*ve.SdkClient)) + err = tosBucketService.Dispatcher.Read(tosBucketService, d, ResourceVestackTosBucket()) + if err != nil { + return fmt.Errorf("error on reading tos bucket %q, %s", d.Id(), err) + } + return err +} + +func resourceVestackTosBucketUpdate(d *schema.ResourceData, meta interface{}) (err error) { + tosBucketService := NewTosBucketService(meta.(*ve.SdkClient)) + err = tosBucketService.Dispatcher.Update(tosBucketService, d, ResourceVestackTosBucket()) + if err != nil { + return fmt.Errorf("error on updating tos bucket %q, %s", d.Id(), err) + } + return resourceVestackTosBucketRead(d, meta) +} + +func resourceVestackTosBucketDelete(d *schema.ResourceData, meta interface{}) (err error) { + tosBucketService := NewTosBucketService(meta.(*ve.SdkClient)) + err = tosBucketService.Dispatcher.Delete(tosBucketService, d, ResourceVestackTosBucket()) + if err != nil { + return fmt.Errorf("error on deleting tos bucket %q, %s", d.Id(), err) + } + return err +} diff --git a/vestack/tos/bucket/service_vestack_tos_bucket.go b/vestack/tos/bucket/service_vestack_tos_bucket.go index 45a2a4f1..35921647 100644 --- a/vestack/tos/bucket/service_vestack_tos_bucket.go +++ b/vestack/tos/bucket/service_vestack_tos_bucket.go @@ -2,6 +2,7 @@ package bucket import ( "fmt" + "net/http" "strings" "time" @@ -42,7 +43,7 @@ func (s *VestackTosBucketService) ReadResources(condition map[string]interface{} if err != nil { return data, err } - results, err = ve.ObtainSdkValue("Buckets", *resp) + results, err = ve.ObtainSdkValue(ve.TosResponse+".Buckets", *resp) if err != nil { return data, err } @@ -51,20 +52,54 @@ func (s *VestackTosBucketService) ReadResources(condition map[string]interface{} } func (s *VestackTosBucketService) ReadResource(resourceData *schema.ResourceData, instanceId string) (data map[string]interface{}, err error) { + tos := s.Client.TosClient var ( - results []interface{} - ok bool + action string + resp *map[string]interface{} + ok bool + header *http.Header + acl map[string]interface{} ) - results, err = s.ReadResources(nil) + + if instanceId == "" { + instanceId = s.ReadResourceId(resourceData.Id()) + } else { + instanceId = s.ReadResourceId(instanceId) + } + + action = "HeadBucket" + logger.Debug(logger.ReqFormat, action, instanceId) + resp, err = tos.DoTosCall(ve.TosInfo{ + HttpMethod: ve.HEAD, + Domain: instanceId, + }, nil) if err != nil { return data, err } - for _, v := range results { - if data, ok = v.(map[string]interface{}); !ok { - return data, fmt.Errorf("Value is not map ") + data = make(map[string]interface{}) + + if header, ok = (*resp)[ve.TosHeader].(*http.Header); ok { + if header.Get("x-tos-storage-class") != "" { + data["TosStorageClass"] = header.Get("x-tos-storage-class") } } + action = "GetBucketAcl" + req := map[string]interface{}{ + "acl": "", + } + logger.Debug(logger.ReqFormat, action, req) + resp, err = tos.DoTosCall(ve.TosInfo{ + HttpMethod: ve.GET, + Domain: instanceId, + }, &req) + if err != nil { + return data, err + } + if acl, ok = (*resp)[ve.TosResponse].(map[string]interface{}); ok { + data["TosAcl"] = acl + } + if len(data) == 0 { return data, fmt.Errorf("bucket %s not exist ", instanceId) } @@ -76,7 +111,64 @@ func (VestackTosBucketService) RefreshResourceState(data *schema.ResourceData, s } func (VestackTosBucketService) WithResourceResponseHandlers(m map[string]interface{}) []ve.ResourceResponseHandler { - return nil + handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { + return m, map[string]ve.ResponseConvert{ + "TosAcl": { + Convert: func(i interface{}) interface{} { + owner, _ := ve.ObtainSdkValue("Owner.ID", i) + grants, _ := ve.ObtainSdkValue("Grants", i) + logger.Debug(logger.RespFormat, "CreateBucket", owner) + var ( + read bool + write bool + ) + for _, grant := range grants.([]interface{}) { + id, _ := ve.ObtainSdkValue("Grantee.ID", grant) + canned, _ := ve.ObtainSdkValue("Grantee.Canned", grant) + t, _ := ve.ObtainSdkValue("Grantee.Type", grant) + permission, _ := ve.ObtainSdkValue("Permission", grant) + if canned != nil && canned.(string) == "AllUsers" && t.(string) == "Group" { + if permission.(string) == "READ" { + read = true + continue + } else if permission.(string) == "WRITE" { + write = true + continue + } + } + + if canned != nil && canned.(string) == "AuthenticatedUsers" && t.(string) == "Group" { + if permission.(string) == "READ" { + return "authenticated-read" + } + break + } + + logger.Debug(logger.RespFormat, "CreateBucket", id) + logger.Debug(logger.RespFormat, "CreateBucket", t) + if id != nil && id.(string) == owner.(string) && t.(string) == "CanonicalUser" { + if permission.(string) == "FULL_CONTROL" { + return "private" + } else if permission.(string) == "READ" { + return "bucket-owner-read" + } + break + + } + + } + if read && !write { + return "public-read" + } + if read && write { + return "public-read-write" + } + return "" + }, + }, + }, nil + } + return []ve.ResourceResponseHandler{handler} } func (s *VestackTosBucketService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { @@ -103,7 +195,7 @@ func (s *VestackTosBucketService) CreateResource(resourceData *schema.ResourceDa }, "tos_storage_class": { ConvertType: ve.ConvertDefault, - TargetField: "tos-storage-class", + TargetField: "x-tos-storage-class", SpecialParam: &ve.SpecialParam{ Type: ve.HeaderParam, }, @@ -131,8 +223,43 @@ func (VestackTosBucketService) ModifyResource(data *schema.ResourceData, resourc return nil } -func (s *VestackTosBucketService) RemoveResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { - return nil +func (s *VestackTosBucketService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { + callback := ve.Callback{ + Call: ve.SdkCall{ + Action: "DeleteBucket", + ConvertMode: ve.RequestConvertIgnore, + SdkParam: &map[string]interface{}{ + "BucketName": s.ReadResourceId(resourceData.Id()), + }, + ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + //删除Bucket + return s.Client.TosClient.DoTosCall(ve.TosInfo{ + HttpMethod: ve.DELETE, + Domain: (*call.SdkParam)["BucketName"].(string), + }, nil) + }, + CallError: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall, baseErr error) error { + //出现错误后重试 + return resource.Retry(15*time.Minute, func() *resource.RetryError { + _, callErr := s.ReadResource(d, "") + if callErr != nil { + if ve.ResourceNotFoundError(callErr) { + return nil + } else { + return resource.NonRetryableError(fmt.Errorf("error on reading tos on delete %q, %w", s.ReadResourceId(d.Id()), callErr)) + } + } + _, callErr = call.ExecuteCall(d, client, call) + if callErr == nil { + return nil + } + return resource.RetryableError(callErr) + }) + }, + }, + } + return []ve.Callback{callback} } func (s *VestackTosBucketService) DatasourceResources(data *schema.ResourceData, resource *schema.Resource) ve.DataSourceInfo { @@ -173,6 +300,9 @@ func (s *VestackTosBucketService) DatasourceResources(data *schema.ResourceData, } } -func (VestackTosBucketService) ReadResourceId(s string) string { - return s[strings.Index(s, ":")+1:] +func (s *VestackTosBucketService) ReadResourceId(id string) string { + if strings.HasPrefix(id, s.Client.Region+":") { + return id[strings.Index(id, ":")+1:] + } + return id } From bea7125e0475bd4d538dd5c34e51b1d46b4c32e0 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Tue, 21 Jun 2022 15:01:07 +0800 Subject: [PATCH 05/21] feat: for_tos --- common/common_vestack_const.go | 1 + common/common_vestack_tos_client.go | 18 +++- common/common_vestack_tos_handler.go | 23 ++++- common/common_vestack_tos_utils.go | 18 +++- common/common_vestack_universal_client.go | 4 +- .../tos/bucket/resource_vestack_tos_bucket.go | 5 + .../tos/bucket/service_vestack_tos_bucket.go | 92 +++++++++++++++++-- 7 files changed, 145 insertions(+), 16 deletions(-) diff --git a/common/common_vestack_const.go b/common/common_vestack_const.go index 853d7843..870e0d1c 100644 --- a/common/common_vestack_const.go +++ b/common/common_vestack_const.go @@ -43,4 +43,5 @@ const ( DomainParam SpecialParamType = iota HeaderParam PathParam + UrlParam ) diff --git a/common/common_vestack_tos_client.go b/common/common_vestack_tos_client.go index bfffbb0f..aeebfd43 100644 --- a/common/common_vestack_tos_client.go +++ b/common/common_vestack_tos_client.go @@ -11,13 +11,20 @@ import ( "github.com/volcengine/volcstack-go-sdk/volcstack/session" ) +const ( + TosInfoUrlParam = "TOS_URL_PARAM" + TosInfoInput = "TOS_INPUT" +) + type Tos struct { Session *session.Session } type TosInfo struct { + ContentType ContentType HttpMethod HttpMethod Path []string + UrlParam map[string]string Header map[string]string Domain string ContentPath string @@ -90,6 +97,7 @@ func (u *Tos) newTosClient(domain string) *client.Client { func (u *Tos) DoTosCall(info TosInfo, input *map[string]interface{}) (output *map[string]interface{}, err error) { c := u.newTosClient(info.Domain) + trueInput := make(map[string]interface{}) var httpPath string if len(info.Path) > 0 { @@ -105,8 +113,16 @@ func (u *Tos) DoTosCall(info TosInfo, input *map[string]interface{}) (output *ma if input == nil { input = &map[string]interface{}{} } + trueInput[TosInfoInput] = input + if len(info.UrlParam) > 0 { + trueInput[TosInfoUrlParam] = info.UrlParam + } output = &map[string]interface{}{} - req := c.NewRequest(op, input, output) + req := c.NewRequest(op, &trueInput, output) + + if getContentType(info.ContentType) == "application/json" { + req.HTTPRequest.Header.Set("Content-Type", "application/json; charset=utf-8") + } if info.ContentPath != "" && (op.HTTPMethod == "PUT" || op.HTTPMethod == "POST") { content, _ := ioutil.ReadFile(info.ContentPath) diff --git a/common/common_vestack_tos_handler.go b/common/common_vestack_tos_handler.go index 0a2f4b84..c5ad6909 100644 --- a/common/common_vestack_tos_handler.go +++ b/common/common_vestack_tos_handler.go @@ -57,6 +57,18 @@ func tosSign(req *request.Request) { func tosBuild(r *request.Request) { body := url.Values{} + params := r.Params + if reflect.TypeOf(r.Params) == reflect.TypeOf(&map[string]interface{}{}) { + if v, ok := (*r.Params.(*map[string]interface{}))[TosInfoUrlParam]; ok { + for k1, v1 := range v.(map[string]string) { + body.Add(k1, v1) + } + } + if v, ok := (*r.Params.(*map[string]interface{}))[TosInfoInput]; ok { + params = v + } + } + if r.Config.ExtraUserAgent != nil && *r.Config.ExtraUserAgent != "" { if strings.HasPrefix(*r.Config.ExtraUserAgent, "/") { request.AddToUserAgent(r, *r.Config.ExtraUserAgent) @@ -69,8 +81,15 @@ func tosBuild(r *request.Request) { r.HTTPRequest.URL.RawQuery = body.Encode() r.HTTPRequest.Host = r.HTTPRequest.URL.Host - if reflect.TypeOf(r.Params) == reflect.TypeOf(&map[string]interface{}{}) { - m := *(r.Params).(*map[string]interface{}) + v := r.HTTPRequest.Header.Get("Content-Type") + if len(v) > 0 && strings.Contains(strings.ToLower(v), "application/json") { + b, _ := json.Marshal(params) + r.SetStringBody(string(b)) + return + } + + if reflect.TypeOf(params) == reflect.TypeOf(&map[string]interface{}{}) { + m := *(params).(*map[string]interface{}) for k, v := range m { if reflect.TypeOf(v).String() == "string" { body.Add(k, v.(string)) diff --git a/common/common_vestack_tos_utils.go b/common/common_vestack_tos_utils.go index 6d5c0709..482ae7a0 100644 --- a/common/common_vestack_tos_utils.go +++ b/common/common_vestack_tos_utils.go @@ -12,16 +12,18 @@ const ( TosDomain = "DOMAIN" TosHeader = "HEADER" TosParam = "PARAM" + TosUrlParam = "URL_PARAM" TosResponse = "RESPONSE" ) func convertToTosParams(convert map[string]RequestConvert, condition map[string]interface{}) (result map[string]interface{}, err error) { if len(condition) > 0 { result = map[string]interface{}{ - TosDomain: "", - TosHeader: make(map[string]string), - TosPath: []string{}, - TosParam: condition, + TosDomain: "", + TosHeader: make(map[string]string), + TosPath: []string{}, + TosParam: condition, + TosUrlParam: make(map[string]string), } if len(convert) > 0 { @@ -41,6 +43,14 @@ func convertToTosParams(convert map[string]RequestConvert, condition map[string] result[TosDomain] = v1 delete(condition, k1) } + case UrlParam: + if v1, ok := condition[k1]; ok { + if _, ok1 := v1.(string); !ok1 { + return result, fmt.Errorf("%s must a string type", k) + } + result[TosUrlParam].(map[string]string)[k1] = v1.(string) + delete(condition, k1) + } case HeaderParam: if v1, ok := condition[k1]; ok { if _, ok1 := v1.(string); !ok1 { diff --git a/common/common_vestack_universal_client.go b/common/common_vestack_universal_client.go index 9ad3c210..2be67842 100644 --- a/common/common_vestack_universal_client.go +++ b/common/common_vestack_universal_client.go @@ -87,7 +87,7 @@ func (u *Universal) getMethod(m HttpMethod) string { } } -func (u *Universal) getContentType(m ContentType) string { +func getContentType(m ContentType) string { switch m { case ApplicationJSON: return "application/json" @@ -109,7 +109,7 @@ func (u *Universal) DoCall(info UniversalInfo, input *map[string]interface{}) (o output = &map[string]interface{}{} req := c.NewRequest(op, input, output) - if u.getContentType(info.ContentType) == "application/json" { + if getContentType(info.ContentType) == "application/json" { req.HTTPRequest.Header.Set("Content-Type", "application/json; charset=utf-8") } err = req.Send() diff --git a/vestack/tos/bucket/resource_vestack_tos_bucket.go b/vestack/tos/bucket/resource_vestack_tos_bucket.go index b3bca0ad..c3119d66 100644 --- a/vestack/tos/bucket/resource_vestack_tos_bucket.go +++ b/vestack/tos/bucket/resource_vestack_tos_bucket.go @@ -58,6 +58,11 @@ func ResourceVestackTosBucket() *schema.Resource { Default: "STANDARD", Description: "The storage type of the bucket.", }, + "enable_version": { + Type: schema.TypeBool, + Optional: true, + Description: "The flag of enable tos version.", + }, }, } return resource diff --git a/vestack/tos/bucket/service_vestack_tos_bucket.go b/vestack/tos/bucket/service_vestack_tos_bucket.go index 35921647..c6dd7323 100644 --- a/vestack/tos/bucket/service_vestack_tos_bucket.go +++ b/vestack/tos/bucket/service_vestack_tos_bucket.go @@ -54,11 +54,12 @@ func (s *VestackTosBucketService) ReadResources(condition map[string]interface{} func (s *VestackTosBucketService) ReadResource(resourceData *schema.ResourceData, instanceId string) (data map[string]interface{}, err error) { tos := s.Client.TosClient var ( - action string - resp *map[string]interface{} - ok bool - header *http.Header - acl map[string]interface{} + action string + resp *map[string]interface{} + ok bool + header *http.Header + acl map[string]interface{} + version map[string]interface{} ) if instanceId == "" { @@ -100,6 +101,22 @@ func (s *VestackTosBucketService) ReadResource(resourceData *schema.ResourceData data["TosAcl"] = acl } + action = "GetBucketVersioning" + req = map[string]interface{}{ + "versioning": "", + } + logger.Debug(logger.ReqFormat, action, req) + resp, err = tos.DoTosCall(ve.TosInfo{ + HttpMethod: ve.GET, + Domain: instanceId, + }, &req) + if err != nil { + return data, err + } + if version, ok = (*resp)[ve.TosResponse].(map[string]interface{}); ok { + data["EnableVersion"] = version + } + if len(data) == 0 { return data, fmt.Errorf("bucket %s not exist ", instanceId) } @@ -113,6 +130,15 @@ func (VestackTosBucketService) RefreshResourceState(data *schema.ResourceData, s func (VestackTosBucketService) WithResourceResponseHandlers(m map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return m, map[string]ve.ResponseConvert{ + "EnableVersion": { + Convert: func(i interface{}) interface{} { + status, _ := ve.ObtainSdkValue("Status", i) + if status.(string) != "Enabled" { + return false + } + return true + }, + }, "TosAcl": { Convert: func(i interface{}) interface{} { owner, _ := ve.ObtainSdkValue("Owner.ID", i) @@ -216,7 +242,60 @@ func (s *VestackTosBucketService) CreateResource(resourceData *schema.ResourceDa }, }, } - return []ve.Callback{callback} + //version + callbackVersion := ve.Callback{ + Call: ve.SdkCall{ + ContentType: ve.ContentTypeJson, + ServiceCategory: ve.ServiceTos, + Action: "PutBucketVersioning", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "bucket_name": { + ConvertType: ve.ConvertDefault, + TargetField: "BucketName", + SpecialParam: &ve.SpecialParam{ + Type: ve.DomainParam, + }, + }, + "enable_version": { + ConvertType: ve.ConvertDefault, + TargetField: "Status", + Convert: func(data *schema.ResourceData, i interface{}) interface{} { + if i.(bool) { + return "Enabled" + } else { + return "" + } + }, + ForceGet: true, + }, + }, + BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + //if disable version,skip this call + if (*call.SdkParam)[ve.TosParam].(map[string]interface{})["Status"] == "" { + return false, nil + } + return true, nil + }, + ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + //PutVersion + condition := (*call.SdkParam)[ve.TosParam].(map[string]interface{}) + return s.Client.TosClient.DoTosCall(ve.TosInfo{ + HttpMethod: ve.PUT, + Domain: (*call.SdkParam)[ve.TosDomain].(string), + UrlParam: map[string]string{ + "versioning": "", + }, + }, &condition) + }, + AfterCall: func(d *schema.ResourceData, client *ve.SdkClient, resp *map[string]interface{}, call ve.SdkCall) error { + d.SetId(s.Client.Region + ":" + (*call.SdkParam)[ve.TosDomain].(string)) + return nil + }, + }, + } + return []ve.Callback{callback, callbackVersion} } func (VestackTosBucketService) ModifyResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { @@ -240,7 +319,6 @@ func (s *VestackTosBucketService) RemoveResource(resourceData *schema.ResourceDa }, nil) }, CallError: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall, baseErr error) error { - //出现错误后重试 return resource.Retry(15*time.Minute, func() *resource.RetryError { _, callErr := s.ReadResource(d, "") if callErr != nil { From 9f8ab8eb5081dee99ee2c8615eee056338471db1 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Wed, 22 Jun 2022 15:57:10 +0800 Subject: [PATCH 06/21] feat: for_tos --- common/common_vestack_callback.go | 4 +- common/common_vestack_callback_test.go | 10 +- common/common_vestack_dispatcher.go | 2 +- common/common_vestack_tos_utils.go | 4 +- example/tosBucket/main.tf | 13 +- .../tos/bucket/common_vestack_tos_bucket.go | 19 + .../tos/bucket/resource_vestack_tos_bucket.go | 37 +- .../tos/bucket/service_vestack_tos_bucket.go | 331 ++++++++++++++++-- 8 files changed, 380 insertions(+), 40 deletions(-) create mode 100644 vestack/tos/bucket/common_vestack_tos_bucket.go diff --git a/common/common_vestack_callback.go b/common/common_vestack_callback.go index 4690ba82..1826e94f 100644 --- a/common/common_vestack_callback.go +++ b/common/common_vestack_callback.go @@ -70,7 +70,7 @@ func (c *SdkCall) InitWriteCall(resourceData *schema.ResourceData, resource *sch return err } -func sortAndStartTransJson(source map[string]interface{}) map[string]interface{} { +func SortAndStartTransJson(source map[string]interface{}) map[string]interface{} { target := make(map[string]interface{}) var a []string for k := range source { @@ -184,7 +184,7 @@ func CallProcess(calls []SdkCall, d *schema.ResourceData, client *SdkClient, ser case ContentTypeDefault: break case ContentTypeJson: - jsonParam := sortAndStartTransJson(*fn.SdkParam) + jsonParam := SortAndStartTransJson(*fn.SdkParam) fn.SdkParam = &jsonParam break } diff --git a/common/common_vestack_callback_test.go b/common/common_vestack_callback_test.go index 8644279d..9f519cfe 100644 --- a/common/common_vestack_callback_test.go +++ b/common/common_vestack_callback_test.go @@ -16,12 +16,12 @@ func TestSortAndStartTransJson1(t *testing.T) { "ClusterId": "12345", }, } - resp := sortAndStartTransJson(req) + resp := SortAndStartTransJson(req) assert.Equal(t, resp, target) } func TestSortAndStartTransJson2(t *testing.T) { - req := sortAndStartTransJson(map[string]interface{}{ + req := SortAndStartTransJson(map[string]interface{}{ "Filter.Ids.1": "id123", "Filter.Ids.2": "id456", }) @@ -30,12 +30,12 @@ func TestSortAndStartTransJson2(t *testing.T) { "Ids": []interface{}{"id123", "id456"}, }, } - resp := sortAndStartTransJson(req) + resp := SortAndStartTransJson(req) assert.Equal(t, resp, target) } func TestSortAndStartTransJson3(t *testing.T) { - req := sortAndStartTransJson(map[string]interface{}{ + req := SortAndStartTransJson(map[string]interface{}{ "Filter.ClusterId": "12345", "Filter.Ids.1": "id123", "Filter.Ids.2": "id456", @@ -61,7 +61,7 @@ func TestSortAndStartTransJson3(t *testing.T) { }, }, } - resp := sortAndStartTransJson(req) + resp := SortAndStartTransJson(req) assert.Equal(t, resp, target) str := `{"Filter":{"ClusterId":"12345","Ids":["id123","id456"],"Nets":[{"Subnet":"subnet1"},{"Subnet":"subnet2"},{"Subnet":"subnet3"}]}}` diff --git a/common/common_vestack_dispatcher.go b/common/common_vestack_dispatcher.go index eece172e..aa4fe69f 100644 --- a/common/common_vestack_dispatcher.go +++ b/common/common_vestack_dispatcher.go @@ -94,7 +94,7 @@ func (d *Dispatcher) Data(resourceService ResourceService, resourceDate *schema. return err } if info.ContentType == ContentTypeJson { - condition = sortAndStartTransJson(condition) + condition = SortAndStartTransJson(condition) } switch info.ServiceCategory { case ServiceTos: diff --git a/common/common_vestack_tos_utils.go b/common/common_vestack_tos_utils.go index 482ae7a0..6a366c4d 100644 --- a/common/common_vestack_tos_utils.go +++ b/common/common_vestack_tos_utils.go @@ -56,7 +56,9 @@ func convertToTosParams(convert map[string]RequestConvert, condition map[string] if _, ok1 := v1.(string); !ok1 { return result, fmt.Errorf("%s must a string type", k) } - result[TosHeader].(map[string]string)[k1] = v1.(string) + if v1.(string) != "" { + result[TosHeader].(map[string]string)[k1] = v1.(string) + } delete(condition, k1) } case PathParam: diff --git a/example/tosBucket/main.tf b/example/tosBucket/main.tf index e53595a1..736e220f 100644 --- a/example/tosBucket/main.tf +++ b/example/tosBucket/main.tf @@ -1,5 +1,14 @@ resource "vestack_tos_bucket" "default" { bucket_name = "test-xym-tf" - tos_storage_class ="IA" - tos_acl = "public-read" + storage_class ="IA" + public_acl = "private" + enable_version = true + account_acl { + account_id = "1" + permission = "READ" + } + account_acl { + account_id = "2000" + permission = "WRITE_ACP" + } } \ No newline at end of file diff --git a/vestack/tos/bucket/common_vestack_tos_bucket.go b/vestack/tos/bucket/common_vestack_tos_bucket.go new file mode 100644 index 00000000..e84b4b4e --- /dev/null +++ b/vestack/tos/bucket/common_vestack_tos_bucket.go @@ -0,0 +1,19 @@ +package bucket + +import ( + "bytes" + "fmt" + + "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" +) + +func tosAccountAclHash(v interface{}) int { + if v == nil { + return hashcode.String("") + } + m := v.(map[string]interface{}) + buf := bytes.Buffer{} + buf.WriteString(fmt.Sprintf("%s-", m["account_id"])) + buf.WriteString(fmt.Sprintf("%s", m["permission"])) + return hashcode.String(buf.String()) +} diff --git a/vestack/tos/bucket/resource_vestack_tos_bucket.go b/vestack/tos/bucket/resource_vestack_tos_bucket.go index c3119d66..58e0cba8 100644 --- a/vestack/tos/bucket/resource_vestack_tos_bucket.go +++ b/vestack/tos/bucket/resource_vestack_tos_bucket.go @@ -34,7 +34,7 @@ func ResourceVestackTosBucket() *schema.Resource { ForceNew: true, Description: "The name of the bucket.", }, - "tos_acl": { + "public_acl": { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringInSlice([]string{ @@ -47,7 +47,7 @@ func ResourceVestackTosBucket() *schema.Resource { Default: "private", Description: "The public acl control of bucket.", }, - "tos_storage_class": { + "storage_class": { Type: schema.TypeString, Optional: true, ForceNew: true, @@ -63,6 +63,39 @@ func ResourceVestackTosBucket() *schema.Resource { Optional: true, Description: "The flag of enable tos version.", }, + "account_acl": { + Type: schema.TypeSet, + Optional: true, + Description: "The user set of grant full control.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "account_id": { + Type: schema.TypeString, + Required: true, + }, + "acl_type": { + Type: schema.TypeString, + Optional: true, + Default: "CanonicalUser", + ValidateFunc: validation.StringInSlice([]string{ + "CanonicalUser", + }, false), + }, + "permission": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + "FULL_CONTROL", + "READ", + "READ_ACP", + "WRITE", + "WRITE_ACP", + }, false), + }, + }, + }, + Set: tosAccountAclHash, + }, }, } return resource diff --git a/vestack/tos/bucket/service_vestack_tos_bucket.go b/vestack/tos/bucket/service_vestack_tos_bucket.go index c6dd7323..39cf5df9 100644 --- a/vestack/tos/bucket/service_vestack_tos_bucket.go +++ b/vestack/tos/bucket/service_vestack_tos_bucket.go @@ -98,7 +98,8 @@ func (s *VestackTosBucketService) ReadResource(resourceData *schema.ResourceData return data, err } if acl, ok = (*resp)[ve.TosResponse].(map[string]interface{}); ok { - data["TosAcl"] = acl + data["PublicAcl"] = acl + data["AccountAcl"] = acl } action = "GetBucketVersioning" @@ -123,11 +124,24 @@ func (s *VestackTosBucketService) ReadResource(resourceData *schema.ResourceData return data, nil } -func (VestackTosBucketService) RefreshResourceState(data *schema.ResourceData, strings []string, duration time.Duration, s string) *resource.StateChangeConf { +func (s *VestackTosBucketService) RefreshResourceState(data *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return nil } -func (VestackTosBucketService) WithResourceResponseHandlers(m map[string]interface{}) []ve.ResourceResponseHandler { +func (s *VestackTosBucketService) getIdPermission(p string, grants []interface{}) []interface{} { + var result []interface{} + for _, grant := range grants { + permission, _ := ve.ObtainSdkValue("Permission", grant) + id, _ := ve.ObtainSdkValue("Grantee.ID", grant) + t, _ := ve.ObtainSdkValue("Grantee.Type", grant) + if id != nil && t.(string) == "CanonicalUser" && p == permission.(string) { + result = append(result, "Id="+id.(string)) + } + } + return result +} + +func (s *VestackTosBucketService) WithResourceResponseHandlers(m map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return m, map[string]ve.ResponseConvert{ "EnableVersion": { @@ -139,11 +153,34 @@ func (VestackTosBucketService) WithResourceResponseHandlers(m map[string]interfa return true }, }, - "TosAcl": { + "AccountAcl": { + Convert: func(i interface{}) interface{} { + var accountAcl []interface{} + owner, _ := ve.ObtainSdkValue("Owner.ID", i) + grants, _ := ve.ObtainSdkValue("Grants", i) + for _, grant := range grants.([]interface{}) { + permission, _ := ve.ObtainSdkValue("Permission", grant) + id, _ := ve.ObtainSdkValue("Grantee.ID", grant) + if id == nil { + continue + } + if id == owner && permission == "FULL_CONTROL" { + continue + } + g := map[string]interface{}{ + "AccountId": id, + "AclType": "CanonicalUser", + "Permission": permission, + } + accountAcl = append(accountAcl, g) + } + return accountAcl + }, + }, + "PublicAcl": { Convert: func(i interface{}) interface{} { owner, _ := ve.ObtainSdkValue("Owner.ID", i) grants, _ := ve.ObtainSdkValue("Grants", i) - logger.Debug(logger.RespFormat, "CreateBucket", owner) var ( read bool write bool @@ -170,8 +207,6 @@ func (VestackTosBucketService) WithResourceResponseHandlers(m map[string]interfa break } - logger.Debug(logger.RespFormat, "CreateBucket", id) - logger.Debug(logger.RespFormat, "CreateBucket", t) if id != nil && id.(string) == owner.(string) && t.(string) == "CanonicalUser" { if permission.(string) == "FULL_CONTROL" { return "private" @@ -212,14 +247,14 @@ func (s *VestackTosBucketService) CreateResource(resourceData *schema.ResourceDa Type: ve.DomainParam, }, }, - "tos_acl": { + "public_acl": { ConvertType: ve.ConvertDefault, TargetField: "x-tos-acl", SpecialParam: &ve.SpecialParam{ Type: ve.HeaderParam, }, }, - "tos_storage_class": { + "storage_class": { ConvertType: ve.ConvertDefault, TargetField: "x-tos-storage-class", SpecialParam: &ve.SpecialParam{ @@ -245,7 +280,6 @@ func (s *VestackTosBucketService) CreateResource(resourceData *schema.ResourceDa //version callbackVersion := ve.Callback{ Call: ve.SdkCall{ - ContentType: ve.ContentTypeJson, ServiceCategory: ve.ServiceTos, Action: "PutBucketVersioning", ConvertMode: ve.RequestConvertInConvert, @@ -277,29 +311,138 @@ func (s *VestackTosBucketService) CreateResource(resourceData *schema.ResourceDa } return true, nil }, - ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { - logger.Debug(logger.RespFormat, call.Action, call.SdkParam) - //PutVersion - condition := (*call.SdkParam)[ve.TosParam].(map[string]interface{}) - return s.Client.TosClient.DoTosCall(ve.TosInfo{ - HttpMethod: ve.PUT, - Domain: (*call.SdkParam)[ve.TosDomain].(string), - UrlParam: map[string]string{ - "versioning": "", + ExecuteCall: s.executePutBucketVersioning(), + }, + } + //acl + callbackAcl := ve.Callback{ + Call: ve.SdkCall{ + ServiceCategory: ve.ServiceTos, + Action: "PutBucketAcl", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "bucket_name": { + ConvertType: ve.ConvertDefault, + TargetField: "BucketName", + SpecialParam: &ve.SpecialParam{ + Type: ve.DomainParam, }, - }, &condition) - }, - AfterCall: func(d *schema.ResourceData, client *ve.SdkClient, resp *map[string]interface{}, call ve.SdkCall) error { - d.SetId(s.Client.Region + ":" + (*call.SdkParam)[ve.TosDomain].(string)) - return nil + }, + "account_acl": { + ConvertType: ve.ConvertListN, + TargetField: "Grants", + NextLevelConvert: map[string]ve.RequestConvert{ + "account_id": { + ConvertType: ve.ConvertDefault, + TargetField: "Grantee.ID", + }, + "acl_type": { + ConvertType: ve.ConvertDefault, + TargetField: "Grantee.Type", + }, + "permission": { + ConvertType: ve.ConvertDefault, + TargetField: "Permission", + }, + }, + }, }, + BeforeCall: s.beforePutBucketAcl(), + ExecuteCall: s.executePutBucketAcl(), }, } - return []ve.Callback{callback, callbackVersion} + return []ve.Callback{callback, callbackVersion, callbackAcl} } -func (VestackTosBucketService) ModifyResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { - return nil +func (s *VestackTosBucketService) ModifyResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { + var callbacks []ve.Callback + if data.HasChange("enable_version") { + //version + callbackVersion := ve.Callback{ + Call: ve.SdkCall{ + ServiceCategory: ve.ServiceTos, + Action: "PutBucketVersioning", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "bucket_name": { + ConvertType: ve.ConvertDefault, + TargetField: "BucketName", + SpecialParam: &ve.SpecialParam{ + Type: ve.DomainParam, + }, + ForceGet: true, + }, + "enable_version": { + ConvertType: ve.ConvertDefault, + TargetField: "Status", + Convert: func(data *schema.ResourceData, i interface{}) interface{} { + if i.(bool) { + return "Enabled" + } else { + return "Suspended" + } + }, + ForceGet: true, + }, + }, + ExecuteCall: s.executePutBucketVersioning(), + }, + } + callbacks = append(callbacks, callbackVersion) + } + var grant = []string{ + "public_acl", + "account_acl", + } + for _, v := range grant { + if data.HasChange(v) { + callbackAcl := ve.Callback{ + Call: ve.SdkCall{ + ServiceCategory: ve.ServiceTos, + Action: "PutBucketAcl", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "bucket_name": { + ConvertType: ve.ConvertDefault, + TargetField: "BucketName", + SpecialParam: &ve.SpecialParam{ + Type: ve.DomainParam, + }, + ForceGet: true, + }, + "account_acl": { + ConvertType: ve.ConvertListN, + TargetField: "Grants", + NextLevelConvert: map[string]ve.RequestConvert{ + "account_id": { + ConvertType: ve.ConvertDefault, + TargetField: "Grantee.ID", + ForceGet: true, + }, + "acl_type": { + ConvertType: ve.ConvertDefault, + TargetField: "Grantee.Type", + ForceGet: true, + }, + "permission": { + ConvertType: ve.ConvertDefault, + TargetField: "Permission", + ForceGet: true, + }, + }, + ForceGet: true, + }, + }, + BeforeCall: s.beforePutBucketAcl(), + ExecuteCall: s.executePutBucketAcl(), + }, + } + callbacks = append(callbacks, callbackAcl) + break + } + } + + return callbacks } func (s *VestackTosBucketService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { @@ -384,3 +527,137 @@ func (s *VestackTosBucketService) ReadResourceId(id string) string { } return id } + +func (s *VestackTosBucketService) mergePublicAcl(acl string, param *map[string]interface{}, ownerId string) { + if _, ok := (*param)["Grants"]; !ok { + (*param)["Grants"] = []interface{}{} + } + vs := (*param)["Grants"].([]interface{}) + + defer func() { + (*param)["Grants"] = vs + }() + + switch acl { + case "private": + m := map[string]interface{}{ + "Grantee": map[string]interface{}{ + "Id": ownerId, + "Type": "CanonicalUser", + }, + "Permission": "FULL_CONTROL", + } + vs = append(vs, m) + return + case "public-read": + m := map[string]interface{}{ + "Grantee": map[string]interface{}{ + "Canned": "AllUsers", + "Type": "Group", + }, + "Permission": "READ", + } + vs = append(vs, m) + return + case "public-read-write": + m := map[string]interface{}{ + "Grantee": map[string]interface{}{ + "Canned": "AllUsers", + "Type": "Group", + }, + "Permission": "WRITE", + } + vs = append(vs, m) + return + case "authenticated-read": + m := map[string]interface{}{ + "Grantee": map[string]interface{}{ + "Canned": "AuthenticatedUsers", + "Type": "Group", + }, + "Permission": "READ", + } + vs = append(vs, m) + return + case "bucket-owner-read": + m := map[string]interface{}{ + "Grantee": map[string]interface{}{ + "Id": ownerId, + "Type": "CanonicalUser", + }, + "Permission": "READ", + } + vs = append(vs, m) + return + } +} + +func (s *VestackTosBucketService) beforePutBucketAcl() ve.BeforeCallFunc { + return func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + //read acl before call and merge all acl + data, err := s.Client.TosClient.DoTosCall(ve.TosInfo{ + HttpMethod: ve.GET, + Domain: (*call.SdkParam)[ve.TosDomain].(string), + UrlParam: map[string]string{ + "acl": "", + }, + }, nil) + if err != nil { + return false, err + } + + sourceAclParam := ve.SortAndStartTransJson((*call.SdkParam)[ve.TosParam].(map[string]interface{})) + ownerId, _ := ve.ObtainSdkValue("Owner.ID", (*data)[ve.TosResponse]) + + grants, _ := ve.ObtainSdkValue("Grants", sourceAclParam) + for _, grant := range grants.([]interface{}) { + id, _ := ve.ObtainSdkValue("Grantee.ID", grant) + p, _ := ve.ObtainSdkValue("Permission", grant) + if id == ownerId && p == "FULL_CONTROL" { + return false, fmt.Errorf("can not set FULL_CONTROL for owner") + } + } + + //merge owner + owner, _ := ve.ObtainSdkValue("Owner", (*data)[ve.TosResponse]) + sourceAclParam["Owner"] = owner + //merge public_acl + s.mergePublicAcl(d.Get("public_acl").(string), &sourceAclParam, ownerId.(string)) + + (*call.SdkParam)[ve.TosParam] = sourceAclParam + return true, nil + } +} + +func (s *VestackTosBucketService) executePutBucketAcl() ve.ExecuteCallFunc { + return func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + //PutAcl + param := (*call.SdkParam)[ve.TosParam].(map[string]interface{}) + return s.Client.TosClient.DoTosCall(ve.TosInfo{ + HttpMethod: ve.PUT, + ContentType: ve.ApplicationJSON, + Domain: (*call.SdkParam)[ve.TosDomain].(string), + Header: (*call.SdkParam)[ve.TosHeader].(map[string]string), + UrlParam: map[string]string{ + "acl": "", + }, + }, ¶m) + } +} + +func (s *VestackTosBucketService) executePutBucketVersioning() ve.ExecuteCallFunc { + return func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + //PutVersion + condition := (*call.SdkParam)[ve.TosParam].(map[string]interface{}) + return s.Client.TosClient.DoTosCall(ve.TosInfo{ + ContentType: ve.ApplicationJSON, + HttpMethod: ve.PUT, + Domain: (*call.SdkParam)[ve.TosDomain].(string), + UrlParam: map[string]string{ + "versioning": "", + }, + }, &condition) + } +} From 5650a7c2d1ed38405a669375e4b704aa9473aa76 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Wed, 22 Jun 2022 19:58:54 +0800 Subject: [PATCH 07/21] feat: for_tos --- example/tosBucket/main.tf | 2 +- .../tos/bucket/resource_vestack_tos_bucket.go | 6 ++++++ .../tos/bucket/service_vestack_tos_bucket.go | 19 ++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/example/tosBucket/main.tf b/example/tosBucket/main.tf index 736e220f..0a26643b 100644 --- a/example/tosBucket/main.tf +++ b/example/tosBucket/main.tf @@ -8,7 +8,7 @@ resource "vestack_tos_bucket" "default" { permission = "READ" } account_acl { - account_id = "2000" + account_id = "2001" permission = "WRITE_ACP" } } \ No newline at end of file diff --git a/vestack/tos/bucket/resource_vestack_tos_bucket.go b/vestack/tos/bucket/resource_vestack_tos_bucket.go index 58e0cba8..f1ba58dc 100644 --- a/vestack/tos/bucket/resource_vestack_tos_bucket.go +++ b/vestack/tos/bucket/resource_vestack_tos_bucket.go @@ -2,6 +2,7 @@ package bucket import ( "fmt" + "time" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -24,6 +25,11 @@ func ResourceVestackTosBucket() *schema.Resource { Read: resourceVestackTosBucketRead, Update: resourceVestackTosBucketUpdate, Delete: resourceVestackTosBucketDelete, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(2 * time.Minute), + Update: schema.DefaultTimeout(2 * time.Minute), + Delete: schema.DefaultTimeout(2 * time.Minute), + }, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, diff --git a/vestack/tos/bucket/service_vestack_tos_bucket.go b/vestack/tos/bucket/service_vestack_tos_bucket.go index 39cf5df9..9f7e0ff7 100644 --- a/vestack/tos/bucket/service_vestack_tos_bucket.go +++ b/vestack/tos/bucket/service_vestack_tos_bucket.go @@ -125,7 +125,16 @@ func (s *VestackTosBucketService) ReadResource(resourceData *schema.ResourceData } func (s *VestackTosBucketService) RefreshResourceState(data *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { - return nil + return &resource.StateChangeConf{ + Pending: []string{}, + Delay: 60 * time.Second, + MinTimeout: 60 * time.Second, + Target: target, + Timeout: timeout, + Refresh: func() (result interface{}, state string, err error) { + return data, "Success", err + }, + } } func (s *VestackTosBucketService) getIdPermission(p string, grants []interface{}) []interface{} { @@ -349,6 +358,10 @@ func (s *VestackTosBucketService) CreateResource(resourceData *schema.ResourceDa }, BeforeCall: s.beforePutBucketAcl(), ExecuteCall: s.executePutBucketAcl(), + Refresh: &ve.StateRefresh{ + Target: []string{"Success"}, + Timeout: resourceData.Timeout(schema.TimeoutCreate), + }, }, } return []ve.Callback{callback, callbackVersion, callbackAcl} @@ -435,6 +448,10 @@ func (s *VestackTosBucketService) ModifyResource(data *schema.ResourceData, reso }, BeforeCall: s.beforePutBucketAcl(), ExecuteCall: s.executePutBucketAcl(), + Refresh: &ve.StateRefresh{ + Target: []string{"Success"}, + Timeout: data.Timeout(schema.TimeoutCreate), + }, }, } callbacks = append(callbacks, callbackAcl) From 872f958664f2f8aa9b0215f6ebae18a52477c9e0 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Thu, 23 Jun 2022 18:10:36 +0800 Subject: [PATCH 08/21] feat: for_tos --- common/common_vestack_const.go | 1 + common/common_vestack_tos_handler.go | 17 +- common/common_vestack_tos_utils.go | 191 ++++++++ example/tosObject/main.tf | 20 + vestack/provider.go | 2 + .../tos/bucket/common_vestack_tos_bucket.go | 19 - .../tos/bucket/resource_vestack_tos_bucket.go | 28 +- .../tos/bucket/service_vestack_tos_bucket.go | 191 +------- .../object/data_source_vestack_tos_objects.go | 72 +++ .../tos/object/resource_vestack_tos_object.go | 179 +++++++ .../tos/object/service_vestack_tos_object.go | 463 ++++++++++++++++++ 11 files changed, 977 insertions(+), 206 deletions(-) create mode 100644 example/tosObject/main.tf delete mode 100644 vestack/tos/bucket/common_vestack_tos_bucket.go create mode 100644 vestack/tos/object/data_source_vestack_tos_objects.go create mode 100644 vestack/tos/object/resource_vestack_tos_object.go create mode 100644 vestack/tos/object/service_vestack_tos_object.go diff --git a/common/common_vestack_const.go b/common/common_vestack_const.go index 870e0d1c..ea519e86 100644 --- a/common/common_vestack_const.go +++ b/common/common_vestack_const.go @@ -44,4 +44,5 @@ const ( HeaderParam PathParam UrlParam + FilePathParam ) diff --git a/common/common_vestack_tos_handler.go b/common/common_vestack_tos_handler.go index c5ad6909..d184887b 100644 --- a/common/common_vestack_tos_handler.go +++ b/common/common_vestack_tos_handler.go @@ -371,12 +371,19 @@ func tosUnmarshal(r *request.Request) { (*r.Data.(*map[string]interface{}))[TosResponse] = temp return } - if err = json.Unmarshal(body, &temp); err != nil { - fmt.Printf("Unmarshal err, %v\n", err) - r.Error = err - return + + if strings.ToLower(r.HTTPResponse.Header.Get("Content-Type")) == "application/json" { + if err = json.Unmarshal(body, &temp); err != nil { + fmt.Printf("Unmarshal err, %v\n", err) + r.Error = err + return + } + (*r.Data.(*map[string]interface{}))[TosResponse] = temp + } else { + (*r.Data.(*map[string]interface{}))[TosResponse] = temp + //(*r.Data.(*map[string]interface{}))[TosPlainResponse] = string(body) } - (*r.Data.(*map[string]interface{}))[TosResponse] = temp + } } diff --git a/common/common_vestack_tos_utils.go b/common/common_vestack_tos_utils.go index 6a366c4d..8d3b75d7 100644 --- a/common/common_vestack_tos_utils.go +++ b/common/common_vestack_tos_utils.go @@ -1,10 +1,14 @@ package common import ( + "bytes" "fmt" "sort" "strconv" "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) const ( @@ -14,6 +18,7 @@ const ( TosParam = "PARAM" TosUrlParam = "URL_PARAM" TosResponse = "RESPONSE" + TosFilePath = "FILE_PATH" ) func convertToTosParams(convert map[string]RequestConvert, condition map[string]interface{}) (result map[string]interface{}, err error) { @@ -71,6 +76,14 @@ func convertToTosParams(convert map[string]RequestConvert, condition map[string] result[TosPath] = temp delete(condition, k1) } + case FilePathParam: + if v1, ok := condition[k1]; ok { + if _, ok1 := v1.(string); !ok1 { + return result, fmt.Errorf("%s must a string type", k) + } + result[TosFilePath] = v1 + delete(condition, k1) + } } } } @@ -90,3 +103,181 @@ func convertToTosParams(convert map[string]RequestConvert, condition map[string] } return result, err } + +func mergeTosPublicAcl(acl string, param *map[string]interface{}, ownerId string) { + if _, ok := (*param)["Grants"]; !ok { + (*param)["Grants"] = []interface{}{} + } + vs := (*param)["Grants"].([]interface{}) + + defer func() { + (*param)["Grants"] = vs + }() + + switch acl { + case "private": + m := map[string]interface{}{ + "Grantee": map[string]interface{}{ + "Id": ownerId, + "Type": "CanonicalUser", + }, + "Permission": "FULL_CONTROL", + } + vs = append(vs, m) + return + case "public-read": + m := map[string]interface{}{ + "Grantee": map[string]interface{}{ + "Canned": "AllUsers", + "Type": "Group", + }, + "Permission": "READ", + } + vs = append(vs, m) + return + case "public-read-write": + m := map[string]interface{}{ + "Grantee": map[string]interface{}{ + "Canned": "AllUsers", + "Type": "Group", + }, + "Permission": "WRITE", + } + vs = append(vs, m) + return + case "authenticated-read": + m := map[string]interface{}{ + "Grantee": map[string]interface{}{ + "Canned": "AuthenticatedUsers", + "Type": "Group", + }, + "Permission": "READ", + } + vs = append(vs, m) + return + case "bucket-owner-read": + m := map[string]interface{}{ + "Grantee": map[string]interface{}{ + "Id": ownerId, + "Type": "CanonicalUser", + }, + "Permission": "READ", + } + vs = append(vs, m) + return + } +} + +func BeforeTosPutAcl(d *schema.ResourceData, call SdkCall, data *map[string]interface{}, err error) (bool, error) { + if err != nil { + return false, err + } + + sourceAclParam := SortAndStartTransJson((*call.SdkParam)[TosParam].(map[string]interface{})) + ownerId, _ := ObtainSdkValue("Owner.ID", (*data)[TosResponse]) + + grants, _ := ObtainSdkValue("Grants", sourceAclParam) + for _, grant := range grants.([]interface{}) { + id, _ := ObtainSdkValue("Grantee.ID", grant) + p, _ := ObtainSdkValue("Permission", grant) + if id == ownerId && p == "FULL_CONTROL" { + return false, fmt.Errorf("can not set FULL_CONTROL for owner") + } + } + + //merge owner + owner, _ := ObtainSdkValue("Owner", (*data)[TosResponse]) + sourceAclParam["Owner"] = owner + //merge public_acl + mergeTosPublicAcl(d.Get("public_acl").(string), &sourceAclParam, ownerId.(string)) + + (*call.SdkParam)[TosParam] = sourceAclParam + return true, nil +} + +func ConvertTosAccountAcl() FieldResponseConvert { + return func(i interface{}) interface{} { + var accountAcl []interface{} + owner, _ := ObtainSdkValue("Owner.ID", i) + grants, _ := ObtainSdkValue("Grants", i) + for _, grant := range grants.([]interface{}) { + permission, _ := ObtainSdkValue("Permission", grant) + id, _ := ObtainSdkValue("Grantee.ID", grant) + if id == nil { + continue + } + if id == owner && permission == "FULL_CONTROL" { + continue + } + g := map[string]interface{}{ + "AccountId": id, + "AclType": "CanonicalUser", + "Permission": permission, + } + accountAcl = append(accountAcl, g) + } + return accountAcl + } +} + +func ConvertTosPublicAcl() FieldResponseConvert { + return func(i interface{}) interface{} { + owner, _ := ObtainSdkValue("Owner.ID", i) + grants, _ := ObtainSdkValue("Grants", i) + var ( + read bool + write bool + ) + for _, grant := range grants.([]interface{}) { + id, _ := ObtainSdkValue("Grantee.ID", grant) + canned, _ := ObtainSdkValue("Grantee.Canned", grant) + t, _ := ObtainSdkValue("Grantee.Type", grant) + permission, _ := ObtainSdkValue("Permission", grant) + if canned != nil && canned.(string) == "AllUsers" && t.(string) == "Group" { + if permission.(string) == "READ" { + read = true + continue + } else if permission.(string) == "WRITE" { + write = true + continue + } + } + + if canned != nil && canned.(string) == "AuthenticatedUsers" && t.(string) == "Group" { + if permission.(string) == "READ" { + return "authenticated-read" + } + break + } + + if id != nil && id.(string) == owner.(string) && t.(string) == "CanonicalUser" { + if permission.(string) == "FULL_CONTROL" { + return "private" + } else if permission.(string) == "READ" { + return "bucket-owner-read" + } + break + + } + + } + if read && !write { + return "public-read" + } + if read && write { + return "public-read-write" + } + return "" + } +} + +func TosAccountAclHash(v interface{}) int { + if v == nil { + return hashcode.String("") + } + m := v.(map[string]interface{}) + buf := bytes.Buffer{} + buf.WriteString(fmt.Sprintf("%s-", m["account_id"])) + buf.WriteString(fmt.Sprintf("%s", m["permission"])) + return hashcode.String(buf.String()) +} diff --git a/example/tosObject/main.tf b/example/tosObject/main.tf new file mode 100644 index 00000000..7d830ea9 --- /dev/null +++ b/example/tosObject/main.tf @@ -0,0 +1,20 @@ +resource "vestack_tos_object" "default" { + bucket_name = "test-xym-tf" + object_name = "demo_xym" + file_path = "/Users/bytedance/Work/Go/build/test.txt" + storage_class ="IA" + public_acl = "private" + encryption = "AES256" + #content_type = "text/plain" + account_acl { + account_id = "1" + permission = "READ" + } + account_acl { + account_id = "2001" + permission = "WRITE_ACP" + } +# lifecycle { +# ignore_changes = ["file_path"] +# } +} \ No newline at end of file diff --git a/vestack/provider.go b/vestack/provider.go index 9cd35177..fe666451 100644 --- a/vestack/provider.go +++ b/vestack/provider.go @@ -23,6 +23,7 @@ import ( "github.com/volcengine/terraform-provider-vestack/vestack/nat/nat_gateway" "github.com/volcengine/terraform-provider-vestack/vestack/nat/snat_entry" "github.com/volcengine/terraform-provider-vestack/vestack/tos/bucket" + "github.com/volcengine/terraform-provider-vestack/vestack/tos/object" "github.com/volcengine/terraform-provider-vestack/vestack/vpc/network_interface" "github.com/volcengine/terraform-provider-vestack/vestack/vpc/network_interface_attach" "github.com/volcengine/terraform-provider-vestack/vestack/vpc/route_entry" @@ -148,6 +149,7 @@ func Provider() terraform.ResourceProvider { //================= TOS ================= "vestack_tos_bucket": bucket.ResourceVestackTosBucket(), + "vestack_tos_object": object.ResourceVestackTosObject(), }, ConfigureFunc: ProviderConfigure, } diff --git a/vestack/tos/bucket/common_vestack_tos_bucket.go b/vestack/tos/bucket/common_vestack_tos_bucket.go deleted file mode 100644 index e84b4b4e..00000000 --- a/vestack/tos/bucket/common_vestack_tos_bucket.go +++ /dev/null @@ -1,19 +0,0 @@ -package bucket - -import ( - "bytes" - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" -) - -func tosAccountAclHash(v interface{}) int { - if v == nil { - return hashcode.String("") - } - m := v.(map[string]interface{}) - buf := bytes.Buffer{} - buf.WriteString(fmt.Sprintf("%s-", m["account_id"])) - buf.WriteString(fmt.Sprintf("%s", m["permission"])) - return hashcode.String(buf.String()) -} diff --git a/vestack/tos/bucket/resource_vestack_tos_bucket.go b/vestack/tos/bucket/resource_vestack_tos_bucket.go index f1ba58dc..3de70476 100644 --- a/vestack/tos/bucket/resource_vestack_tos_bucket.go +++ b/vestack/tos/bucket/resource_vestack_tos_bucket.go @@ -2,6 +2,7 @@ package bucket import ( "fmt" + "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -12,9 +13,9 @@ import ( /* Import -VPC can be imported using the id, e.g. +Tos Bucket can be imported using the id, e.g. ``` -$ terraform import vestack_vpc.default vpc-mizl7m1kqccg5smt1bdpijuj +$ terraform import vestack_tos_bucket.default region:bucketName ``` */ @@ -31,7 +32,14 @@ func ResourceVestackTosBucket() *schema.Resource { Delete: schema.DefaultTimeout(2 * time.Minute), }, Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, + State: func(data *schema.ResourceData, i interface{}) ([]*schema.ResourceData, error) { + items := strings.Split(data.Id(), ":") + if len(items) != 1 { + return []*schema.ResourceData{data}, fmt.Errorf("import id must be of the form bucketName") + } + _ = data.Set("bucket_name", items[0]) + return []*schema.ResourceData{data}, nil + }, }, Schema: map[string]*schema.Schema{ "bucket_name": { @@ -51,7 +59,7 @@ func ResourceVestackTosBucket() *schema.Resource { "bucket-owner-read", }, false), Default: "private", - Description: "The public acl control of bucket.", + Description: "The public acl control of object.Valid value is private|public-read|public-read-write|authenticated-read|bucket-owner-read.", }, "storage_class": { Type: schema.TypeString, @@ -62,13 +70,14 @@ func ResourceVestackTosBucket() *schema.Resource { "IA", }, false), Default: "STANDARD", - Description: "The storage type of the bucket.", + Description: "The storage type of the object.Valid value is STANDARD|IA.", }, "enable_version": { Type: schema.TypeBool, Optional: true, Description: "The flag of enable tos version.", }, + "account_acl": { Type: schema.TypeSet, Optional: true, @@ -76,8 +85,9 @@ func ResourceVestackTosBucket() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "account_id": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "The accountId to control.", }, "acl_type": { Type: schema.TypeString, @@ -86,6 +96,7 @@ func ResourceVestackTosBucket() *schema.Resource { ValidateFunc: validation.StringInSlice([]string{ "CanonicalUser", }, false), + Description: "The acl type to control.Valid value is CanonicalUser.", }, "permission": { Type: schema.TypeString, @@ -97,10 +108,11 @@ func ResourceVestackTosBucket() *schema.Resource { "WRITE", "WRITE_ACP", }, false), + Description: "The permission to control.Valid value is FULL_CONTROL|READ|READ_ACP|WRITE|WRITE_ACP.", }, }, }, - Set: tosAccountAclHash, + Set: ve.TosAccountAclHash, }, }, } diff --git a/vestack/tos/bucket/service_vestack_tos_bucket.go b/vestack/tos/bucket/service_vestack_tos_bucket.go index 9f7e0ff7..efb56175 100644 --- a/vestack/tos/bucket/service_vestack_tos_bucket.go +++ b/vestack/tos/bucket/service_vestack_tos_bucket.go @@ -3,7 +3,6 @@ package bucket import ( "fmt" "net/http" - "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" @@ -57,7 +56,7 @@ func (s *VestackTosBucketService) ReadResource(resourceData *schema.ResourceData action string resp *map[string]interface{} ok bool - header *http.Header + header http.Header acl map[string]interface{} version map[string]interface{} ) @@ -74,14 +73,16 @@ func (s *VestackTosBucketService) ReadResource(resourceData *schema.ResourceData HttpMethod: ve.HEAD, Domain: instanceId, }, nil) + logger.Debug(logger.ReqFormat, action, *resp) + logger.Debug(logger.ReqFormat, action, err) if err != nil { return data, err } data = make(map[string]interface{}) - if header, ok = (*resp)[ve.TosHeader].(*http.Header); ok { - if header.Get("x-tos-storage-class") != "" { - data["TosStorageClass"] = header.Get("x-tos-storage-class") + if header, ok = (*resp)[ve.TosHeader].(http.Header); ok { + if header.Get("X-Tos-Storage-Class") != "" { + data["StorageClass"] = header.Get("X-Tos-Storage-Class") } } @@ -163,78 +164,10 @@ func (s *VestackTosBucketService) WithResourceResponseHandlers(m map[string]inte }, }, "AccountAcl": { - Convert: func(i interface{}) interface{} { - var accountAcl []interface{} - owner, _ := ve.ObtainSdkValue("Owner.ID", i) - grants, _ := ve.ObtainSdkValue("Grants", i) - for _, grant := range grants.([]interface{}) { - permission, _ := ve.ObtainSdkValue("Permission", grant) - id, _ := ve.ObtainSdkValue("Grantee.ID", grant) - if id == nil { - continue - } - if id == owner && permission == "FULL_CONTROL" { - continue - } - g := map[string]interface{}{ - "AccountId": id, - "AclType": "CanonicalUser", - "Permission": permission, - } - accountAcl = append(accountAcl, g) - } - return accountAcl - }, + Convert: ve.ConvertTosAccountAcl(), }, "PublicAcl": { - Convert: func(i interface{}) interface{} { - owner, _ := ve.ObtainSdkValue("Owner.ID", i) - grants, _ := ve.ObtainSdkValue("Grants", i) - var ( - read bool - write bool - ) - for _, grant := range grants.([]interface{}) { - id, _ := ve.ObtainSdkValue("Grantee.ID", grant) - canned, _ := ve.ObtainSdkValue("Grantee.Canned", grant) - t, _ := ve.ObtainSdkValue("Grantee.Type", grant) - permission, _ := ve.ObtainSdkValue("Permission", grant) - if canned != nil && canned.(string) == "AllUsers" && t.(string) == "Group" { - if permission.(string) == "READ" { - read = true - continue - } else if permission.(string) == "WRITE" { - write = true - continue - } - } - - if canned != nil && canned.(string) == "AuthenticatedUsers" && t.(string) == "Group" { - if permission.(string) == "READ" { - return "authenticated-read" - } - break - } - - if id != nil && id.(string) == owner.(string) && t.(string) == "CanonicalUser" { - if permission.(string) == "FULL_CONTROL" { - return "private" - } else if permission.(string) == "READ" { - return "bucket-owner-read" - } - break - - } - - } - if read && !write { - return "public-read" - } - if read && write { - return "public-read-write" - } - return "" - }, + Convert: ve.ConvertTosPublicAcl(), }, }, nil } @@ -281,7 +214,7 @@ func (s *VestackTosBucketService) CreateResource(resourceData *schema.ResourceDa }, nil) }, AfterCall: func(d *schema.ResourceData, client *ve.SdkClient, resp *map[string]interface{}, call ve.SdkCall) error { - d.SetId(s.Client.Region + ":" + (*call.SdkParam)[ve.TosDomain].(string)) + d.SetId((*call.SdkParam)[ve.TosDomain].(string)) return nil }, }, @@ -358,10 +291,10 @@ func (s *VestackTosBucketService) CreateResource(resourceData *schema.ResourceDa }, BeforeCall: s.beforePutBucketAcl(), ExecuteCall: s.executePutBucketAcl(), - Refresh: &ve.StateRefresh{ - Target: []string{"Success"}, - Timeout: resourceData.Timeout(schema.TimeoutCreate), - }, + //Refresh: &ve.StateRefresh{ + // Target: []string{"Success"}, + // Timeout: resourceData.Timeout(schema.TimeoutCreate), + //}, }, } return []ve.Callback{callback, callbackVersion, callbackAcl} @@ -521,14 +454,14 @@ func (s *VestackTosBucketService) DatasourceResources(data *schema.ResourceData, } if ok { if name.(string) == v.(map[string]interface{})["Name"].(string) { - v.(map[string]interface{})["BucketId"] = s.Client.Region + ":" + v.(map[string]interface{})["Name"].(string) + v.(map[string]interface{})["BucketId"] = v.(map[string]interface{})["Name"].(string) extraData = append(extraData, v) break } else { continue } } else { - v.(map[string]interface{})["BucketId"] = s.Client.Region + ":" + v.(map[string]interface{})["Name"].(string) + v.(map[string]interface{})["BucketId"] = v.(map[string]interface{})["Name"].(string) extraData = append(extraData, v) } @@ -539,79 +472,12 @@ func (s *VestackTosBucketService) DatasourceResources(data *schema.ResourceData, } func (s *VestackTosBucketService) ReadResourceId(id string) string { - if strings.HasPrefix(id, s.Client.Region+":") { - return id[strings.Index(id, ":")+1:] - } return id } -func (s *VestackTosBucketService) mergePublicAcl(acl string, param *map[string]interface{}, ownerId string) { - if _, ok := (*param)["Grants"]; !ok { - (*param)["Grants"] = []interface{}{} - } - vs := (*param)["Grants"].([]interface{}) - - defer func() { - (*param)["Grants"] = vs - }() - - switch acl { - case "private": - m := map[string]interface{}{ - "Grantee": map[string]interface{}{ - "Id": ownerId, - "Type": "CanonicalUser", - }, - "Permission": "FULL_CONTROL", - } - vs = append(vs, m) - return - case "public-read": - m := map[string]interface{}{ - "Grantee": map[string]interface{}{ - "Canned": "AllUsers", - "Type": "Group", - }, - "Permission": "READ", - } - vs = append(vs, m) - return - case "public-read-write": - m := map[string]interface{}{ - "Grantee": map[string]interface{}{ - "Canned": "AllUsers", - "Type": "Group", - }, - "Permission": "WRITE", - } - vs = append(vs, m) - return - case "authenticated-read": - m := map[string]interface{}{ - "Grantee": map[string]interface{}{ - "Canned": "AuthenticatedUsers", - "Type": "Group", - }, - "Permission": "READ", - } - vs = append(vs, m) - return - case "bucket-owner-read": - m := map[string]interface{}{ - "Grantee": map[string]interface{}{ - "Id": ownerId, - "Type": "CanonicalUser", - }, - "Permission": "READ", - } - vs = append(vs, m) - return - } -} - func (s *VestackTosBucketService) beforePutBucketAcl() ve.BeforeCallFunc { + return func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { - //read acl before call and merge all acl data, err := s.Client.TosClient.DoTosCall(ve.TosInfo{ HttpMethod: ve.GET, Domain: (*call.SdkParam)[ve.TosDomain].(string), @@ -619,30 +485,7 @@ func (s *VestackTosBucketService) beforePutBucketAcl() ve.BeforeCallFunc { "acl": "", }, }, nil) - if err != nil { - return false, err - } - - sourceAclParam := ve.SortAndStartTransJson((*call.SdkParam)[ve.TosParam].(map[string]interface{})) - ownerId, _ := ve.ObtainSdkValue("Owner.ID", (*data)[ve.TosResponse]) - - grants, _ := ve.ObtainSdkValue("Grants", sourceAclParam) - for _, grant := range grants.([]interface{}) { - id, _ := ve.ObtainSdkValue("Grantee.ID", grant) - p, _ := ve.ObtainSdkValue("Permission", grant) - if id == ownerId && p == "FULL_CONTROL" { - return false, fmt.Errorf("can not set FULL_CONTROL for owner") - } - } - - //merge owner - owner, _ := ve.ObtainSdkValue("Owner", (*data)[ve.TosResponse]) - sourceAclParam["Owner"] = owner - //merge public_acl - s.mergePublicAcl(d.Get("public_acl").(string), &sourceAclParam, ownerId.(string)) - - (*call.SdkParam)[ve.TosParam] = sourceAclParam - return true, nil + return ve.BeforeTosPutAcl(d, call, data, err) } } diff --git a/vestack/tos/object/data_source_vestack_tos_objects.go b/vestack/tos/object/data_source_vestack_tos_objects.go new file mode 100644 index 00000000..84c183b7 --- /dev/null +++ b/vestack/tos/object/data_source_vestack_tos_objects.go @@ -0,0 +1,72 @@ +package object + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + ve "github.com/volcengine/terraform-provider-vestack/common" +) + +func DataSourceVestackTosObject() *schema.Resource { + return &schema.Resource{ + Read: dataSourceVestackTosObjectRead, + Schema: map[string]*schema.Schema{ + "bucket_name": { + Type: schema.TypeString, + Optional: true, + Description: "The name the TOS bucket.", + }, + "object_name": { + Type: schema.TypeString, + Optional: true, + Description: "The name the TOS Object.", + }, + "name_regex": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringIsValidRegExp, + Description: "A Name Regex of TOS Object.", + }, + + "output_file": { + Type: schema.TypeString, + Optional: true, + Description: "File name where to save data source results.", + }, + + "total_count": { + Type: schema.TypeInt, + Computed: true, + Description: "The total count of TOS Object query.", + }, + "objects": { + Description: "The collection of TOS Object query.", + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Computed: true, + Description: "The name the TOS Object.", + }, + "size": { + Type: schema.TypeInt, + Computed: true, + Description: "The name the TOS Object size.", + }, + "storage_class": { + Type: schema.TypeString, + Computed: true, + Description: "The name the TOS Object storage class.", + }, + }, + }, + }, + }, + } +} + +func dataSourceVestackTosObjectRead(d *schema.ResourceData, meta interface{}) error { + tosBucketService := NewTosObjectService(meta.(*ve.SdkClient)) + return tosBucketService.Dispatcher.Data(tosBucketService, d, DataSourceVestackTosObject()) +} diff --git a/vestack/tos/object/resource_vestack_tos_object.go b/vestack/tos/object/resource_vestack_tos_object.go new file mode 100644 index 00000000..5bc1f17a --- /dev/null +++ b/vestack/tos/object/resource_vestack_tos_object.go @@ -0,0 +1,179 @@ +package object + +import ( + "fmt" + "strings" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + ve "github.com/volcengine/terraform-provider-vestack/common" +) + +/* + +Import +TOS Object can be imported using the id, e.g. +``` +$ terraform import vestack_tos_object.default bucketName:objectName +``` + +*/ + +func ResourceVestackTosObject() *schema.Resource { + resource := &schema.Resource{ + Create: resourceVestackTosObjectCreate, + Read: resourceVestackTosObjectRead, + Update: resourceVestackTosObjectUpdate, + Delete: resourceVestackTosObjectDelete, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(2 * time.Minute), + Update: schema.DefaultTimeout(2 * time.Minute), + Delete: schema.DefaultTimeout(2 * time.Minute), + }, + Importer: &schema.ResourceImporter{ + State: func(data *schema.ResourceData, i interface{}) ([]*schema.ResourceData, error) { + items := strings.Split(data.Id(), ":") + if len(items) != 2 { + return []*schema.ResourceData{data}, fmt.Errorf("import id must be of the form bucketName:objectName") + } + _ = data.Set("bucket_name", items[0]) + _ = data.Set("object_name", items[1]) + return []*schema.ResourceData{data}, nil + }, + }, + Schema: map[string]*schema.Schema{ + "bucket_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The name of the bucket.", + }, + "object_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The name of the object.", + }, + "file_path": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The file path for upload.", + }, + "encryption": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + "AES256", + }, false), + Description: "The encryption of the object.Valid value is AES256.", + }, + "content_type": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Computed: true, + Description: "The content type of the object.", + }, + "public_acl": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "private", + "public-read", + "public-read-write", + "authenticated-read", + "bucket-owner-read", + }, false), + Default: "private", + Description: "The public acl control of object.Valid value is private|public-read|public-read-write|authenticated-read|bucket-owner-read.", + }, + "storage_class": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + "STANDARD", + "IA", + }, false), + Default: "STANDARD", + Description: "The storage type of the object.Valid value is STANDARD|IA.", + }, + "account_acl": { + Type: schema.TypeSet, + Optional: true, + Description: "The user set of grant full control.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "account_id": { + Type: schema.TypeString, + Required: true, + Description: "The accountId to control.", + }, + "acl_type": { + Type: schema.TypeString, + Optional: true, + Default: "CanonicalUser", + ValidateFunc: validation.StringInSlice([]string{ + "CanonicalUser", + }, false), + Description: "The acl type to control.Valid value is CanonicalUser.", + }, + "permission": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + "FULL_CONTROL", + "READ", + "READ_ACP", + "WRITE", + "WRITE_ACP", + }, false), + Description: "The permission to control.Valid value is FULL_CONTROL|READ|READ_ACP|WRITE|WRITE_ACP.", + }, + }, + }, + Set: ve.TosAccountAclHash, + }, + }, + } + return resource +} + +func resourceVestackTosObjectCreate(d *schema.ResourceData, meta interface{}) (err error) { + tosBucketService := NewTosObjectService(meta.(*ve.SdkClient)) + err = tosBucketService.Dispatcher.Create(tosBucketService, d, ResourceVestackTosObject()) + if err != nil { + return fmt.Errorf("error on creating tos bucket %q, %s", d.Id(), err) + } + return resourceVestackTosObjectRead(d, meta) +} + +func resourceVestackTosObjectRead(d *schema.ResourceData, meta interface{}) (err error) { + tosBucketService := NewTosObjectService(meta.(*ve.SdkClient)) + err = tosBucketService.Dispatcher.Read(tosBucketService, d, ResourceVestackTosObject()) + if err != nil { + return fmt.Errorf("error on reading tos bucket %q, %s", d.Id(), err) + } + return err +} + +func resourceVestackTosObjectUpdate(d *schema.ResourceData, meta interface{}) (err error) { + tosBucketService := NewTosObjectService(meta.(*ve.SdkClient)) + err = tosBucketService.Dispatcher.Update(tosBucketService, d, ResourceVestackTosObject()) + if err != nil { + return fmt.Errorf("error on updating tos bucket %q, %s", d.Id(), err) + } + return resourceVestackTosObjectRead(d, meta) +} + +func resourceVestackTosObjectDelete(d *schema.ResourceData, meta interface{}) (err error) { + tosBucketService := NewTosObjectService(meta.(*ve.SdkClient)) + err = tosBucketService.Dispatcher.Delete(tosBucketService, d, ResourceVestackTosObject()) + if err != nil { + return fmt.Errorf("error on deleting tos bucket %q, %s", d.Id(), err) + } + return err +} diff --git a/vestack/tos/object/service_vestack_tos_object.go b/vestack/tos/object/service_vestack_tos_object.go new file mode 100644 index 00000000..5a62ffee --- /dev/null +++ b/vestack/tos/object/service_vestack_tos_object.go @@ -0,0 +1,463 @@ +package object + +import ( + "fmt" + "net/http" + "strings" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + ve "github.com/volcengine/terraform-provider-vestack/common" + "github.com/volcengine/terraform-provider-vestack/logger" +) + +type VestackTosObjectService struct { + Client *ve.SdkClient + Dispatcher *ve.Dispatcher +} + +func NewTosObjectService(c *ve.SdkClient) *VestackTosObjectService { + return &VestackTosObjectService{ + Client: c, + Dispatcher: &ve.Dispatcher{}, + } +} + +func (s *VestackTosObjectService) GetClient() *ve.SdkClient { + return s.Client +} + +func (s *VestackTosObjectService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { + tos := s.Client.TosClient + var ( + action string + resp *map[string]interface{} + results interface{} + ) + action = "ListObjects" + logger.Debug(logger.ReqFormat, action, nil) + resp, err = tos.DoTosCall(ve.TosInfo{ + HttpMethod: ve.GET, + Domain: condition[ve.TosDomain].(string), + }, nil) + if err != nil { + return data, err + } + results, err = ve.ObtainSdkValue(ve.TosResponse+".Contents", *resp) + if err != nil { + return data, err + } + data = results.([]interface{}) + return data, err +} + +func (s *VestackTosObjectService) ReadResource(resourceData *schema.ResourceData, instanceId string) (data map[string]interface{}, err error) { + tos := s.Client.TosClient + bucketName := resourceData.Get("bucket_name").(string) + var ( + action string + resp *map[string]interface{} + ok bool + header http.Header + acl map[string]interface{} + ) + + if instanceId == "" { + instanceId = s.ReadResourceId(resourceData.Id()) + } else { + instanceId = s.ReadResourceId(instanceId) + } + + action = "HeadObject" + logger.Debug(logger.ReqFormat, action, bucketName+":"+instanceId) + resp, err = tos.DoTosCall(ve.TosInfo{ + HttpMethod: ve.HEAD, + Domain: bucketName, + Path: []string{instanceId}, + }, nil) + if err != nil { + return data, err + } + data = make(map[string]interface{}) + + if header, ok = (*resp)[ve.TosHeader].(http.Header); ok { + if header.Get("X-Tos-Storage-Class") != "" { + data["StorageClass"] = header.Get("x-tos-storage-class") + } + if header.Get("Content-Type") != "" { + data["ContentType"] = header.Get("Content-Type") + } + if header.Get("X-Tos-Server-Side-Encryption") != "" { + data["Encryption"] = header.Get("X-Tos-Server-Side-Encryption") + } + } + + action = "GetObjectAcl" + req := map[string]interface{}{ + "acl": "", + } + logger.Debug(logger.ReqFormat, action, req) + resp, err = tos.DoTosCall(ve.TosInfo{ + HttpMethod: ve.GET, + Domain: bucketName, + Path: []string{instanceId}, + }, &req) + if err != nil { + return data, err + } + if acl, ok = (*resp)[ve.TosResponse].(map[string]interface{}); ok { + data["PublicAcl"] = acl + data["AccountAcl"] = acl + } + + if len(data) == 0 { + return data, fmt.Errorf("object %s not exist ", instanceId) + } + return data, nil +} + +func (s *VestackTosObjectService) RefreshResourceState(data *schema.ResourceData, target []string, timeout time.Duration, instanceId string) *resource.StateChangeConf { + return &resource.StateChangeConf{ + Pending: []string{}, + Delay: 60 * time.Second, + MinTimeout: 60 * time.Second, + Target: target, + Timeout: timeout, + Refresh: func() (result interface{}, state string, err error) { + return data, "Success", err + }, + } +} + +func (VestackTosObjectService) WithResourceResponseHandlers(m map[string]interface{}) []ve.ResourceResponseHandler { + handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { + return m, map[string]ve.ResponseConvert{ + "AccountAcl": { + Convert: ve.ConvertTosAccountAcl(), + }, + "PublicAcl": { + Convert: ve.ConvertTosPublicAcl(), + }, + }, nil + } + return []ve.ResourceResponseHandler{handler} +} + +func (s *VestackTosObjectService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { + //create object + callback := ve.Callback{ + Call: ve.SdkCall{ + ServiceCategory: ve.ServiceTos, + Action: "CreateObject", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "bucket_name": { + ConvertType: ve.ConvertDefault, + TargetField: "BucketName", + SpecialParam: &ve.SpecialParam{ + Type: ve.DomainParam, + }, + }, + "object_name": { + ConvertType: ve.ConvertDefault, + TargetField: "ObjectName", + SpecialParam: &ve.SpecialParam{ + Type: ve.PathParam, + Index: 0, + }, + }, + "public_acl": { + ConvertType: ve.ConvertDefault, + TargetField: "x-tos-acl", + SpecialParam: &ve.SpecialParam{ + Type: ve.HeaderParam, + }, + }, + "storage_class": { + ConvertType: ve.ConvertDefault, + TargetField: "x-tos-storage-class", + SpecialParam: &ve.SpecialParam{ + Type: ve.HeaderParam, + }, + }, + "content_type": { + ConvertType: ve.ConvertDefault, + TargetField: "content-type", + SpecialParam: &ve.SpecialParam{ + Type: ve.HeaderParam, + }, + }, + "file_path": { + ConvertType: ve.ConvertDefault, + TargetField: "file-path", + SpecialParam: &ve.SpecialParam{ + Type: ve.FilePathParam, + }, + }, + "encryption": { + ConvertType: ve.ConvertDefault, + TargetField: "x-tos-server-side-encryption", + SpecialParam: &ve.SpecialParam{ + Type: ve.HeaderParam, + }, + }, + }, + ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + //创建Object + return s.Client.TosClient.DoTosCall(ve.TosInfo{ + HttpMethod: ve.PUT, + Domain: (*call.SdkParam)[ve.TosDomain].(string), + Header: (*call.SdkParam)[ve.TosHeader].(map[string]string), + Path: (*call.SdkParam)[ve.TosPath].([]string), + ContentPath: (*call.SdkParam)[ve.TosFilePath].(string), + }, nil) + }, + AfterCall: func(d *schema.ResourceData, client *ve.SdkClient, resp *map[string]interface{}, call ve.SdkCall) error { + d.SetId((*call.SdkParam)[ve.TosDomain].(string) + ":" + (*call.SdkParam)[ve.TosPath].([]string)[0]) + return nil + }, + }, + } + //acl + callbackAcl := ve.Callback{ + Call: ve.SdkCall{ + ServiceCategory: ve.ServiceTos, + Action: "PutObjectAcl", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "bucket_name": { + ConvertType: ve.ConvertDefault, + TargetField: "BucketName", + SpecialParam: &ve.SpecialParam{ + Type: ve.DomainParam, + }, + }, + "object_name": { + ConvertType: ve.ConvertDefault, + TargetField: "ObjectName", + SpecialParam: &ve.SpecialParam{ + Type: ve.PathParam, + Index: 0, + }, + }, + "account_acl": { + ConvertType: ve.ConvertListN, + TargetField: "Grants", + NextLevelConvert: map[string]ve.RequestConvert{ + "account_id": { + ConvertType: ve.ConvertDefault, + TargetField: "Grantee.ID", + }, + "acl_type": { + ConvertType: ve.ConvertDefault, + TargetField: "Grantee.Type", + }, + "permission": { + ConvertType: ve.ConvertDefault, + TargetField: "Permission", + }, + }, + }, + }, + BeforeCall: s.beforePutObjectAcl(), + ExecuteCall: s.executePutObjectAcl(), + //Refresh: &ve.StateRefresh{ + // Target: []string{"Success"}, + // Timeout: resourceData.Timeout(schema.TimeoutCreate), + //}, + }, + } + return []ve.Callback{callback, callbackAcl} +} + +func (s *VestackTosObjectService) ModifyResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { + var callbacks []ve.Callback + + var grant = []string{ + "public_acl", + "account_acl", + } + for _, v := range grant { + if data.HasChange(v) { + callbackAcl := ve.Callback{ + Call: ve.SdkCall{ + ServiceCategory: ve.ServiceTos, + Action: "PutBucketAcl", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "bucket_name": { + ConvertType: ve.ConvertDefault, + TargetField: "BucketName", + SpecialParam: &ve.SpecialParam{ + Type: ve.DomainParam, + }, + ForceGet: true, + }, + "object_name": { + ConvertType: ve.ConvertDefault, + TargetField: "ObjectName", + SpecialParam: &ve.SpecialParam{ + Type: ve.PathParam, + Index: 0, + }, + }, + "account_acl": { + ConvertType: ve.ConvertListN, + TargetField: "Grants", + NextLevelConvert: map[string]ve.RequestConvert{ + "account_id": { + ConvertType: ve.ConvertDefault, + TargetField: "Grantee.ID", + ForceGet: true, + }, + "acl_type": { + ConvertType: ve.ConvertDefault, + TargetField: "Grantee.Type", + ForceGet: true, + }, + "permission": { + ConvertType: ve.ConvertDefault, + TargetField: "Permission", + ForceGet: true, + }, + }, + ForceGet: true, + }, + }, + BeforeCall: s.beforePutObjectAcl(), + ExecuteCall: s.executePutObjectAcl(), + Refresh: &ve.StateRefresh{ + Target: []string{"Success"}, + Timeout: data.Timeout(schema.TimeoutCreate), + }, + }, + } + callbacks = append(callbacks, callbackAcl) + break + } + } + + return callbacks +} + +func (s *VestackTosObjectService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { + callback := ve.Callback{ + Call: ve.SdkCall{ + Action: "DeleteObject", + ConvertMode: ve.RequestConvertIgnore, + SdkParam: &map[string]interface{}{ + "BucketName": resourceData.Get("bucket_name"), + "ObjectName": s.ReadResourceId(resourceData.Id()), + }, + ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + //删除Object + return s.Client.TosClient.DoTosCall(ve.TosInfo{ + HttpMethod: ve.DELETE, + Domain: (*call.SdkParam)["BucketName"].(string), + Path: []string{(*call.SdkParam)["ObjectName"].(string)}, + }, nil) + }, + CallError: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall, baseErr error) error { + return resource.Retry(15*time.Minute, func() *resource.RetryError { + _, callErr := s.ReadResource(d, "") + if callErr != nil { + if ve.ResourceNotFoundError(callErr) { + return nil + } else { + return resource.NonRetryableError(fmt.Errorf("error on reading tos object on delete %q, %w", s.ReadResourceId(d.Id()), callErr)) + } + } + _, callErr = call.ExecuteCall(d, client, call) + if callErr == nil { + return nil + } + return resource.RetryableError(callErr) + }) + }, + }, + } + return []ve.Callback{callback} +} + +func (s *VestackTosObjectService) DatasourceResources(data *schema.ResourceData, resource *schema.Resource) ve.DataSourceInfo { + name, ok := data.GetOk("object_name") + bucketName, _ := data.GetOk("bucket_name") + return ve.DataSourceInfo{ + ServiceCategory: ve.ServiceTos, + RequestConverts: map[string]ve.RequestConvert{ + "bucket_name": { + ConvertType: ve.ConvertDefault, + SpecialParam: &ve.SpecialParam{ + Type: ve.DomainParam, + }, + }, + "object_name": { + Ignore: true, + }, + }, + NameField: "Key", + IdField: "ObjectId", + CollectField: "objects", + ResponseConverts: map[string]ve.ResponseConvert{ + "Key": { + TargetField: "name", + }, + }, + ExtraData: func(sourceData []interface{}) (extraData []interface{}, err error) { + for _, v := range sourceData { + if ok { + if name.(string) == v.(map[string]interface{})["Key"].(string) { + v.(map[string]interface{})["ObjectId"] = bucketName.(string) + ":" + v.(map[string]interface{})["Key"].(string) + extraData = append(extraData, v) + break + } else { + continue + } + } else { + v.(map[string]interface{})["ObjectId"] = bucketName.(string) + ":" + v.(map[string]interface{})["Key"].(string) + extraData = append(extraData, v) + } + + } + return extraData, err + }, + } +} + +func (s *VestackTosObjectService) ReadResourceId(id string) string { + return id[strings.Index(id, ":")+1:] +} + +func (s *VestackTosObjectService) beforePutObjectAcl() ve.BeforeCallFunc { + return func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + data, err := s.Client.TosClient.DoTosCall(ve.TosInfo{ + HttpMethod: ve.GET, + Domain: (*call.SdkParam)[ve.TosDomain].(string), + Path: (*call.SdkParam)[ve.TosPath].([]string), + UrlParam: map[string]string{ + "acl": "", + }, + }, nil) + return ve.BeforeTosPutAcl(d, call, data, err) + } +} + +func (s *VestackTosObjectService) executePutObjectAcl() ve.ExecuteCallFunc { + return func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + //PutAcl + param := (*call.SdkParam)[ve.TosParam].(map[string]interface{}) + return s.Client.TosClient.DoTosCall(ve.TosInfo{ + HttpMethod: ve.PUT, + ContentType: ve.ApplicationJSON, + Domain: (*call.SdkParam)[ve.TosDomain].(string), + Path: (*call.SdkParam)[ve.TosPath].([]string), + UrlParam: map[string]string{ + "acl": "", + }, + }, ¶m) + } +} From cfb98b0cbffd7085cd20ff0b9e140dfc2043797d Mon Sep 17 00:00:00 2001 From: xuyaming Date: Fri, 24 Jun 2022 17:43:26 +0800 Subject: [PATCH 09/21] feat: for_tos --- common/common_vestack_tos_handler.go | 46 ++++++------------- example/tosBucket/main.tf | 4 +- example/tosObject/main.tf | 4 +- .../tos/object/resource_vestack_tos_object.go | 5 ++ .../tos/object/service_vestack_tos_object.go | 10 +++- 5 files changed, 32 insertions(+), 37 deletions(-) diff --git a/common/common_vestack_tos_handler.go b/common/common_vestack_tos_handler.go index d184887b..ba7807d9 100644 --- a/common/common_vestack_tos_handler.go +++ b/common/common_vestack_tos_handler.go @@ -19,6 +19,7 @@ import ( "github.com/volcengine/volcstack-go-sdk/volcstack" "github.com/volcengine/volcstack-go-sdk/volcstack/request" + "github.com/volcengine/volcstack-go-sdk/volcstack/volcstackbody" "github.com/volcengine/volcstack-go-sdk/volcstack/volcstackerr" ) @@ -69,46 +70,27 @@ func tosBuild(r *request.Request) { } } + r.Params = params + + r.HTTPRequest.Host = r.HTTPRequest.URL.Host if r.Config.ExtraUserAgent != nil && *r.Config.ExtraUserAgent != "" { if strings.HasPrefix(*r.Config.ExtraUserAgent, "/") { request.AddToUserAgent(r, *r.Config.ExtraUserAgent) } else { request.AddToUserAgent(r, "/"+*r.Config.ExtraUserAgent) } - } - - r.HTTPRequest.URL.RawQuery = body.Encode() - r.HTTPRequest.Host = r.HTTPRequest.URL.Host - - v := r.HTTPRequest.Header.Get("Content-Type") - if len(v) > 0 && strings.Contains(strings.ToLower(v), "application/json") { - b, _ := json.Marshal(params) - r.SetStringBody(string(b)) - return - } - - if reflect.TypeOf(params) == reflect.TypeOf(&map[string]interface{}{}) { - m := *(params).(*map[string]interface{}) - for k, v := range m { - if reflect.TypeOf(v).String() == "string" { - body.Add(k, v.(string)) - } else { - body.Add(k, fmt.Sprintf("%v", v)) - } - } - } - - r.HTTPRequest.URL.Query() - if r.Config.ExtraHttpParameters != nil { - extra := r.Config.ExtraHttpParameters(r.Context()) - if extra != nil { - for k, value := range extra { - body.Add(k, value) - } - } + contentType := r.HTTPRequest.Header.Get("Content-Type") + if (strings.ToUpper(r.HTTPRequest.Method) == "PUT" || + strings.ToUpper(r.HTTPRequest.Method) == "POST" || + strings.ToUpper(r.HTTPRequest.Method) == "DELETE" || + strings.ToUpper(r.HTTPRequest.Method) == "PATCH") && + strings.Contains(strings.ToLower(contentType), "application/json") { + r.HTTPRequest.Header.Set("Content-Type", "application/json; charset=utf-8") + volcstackbody.BodyJson(&body, r) + } else { + volcstackbody.BodyParam(&body, r) } - r.HTTPRequest.URL.RawQuery = body.Encode() } type tosMetadata struct { diff --git a/example/tosBucket/main.tf b/example/tosBucket/main.tf index 0a26643b..77a557a0 100644 --- a/example/tosBucket/main.tf +++ b/example/tosBucket/main.tf @@ -1,6 +1,6 @@ resource "vestack_tos_bucket" "default" { - bucket_name = "test-xym-tf" - storage_class ="IA" + bucket_name = "test-xym-1" +# storage_class ="IA" public_acl = "private" enable_version = true account_acl { diff --git a/example/tosObject/main.tf b/example/tosObject/main.tf index 7d830ea9..dbb6fdea 100644 --- a/example/tosObject/main.tf +++ b/example/tosObject/main.tf @@ -1,8 +1,8 @@ resource "vestack_tos_object" "default" { - bucket_name = "test-xym-tf" + bucket_name = "test-xym-1" object_name = "demo_xym" file_path = "/Users/bytedance/Work/Go/build/test.txt" - storage_class ="IA" +# storage_class ="IA" public_acl = "private" encryption = "AES256" #content_type = "text/plain" diff --git a/vestack/tos/object/resource_vestack_tos_object.go b/vestack/tos/object/resource_vestack_tos_object.go index 5bc1f17a..2edcb8c5 100644 --- a/vestack/tos/object/resource_vestack_tos_object.go +++ b/vestack/tos/object/resource_vestack_tos_object.go @@ -101,6 +101,11 @@ func ResourceVestackTosObject() *schema.Resource { Default: "STANDARD", Description: "The storage type of the object.Valid value is STANDARD|IA.", }, + "version_id": { + Type: schema.TypeString, + Computed: true, + Description: "The version id of the object if exist.", + }, "account_acl": { Type: schema.TypeSet, Optional: true, diff --git a/vestack/tos/object/service_vestack_tos_object.go b/vestack/tos/object/service_vestack_tos_object.go index 5a62ffee..8777261b 100644 --- a/vestack/tos/object/service_vestack_tos_object.go +++ b/vestack/tos/object/service_vestack_tos_object.go @@ -91,6 +91,10 @@ func (s *VestackTosObjectService) ReadResource(resourceData *schema.ResourceData if header.Get("X-Tos-Server-Side-Encryption") != "" { data["Encryption"] = header.Get("X-Tos-Server-Side-Encryption") } + + if header.Get("X-Tos-Version-Id") != "" { + data["VersionId"] = header.Get("X-Tos-Version-Id") + } } action = "GetObjectAcl" @@ -353,12 +357,16 @@ func (s *VestackTosObjectService) RemoveResource(resourceData *schema.ResourceDa }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + condition := make(map[string]interface{}) + if d.Get("version_id") != "" { + condition["versionId"] = d.Get("version_id") + } //删除Object return s.Client.TosClient.DoTosCall(ve.TosInfo{ HttpMethod: ve.DELETE, Domain: (*call.SdkParam)["BucketName"].(string), Path: []string{(*call.SdkParam)["ObjectName"].(string)}, - }, nil) + }, &condition) }, CallError: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall, baseErr error) error { return resource.Retry(15*time.Minute, func() *resource.RetryError { From 985a20117f59b554fa17553f38986a297511a54c Mon Sep 17 00:00:00 2001 From: xuyaming Date: Fri, 24 Jun 2022 19:31:05 +0800 Subject: [PATCH 10/21] feat: for_tos --- go.mod | 2 +- .../tos/object/resource_vestack_tos_object.go | 12 ++- .../tos/object/service_vestack_tos_object.go | 89 ++++++++++++++++--- 3 files changed, 87 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 2434cfb9..ded0711f 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,6 @@ require ( github.com/hashicorp/hcl/v2 v2.0.0 github.com/hashicorp/terraform-plugin-sdk v1.7.0 github.com/stretchr/testify v1.7.0 - github.com/volcengine/volcstack-go-sdk v1.0.2 + github.com/volcengine/volcstack-go-sdk v1.0.3 golang.org/x/sync v0.0.0-20190423024810-112230192c58 ) diff --git a/vestack/tos/object/resource_vestack_tos_object.go b/vestack/tos/object/resource_vestack_tos_object.go index 2edcb8c5..1101fb56 100644 --- a/vestack/tos/object/resource_vestack_tos_object.go +++ b/vestack/tos/object/resource_vestack_tos_object.go @@ -101,10 +101,14 @@ func ResourceVestackTosObject() *schema.Resource { Default: "STANDARD", Description: "The storage type of the object.Valid value is STANDARD|IA.", }, - "version_id": { - Type: schema.TypeString, - Computed: true, - Description: "The version id of the object if exist.", + "version_ids": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Set: schema.HashString, + Description: "The version ids of the object if exist.", }, "account_acl": { Type: schema.TypeSet, diff --git a/vestack/tos/object/service_vestack_tos_object.go b/vestack/tos/object/service_vestack_tos_object.go index 8777261b..18ac7360 100644 --- a/vestack/tos/object/service_vestack_tos_object.go +++ b/vestack/tos/object/service_vestack_tos_object.go @@ -93,7 +93,58 @@ func (s *VestackTosObjectService) ReadResource(resourceData *schema.ResourceData } if header.Get("X-Tos-Version-Id") != "" { - data["VersionId"] = header.Get("X-Tos-Version-Id") + action = "ListObjects" + logger.Debug(logger.ReqFormat, action, bucketName+":"+instanceId) + + var ( + nextVersionIdMarker string + versionIds []string + ) + + for { + urlParam := map[string]string{ + "prefix": instanceId, + "max-keys": "100", + "versions": "", + } + if nextVersionIdMarker != "" { + urlParam["key-marker"] = instanceId + urlParam["version-id-marker"] = nextVersionIdMarker + } + + resp, err = tos.DoTosCall(ve.TosInfo{ + HttpMethod: ve.GET, + Domain: bucketName, + UrlParam: urlParam, + }, nil) + + if err != nil { + return data, err + } + versions, _ := ve.ObtainSdkValue(ve.TosResponse+".Versions", *resp) + next, _ := ve.ObtainSdkValue(ve.TosResponse+".NextVersionIdMarker", *resp) + + if versions == nil || len(versions.([]interface{})) == 0 { + break + } + + if next == nil || next.(string) == "" { + nextVersionIdMarker = "" + } else { + nextVersionIdMarker = next.(string) + } + + for _, version := range versions.([]interface{}) { + versionId, _ := ve.ObtainSdkValue("VersionId", version) + versionIds = append(versionIds, versionId.(string)) + } + + if nextVersionIdMarker == "" { + break + } + } + logger.Debug(logger.ReqFormat, action, versionIds) + data["VersionIds"] = versionIds } } @@ -356,17 +407,33 @@ func (s *VestackTosObjectService) RemoveResource(resourceData *schema.ResourceDa "ObjectName": s.ReadResourceId(resourceData.Id()), }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { - logger.Debug(logger.RespFormat, call.Action, call.SdkParam) - condition := make(map[string]interface{}) - if d.Get("version_id") != "" { - condition["versionId"] = d.Get("version_id") + + if d.Get("version_ids") != nil && len(d.Get("version_ids").(*schema.Set).List()) > 0 { + for _, vv := range d.Get("version_ids").(*schema.Set).List() { + condition := make(map[string]interface{}) + condition["versionId"] = vv + //remove Object-with-version + logger.Debug(logger.RespFormat, call.Action, condition) + _, err := s.Client.TosClient.DoTosCall(ve.TosInfo{ + HttpMethod: ve.DELETE, + Domain: (*call.SdkParam)["BucketName"].(string), + Path: []string{(*call.SdkParam)["ObjectName"].(string)}, + }, &condition) + if err != nil { + return nil, err + } + } + } else { + //remove Object-no-version + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + return s.Client.TosClient.DoTosCall(ve.TosInfo{ + HttpMethod: ve.DELETE, + Domain: (*call.SdkParam)["BucketName"].(string), + Path: []string{(*call.SdkParam)["ObjectName"].(string)}, + }, nil) } - //删除Object - return s.Client.TosClient.DoTosCall(ve.TosInfo{ - HttpMethod: ve.DELETE, - Domain: (*call.SdkParam)["BucketName"].(string), - Path: []string{(*call.SdkParam)["ObjectName"].(string)}, - }, &condition) + + return nil, nil }, CallError: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall, baseErr error) error { return resource.Retry(15*time.Minute, func() *resource.RetryError { From 242ec4ec51afe16569914add4a2b676c08f3bca1 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Fri, 24 Jun 2022 19:35:53 +0800 Subject: [PATCH 11/21] feat: for_tos --- common/common_vestack_tos_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/common_vestack_tos_handler.go b/common/common_vestack_tos_handler.go index ba7807d9..07605d4b 100644 --- a/common/common_vestack_tos_handler.go +++ b/common/common_vestack_tos_handler.go @@ -354,7 +354,7 @@ func tosUnmarshal(r *request.Request) { return } - if strings.ToLower(r.HTTPResponse.Header.Get("Content-Type")) == "application/json" { + if strings.Contains(strings.ToLower(r.HTTPResponse.Header.Get("Accept")), "application/json") { if err = json.Unmarshal(body, &temp); err != nil { fmt.Printf("Unmarshal err, %v\n", err) r.Error = err From a16684f97a969c23e89ee462c47123d260bc359a Mon Sep 17 00:00:00 2001 From: xuyaming Date: Mon, 27 Jun 2022 18:56:51 +0800 Subject: [PATCH 12/21] feat: for_tos --- common/common_vestack_tos_handler.go | 9 +- .../service_vestack_volume_attach_test.go | 1 + .../tos/object/resource_vestack_tos_object.go | 17 +- .../tos/object/service_vestack_tos_object.go | 381 +++++++++--------- 4 files changed, 217 insertions(+), 191 deletions(-) diff --git a/common/common_vestack_tos_handler.go b/common/common_vestack_tos_handler.go index 07605d4b..516d1d93 100644 --- a/common/common_vestack_tos_handler.go +++ b/common/common_vestack_tos_handler.go @@ -89,7 +89,13 @@ func tosBuild(r *request.Request) { r.HTTPRequest.Header.Set("Content-Type", "application/json; charset=utf-8") volcstackbody.BodyJson(&body, r) } else { + if len(contentType) > 0 && !strings.Contains(strings.ToLower(contentType), "x-www-form-urlencoded") { + r.HTTPRequest.Header.Del("Content-Type") + } volcstackbody.BodyParam(&body, r) + if len(contentType) > 0 { + r.HTTPRequest.Header.Set("Content-Type", contentType) + } } } @@ -354,7 +360,8 @@ func tosUnmarshal(r *request.Request) { return } - if strings.Contains(strings.ToLower(r.HTTPResponse.Header.Get("Accept")), "application/json") { + if strings.Contains(strings.ToLower(r.HTTPResponse.Header.Get("Accept")), "application/json") || + strings.Contains(strings.ToLower(r.HTTPResponse.Header.Get("Content-Type")), "application/json") { if err = json.Unmarshal(body, &temp); err != nil { fmt.Printf("Unmarshal err, %v\n", err) r.Error = err diff --git a/vestack/ebs/volume_attach/service_vestack_volume_attach_test.go b/vestack/ebs/volume_attach/service_vestack_volume_attach_test.go index 97888e47..9aa0d99a 100644 --- a/vestack/ebs/volume_attach/service_vestack_volume_attach_test.go +++ b/vestack/ebs/volume_attach/service_vestack_volume_attach_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + ve "github.com/volcengine/terraform-provider-vestack/common" ) func Test_ResourceNotFoundError(t *testing.T) { diff --git a/vestack/tos/object/resource_vestack_tos_object.go b/vestack/tos/object/resource_vestack_tos_object.go index 1101fb56..6e916e20 100644 --- a/vestack/tos/object/resource_vestack_tos_object.go +++ b/vestack/tos/object/resource_vestack_tos_object.go @@ -42,6 +42,12 @@ func ResourceVestackTosObject() *schema.Resource { return []*schema.ResourceData{data}, nil }, }, + CustomizeDiff: func(diff *schema.ResourceDiff, i interface{}) (err error) { + if diff.Id() != "" && diff.HasChange("file_path") && !diff.Get("enable_version").(bool) { + return diff.ForceNew("file_path") + } + return err + }, Schema: map[string]*schema.Schema{ "bucket_name": { Type: schema.TypeString, @@ -56,9 +62,9 @@ func ResourceVestackTosObject() *schema.Resource { Description: "The name of the object.", }, "file_path": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + //ForceNew: true, Description: "The file path for upload.", }, "encryption": { @@ -146,6 +152,11 @@ func ResourceVestackTosObject() *schema.Resource { }, Set: ve.TosAccountAclHash, }, + "enable_version": { + Type: schema.TypeBool, + Computed: true, + Description: "The flag of enable tos version.", + }, }, } return resource diff --git a/vestack/tos/object/service_vestack_tos_object.go b/vestack/tos/object/service_vestack_tos_object.go index 18ac7360..9398ad06 100644 --- a/vestack/tos/object/service_vestack_tos_object.go +++ b/vestack/tos/object/service_vestack_tos_object.go @@ -56,11 +56,12 @@ func (s *VestackTosObjectService) ReadResource(resourceData *schema.ResourceData tos := s.Client.TosClient bucketName := resourceData.Get("bucket_name").(string) var ( - action string - resp *map[string]interface{} - ok bool - header http.Header - acl map[string]interface{} + action string + resp *map[string]interface{} + ok bool + header http.Header + acl map[string]interface{} + bucketVersion map[string]interface{} ) if instanceId == "" { @@ -166,6 +167,22 @@ func (s *VestackTosObjectService) ReadResource(resourceData *schema.ResourceData data["AccountAcl"] = acl } + action = "GetBucketVersioning" + req = map[string]interface{}{ + "versioning": "", + } + logger.Debug(logger.ReqFormat, action, req) + resp, err = tos.DoTosCall(ve.TosInfo{ + HttpMethod: ve.GET, + Domain: bucketName, + }, &req) + if err != nil { + return data, err + } + if bucketVersion, ok = (*resp)[ve.TosResponse].(map[string]interface{}); ok { + data["EnableVersion"] = bucketVersion + } + if len(data) == 0 { return data, fmt.Errorf("object %s not exist ", instanceId) } @@ -188,6 +205,15 @@ func (s *VestackTosObjectService) RefreshResourceState(data *schema.ResourceData func (VestackTosObjectService) WithResourceResponseHandlers(m map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return m, map[string]ve.ResponseConvert{ + "EnableVersion": { + Convert: func(i interface{}) interface{} { + status, _ := ve.ObtainSdkValue("Status", i) + if status.(string) != "Enabled" { + return false + } + return true + }, + }, "AccountAcl": { Convert: ve.ConvertTosAccountAcl(), }, @@ -201,196 +227,29 @@ func (VestackTosObjectService) WithResourceResponseHandlers(m map[string]interfa func (s *VestackTosObjectService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { //create object - callback := ve.Callback{ - Call: ve.SdkCall{ - ServiceCategory: ve.ServiceTos, - Action: "CreateObject", - ConvertMode: ve.RequestConvertInConvert, - Convert: map[string]ve.RequestConvert{ - "bucket_name": { - ConvertType: ve.ConvertDefault, - TargetField: "BucketName", - SpecialParam: &ve.SpecialParam{ - Type: ve.DomainParam, - }, - }, - "object_name": { - ConvertType: ve.ConvertDefault, - TargetField: "ObjectName", - SpecialParam: &ve.SpecialParam{ - Type: ve.PathParam, - Index: 0, - }, - }, - "public_acl": { - ConvertType: ve.ConvertDefault, - TargetField: "x-tos-acl", - SpecialParam: &ve.SpecialParam{ - Type: ve.HeaderParam, - }, - }, - "storage_class": { - ConvertType: ve.ConvertDefault, - TargetField: "x-tos-storage-class", - SpecialParam: &ve.SpecialParam{ - Type: ve.HeaderParam, - }, - }, - "content_type": { - ConvertType: ve.ConvertDefault, - TargetField: "content-type", - SpecialParam: &ve.SpecialParam{ - Type: ve.HeaderParam, - }, - }, - "file_path": { - ConvertType: ve.ConvertDefault, - TargetField: "file-path", - SpecialParam: &ve.SpecialParam{ - Type: ve.FilePathParam, - }, - }, - "encryption": { - ConvertType: ve.ConvertDefault, - TargetField: "x-tos-server-side-encryption", - SpecialParam: &ve.SpecialParam{ - Type: ve.HeaderParam, - }, - }, - }, - ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { - logger.Debug(logger.RespFormat, call.Action, call.SdkParam) - //创建Object - return s.Client.TosClient.DoTosCall(ve.TosInfo{ - HttpMethod: ve.PUT, - Domain: (*call.SdkParam)[ve.TosDomain].(string), - Header: (*call.SdkParam)[ve.TosHeader].(map[string]string), - Path: (*call.SdkParam)[ve.TosPath].([]string), - ContentPath: (*call.SdkParam)[ve.TosFilePath].(string), - }, nil) - }, - AfterCall: func(d *schema.ResourceData, client *ve.SdkClient, resp *map[string]interface{}, call ve.SdkCall) error { - d.SetId((*call.SdkParam)[ve.TosDomain].(string) + ":" + (*call.SdkParam)[ve.TosPath].([]string)[0]) - return nil - }, - }, - } + callback := s.createOrReplaceObject(resourceData, resource, false) //acl - callbackAcl := ve.Callback{ - Call: ve.SdkCall{ - ServiceCategory: ve.ServiceTos, - Action: "PutObjectAcl", - ConvertMode: ve.RequestConvertInConvert, - Convert: map[string]ve.RequestConvert{ - "bucket_name": { - ConvertType: ve.ConvertDefault, - TargetField: "BucketName", - SpecialParam: &ve.SpecialParam{ - Type: ve.DomainParam, - }, - }, - "object_name": { - ConvertType: ve.ConvertDefault, - TargetField: "ObjectName", - SpecialParam: &ve.SpecialParam{ - Type: ve.PathParam, - Index: 0, - }, - }, - "account_acl": { - ConvertType: ve.ConvertListN, - TargetField: "Grants", - NextLevelConvert: map[string]ve.RequestConvert{ - "account_id": { - ConvertType: ve.ConvertDefault, - TargetField: "Grantee.ID", - }, - "acl_type": { - ConvertType: ve.ConvertDefault, - TargetField: "Grantee.Type", - }, - "permission": { - ConvertType: ve.ConvertDefault, - TargetField: "Permission", - }, - }, - }, - }, - BeforeCall: s.beforePutObjectAcl(), - ExecuteCall: s.executePutObjectAcl(), - //Refresh: &ve.StateRefresh{ - // Target: []string{"Success"}, - // Timeout: resourceData.Timeout(schema.TimeoutCreate), - //}, - }, - } + callbackAcl := s.createOrUpdateObjectAcl(resourceData, resource, false) return []ve.Callback{callback, callbackAcl} } func (s *VestackTosObjectService) ModifyResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { var callbacks []ve.Callback - var grant = []string{ - "public_acl", - "account_acl", - } - for _, v := range grant { - if data.HasChange(v) { - callbackAcl := ve.Callback{ - Call: ve.SdkCall{ - ServiceCategory: ve.ServiceTos, - Action: "PutBucketAcl", - ConvertMode: ve.RequestConvertInConvert, - Convert: map[string]ve.RequestConvert{ - "bucket_name": { - ConvertType: ve.ConvertDefault, - TargetField: "BucketName", - SpecialParam: &ve.SpecialParam{ - Type: ve.DomainParam, - }, - ForceGet: true, - }, - "object_name": { - ConvertType: ve.ConvertDefault, - TargetField: "ObjectName", - SpecialParam: &ve.SpecialParam{ - Type: ve.PathParam, - Index: 0, - }, - }, - "account_acl": { - ConvertType: ve.ConvertListN, - TargetField: "Grants", - NextLevelConvert: map[string]ve.RequestConvert{ - "account_id": { - ConvertType: ve.ConvertDefault, - TargetField: "Grantee.ID", - ForceGet: true, - }, - "acl_type": { - ConvertType: ve.ConvertDefault, - TargetField: "Grantee.Type", - ForceGet: true, - }, - "permission": { - ConvertType: ve.ConvertDefault, - TargetField: "Permission", - ForceGet: true, - }, - }, - ForceGet: true, - }, - }, - BeforeCall: s.beforePutObjectAcl(), - ExecuteCall: s.executePutObjectAcl(), - Refresh: &ve.StateRefresh{ - Target: []string{"Success"}, - Timeout: data.Timeout(schema.TimeoutCreate), - }, - }, + if data.HasChange("file_path") { + callbacks = append(callbacks, s.createOrReplaceObject(data, resource, true)) + callbacks = append(callbacks, s.createOrUpdateObjectAcl(data, resource, true)) + } else { + var grant = []string{ + "public_acl", + "account_acl", + } + for _, v := range grant { + if data.HasChange(v) { + callbackAcl := s.createOrUpdateObjectAcl(data, resource, true) + callbacks = append(callbacks, callbackAcl) + break } - callbacks = append(callbacks, callbackAcl) - break } } @@ -508,6 +367,7 @@ func (s *VestackTosObjectService) ReadResourceId(id string) string { func (s *VestackTosObjectService) beforePutObjectAcl() ve.BeforeCallFunc { return func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) data, err := s.Client.TosClient.DoTosCall(ve.TosInfo{ HttpMethod: ve.GET, Domain: (*call.SdkParam)[ve.TosDomain].(string), @@ -536,3 +396,150 @@ func (s *VestackTosObjectService) executePutObjectAcl() ve.ExecuteCallFunc { }, ¶m) } } + +func (s *VestackTosObjectService) createOrUpdateObjectAcl(resourceData *schema.ResourceData, resource *schema.Resource, isUpdate bool) ve.Callback { + callback := ve.Callback{ + Call: ve.SdkCall{ + ServiceCategory: ve.ServiceTos, + Action: "PutObjectAcl", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "bucket_name": { + ConvertType: ve.ConvertDefault, + TargetField: "BucketName", + SpecialParam: &ve.SpecialParam{ + Type: ve.DomainParam, + }, + ForceGet: isUpdate, + }, + "object_name": { + ConvertType: ve.ConvertDefault, + TargetField: "ObjectName", + SpecialParam: &ve.SpecialParam{ + Type: ve.PathParam, + Index: 0, + }, + ForceGet: isUpdate, + }, + "account_acl": { + ConvertType: ve.ConvertListN, + TargetField: "Grants", + ForceGet: isUpdate, + NextLevelConvert: map[string]ve.RequestConvert{ + "account_id": { + ConvertType: ve.ConvertDefault, + TargetField: "Grantee.ID", + ForceGet: isUpdate, + }, + "acl_type": { + ConvertType: ve.ConvertDefault, + TargetField: "Grantee.Type", + ForceGet: isUpdate, + }, + "permission": { + ConvertType: ve.ConvertDefault, + TargetField: "Permission", + ForceGet: isUpdate, + }, + }, + }, + }, + BeforeCall: s.beforePutObjectAcl(), + ExecuteCall: s.executePutObjectAcl(), + //Refresh: &ve.StateRefresh{ + // Target: []string{"Success"}, + // Timeout: resourceData.Timeout(schema.TimeoutCreate), + //}, + }, + } + if isUpdate { + callback.Call.Refresh = &ve.StateRefresh{ + Target: []string{"Success"}, + Timeout: resourceData.Timeout(schema.TimeoutCreate), + } + } + return callback +} + +func (s *VestackTosObjectService) createOrReplaceObject(resourceData *schema.ResourceData, resource *schema.Resource, isUpdate bool) ve.Callback { + return ve.Callback{ + Call: ve.SdkCall{ + ServiceCategory: ve.ServiceTos, + Action: "PutObject", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "bucket_name": { + ConvertType: ve.ConvertDefault, + TargetField: "BucketName", + SpecialParam: &ve.SpecialParam{ + Type: ve.DomainParam, + }, + ForceGet: isUpdate, + }, + "object_name": { + ConvertType: ve.ConvertDefault, + TargetField: "ObjectName", + SpecialParam: &ve.SpecialParam{ + Type: ve.PathParam, + Index: 0, + }, + ForceGet: isUpdate, + }, + "public_acl": { + ConvertType: ve.ConvertDefault, + TargetField: "x-tos-acl", + SpecialParam: &ve.SpecialParam{ + Type: ve.HeaderParam, + }, + ForceGet: isUpdate, + }, + "storage_class": { + ConvertType: ve.ConvertDefault, + TargetField: "x-tos-storage-class", + SpecialParam: &ve.SpecialParam{ + Type: ve.HeaderParam, + }, + ForceGet: isUpdate, + }, + "content_type": { + ConvertType: ve.ConvertDefault, + TargetField: "Content-Type", + SpecialParam: &ve.SpecialParam{ + Type: ve.HeaderParam, + }, + ForceGet: isUpdate, + }, + "file_path": { + ConvertType: ve.ConvertDefault, + TargetField: "file-path", + SpecialParam: &ve.SpecialParam{ + Type: ve.FilePathParam, + }, + }, + "encryption": { + ConvertType: ve.ConvertDefault, + TargetField: "x-tos-server-side-encryption", + SpecialParam: &ve.SpecialParam{ + Type: ve.HeaderParam, + }, + ForceGet: isUpdate, + }, + }, + ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + //创建Object + return s.Client.TosClient.DoTosCall(ve.TosInfo{ + HttpMethod: ve.PUT, + Domain: (*call.SdkParam)[ve.TosDomain].(string), + Header: (*call.SdkParam)[ve.TosHeader].(map[string]string), + Path: (*call.SdkParam)[ve.TosPath].([]string), + ContentPath: (*call.SdkParam)[ve.TosFilePath].(string), + }, nil) + }, + AfterCall: func(d *schema.ResourceData, client *ve.SdkClient, resp *map[string]interface{}, call ve.SdkCall) error { + d.SetId((*call.SdkParam)[ve.TosDomain].(string) + ":" + (*call.SdkParam)[ve.TosPath].([]string)[0]) + return nil + }, + }, + } +} From 0db3b6d288f1b12de1d74d97a603b534eec05e66 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Thu, 30 Jun 2022 18:49:46 +0800 Subject: [PATCH 13/21] convert --- README.md | 36 ++-- build.sh | 8 +- build_scm.sh | 2 +- common/common_vestack_client.go | 28 --- ...lback.go => common_volcengine_callback.go} | 0 ....go => common_volcengine_callback_test.go} | 0 common/common_volcengine_client.go | 28 +++ ..._config.go => common_volcengine_config.go} | 32 ++-- ...ck_const.go => common_volcengine_const.go} | 0 ...onvert.go => common_volcengine_convert.go} | 0 ...ce.go => common_volcengine_data_source.go} | 0 ...o => common_volcengine_diff_collection.go} | 0 ...> common_volcengine_diff_suppress_func.go} | 0 ...her.go => common_volcengine_dispatcher.go} | 0 ...ck_error.go => common_volcengine_error.go} | 4 +- ...andler.go => common_volcengine_handler.go} | 0 ...odes.go => common_volcengine_hashcodes.go} | 0 ...face.go => common_volcengine_interface.go} | 0 ...tack_lock.go => common_volcengine_lock.go} | 0 ...tack_page.go => common_volcengine_page.go} | 0 ...mit.go => common_volcengine_sync_limit.go} | 0 ...ent.go => common_volcengine_tos_client.go} | 10 +- ...er.go => common_volcengine_tos_handler.go} | 26 +-- ...tils.go => common_volcengine_tos_utils.go} | 0 ... => common_volcengine_universal_client.go} | 22 +-- ...tack_util.go => common_volcengine_util.go} | 0 ...ersion.go => common_volcengine_version.go} | 2 +- docgen/main.go | 10 +- example/acl/main.tf | 2 +- example/aclEntry/main.tf | 6 +- example/certificate/main.tf | 2 +- example/clb/main.tf | 2 +- example/dataAcls/main.tf | 2 +- example/dataCertificates/main.tf | 2 +- example/dataClbs/main.tf | 2 +- example/dataEcsInstances/main.tf | 2 +- example/dataEipAddresses/main.tf | 2 +- example/dataImages/main.tf | 2 +- example/dataListeners/main.tf | 2 +- example/dataNatGateways/main.tf | 2 +- example/dataNetworkInterfaces/main.tf | 2 +- example/dataRouteEntries/main.tf | 2 +- example/dataRouteTables/main.tf | 2 +- example/dataRules/main.tf | 4 +- example/dataSecurityGroups/main.tf | 2 +- example/dataServerGroupServers/main.tf | 2 +- example/dataServerGroups/main.tf | 2 +- example/dataSnatEntries/main.tf | 2 +- example/dataSubnets/main.tf | 2 +- example/dataTosBuckets/main.tf | 2 +- example/dataVolumes/main.tf | 2 +- example/dataVpcs/main.tf | 2 +- example/dataZones/main.tf | 2 +- example/demo/main.tf | 2 +- example/ecsInstance/main.tf | 22 +-- example/ecsInstanceState/main.tf | 2 +- example/eipAddress/main.tf | 2 +- example/eipAssociate/main.tf | 2 +- example/listener/main.tf | 2 +- example/natGateway/main.tf | 2 +- example/networkInterface/main.tf | 2 +- example/networkInterfaceAttach/main.tf | 2 +- example/routeEntry/main.tf | 2 +- example/routeTable/main.tf | 2 +- example/routeTableAssociate/main.tf | 2 +- example/rule/main.tf | 2 +- example/securityGroup/main.tf | 2 +- example/securityGroupRule/main.tf | 2 +- example/serverGroup/main.tf | 2 +- example/serverGroupServer/main.tf | 2 +- example/snatEntry/main.tf | 2 +- example/subnet/main.tf | 2 +- example/tosBucket/main.tf | 2 +- example/tosObject/main.tf | 2 +- example/volume/main.tf | 2 +- example/volumeAttach/main.tf | 2 +- example/vpc/main.tf | 2 +- go.mod | 4 +- main.go | 4 +- vestack/provider.go | 169 ------------------ .../clb/acl/data_source_volcengine_acls.go | 10 +- .../clb/acl/resource_volcengine_acl.go | 38 ++-- .../clb/acl/service_volcengine_acl.go | 30 ++-- .../acl_entry/common_volcengine_acl_entry.go | 0 .../resource_volcengine_acl_entry.go | 26 +-- .../acl_entry/service_volcengine_acl_entry.go | 30 ++-- .../data_source_volcengine_certificates.go | 10 +- .../resource_volcengine_certificate.go | 32 ++-- .../service_volcengine_certificate.go | 30 ++-- .../clb/clb/data_source_volcengine_clbs.go | 10 +- .../clb/clb/resource_volcengine_clb.go | 34 ++-- .../clb/clb/service_volcengine_clb.go | 30 ++-- .../listener/common_volcengine_listener.go | 0 .../data_source_volcengine_listeners.go | 10 +- .../listener/resource_volcengine_listener.go | 34 ++-- .../listener/service_volcengine_listener.go | 34 ++-- .../clb/rule/data_source_volcengine_rules.go | 10 +- .../clb/rule/resource_volcengine_rule.go | 34 ++-- .../clb/rule/service_volcengine_rule.go | 34 ++-- .../data_source_volcengine_server_groups.go | 10 +- .../resource_volcengine_server_group.go | 34 ++-- .../service_volcengine_server_group.go | 34 ++-- .../common_volcengine_server_grop_server.go | 0 ...esource_volcengine_server_group_servers.go | 10 +- .../resource_volcengine_server_group.go | 34 ++-- .../service_volcengine_server_group_server.go | 34 ++-- .../volume/data_source_volcengine_volumes.go | 10 +- .../ebs/volume/resource_volcengine_volume.go | 34 ++-- .../ebs/volume/service_volcengine_volume.go | 30 ++-- .../volume/service_volcengine_volume_test.go | 0 .../resource_volcengine_volume_attach.go | 32 ++-- .../service_volcengine_volume_attach.go | 30 ++-- .../service_volcengine_volume_attach_test.go | 2 +- .../data_source_volcengine_ecs_instances.go | 10 +- .../resource_volcengine_ecs_instance.go | 42 ++--- .../service_volcengine_ecs_instance.go | 36 ++-- .../common_volcengine_ecs_instance_state.go | 0 .../resource_volcengine_ecs_instance_state.go | 34 ++-- .../service_volcengine_ecs_instance_state.go | 30 ++-- .../image/data_source_volcengine_images.go | 10 +- .../ecs/image/service_volcengine_image.go | 30 ++-- .../ecs/zone/data_source_volcengine_zones.go | 10 +- .../ecs/zone/service_volcengine_zone.go | 30 ++-- .../common_volcengine_eip_address.go | 0 .../data_source_volcengine_eip_addresses.go | 10 +- .../resource_volcengine_eip_address.go | 34 ++-- .../service_volcengine_eip_address.go | 30 ++-- .../common_volcengine_eip_associate.go | 0 .../resource_volcengine_eip_associate.go | 26 +-- .../service_volcengine_eip_associate.go | 30 ++-- .../data_source_volcengine_nat_gateways.go | 10 +- .../resource_volcengine_nat_gateway.go | 34 ++-- .../service_volcengine_nat_gateway.go | 30 ++-- .../data_source_volcengine_snat_entries.go | 10 +- .../resource_volcengine_snat_entry.go | 34 ++-- .../service_volcengine_snat_entry.go | 30 ++-- volcengine/provider.go | 169 ++++++++++++++++++ .../data_source_volcengine_tos_buckets.go | 10 +- .../bucket/resource_volcengine_tos_bucket.go | 34 ++-- .../bucket/service_volcengine_tos_bucket.go | 38 ++-- .../data_source_volcengine_tos_objects.go | 10 +- .../object/resource_volcengine_tos_object.go | 34 ++-- .../object/service_volcengine_tos_object.go | 38 ++-- ...ta_source_volcengine_network_interfaces.go | 10 +- .../resource_volcengine_network_interface.go | 34 ++-- .../service_volcengine_network_interface.go | 30 ++-- ...mon_volcengine_network_interface_attach.go | 0 ...rce_volcengine_network_interface_attach.go | 26 +-- ...ice_volcengine_network_interface_attach.go | 30 ++-- .../data_source_volcengine_route_entries.go | 10 +- .../resource_volcengine_route_entry.go | 34 ++-- .../service_volcengine_route_entry.go | 30 ++-- .../data_source_volcengine_route_tables.go | 10 +- .../resource_volcengine_route_table.go | 34 ++-- .../service_volcengine_route_table.go | 30 ++-- ...common_volcengine_route_table_associate.go | 0 ...source_volcengine_route_table_associate.go | 26 +-- ...ervice_volcengine_route_table_associate.go | 30 ++-- .../data_source_volcengine_security_groups.go | 10 +- .../resource_volcengine_security_group.go | 34 ++-- .../service_volcengine_security_group.go | 32 ++-- ...resource_volcengine_security_group_rule.go | 34 ++-- .../service_volcengine_security_group_rule.go | 30 ++-- .../subnet/data_source_volcengine_subnets.go | 10 +- .../vpc/subnet/resource_volcengine_subnet.go | 34 ++-- .../vpc/subnet/service_volcengine_subnet.go | 32 ++-- .../vpc/vpc/data_source_volcengine_vpcs.go | 10 +- .../vpc/vpc/resource_volcengine_vpc.go | 36 ++-- .../vpc/vpc/service_volcengine_vpc.go | 30 ++-- website/docs/d/acls.html.markdown | 10 +- website/docs/d/certificates.html.markdown | 10 +- website/docs/d/clbs.html.markdown | 10 +- website/docs/d/ecs_instances.html.markdown | 10 +- website/docs/d/eip_addresses.html.markdown | 10 +- website/docs/d/images.html.markdown | 10 +- website/docs/d/listeners.html.markdown | 10 +- website/docs/d/nat_gateways.html.markdown | 10 +- .../docs/d/network_interfaces.html.markdown | 10 +- website/docs/d/route_entries.html.markdown | 10 +- website/docs/d/route_tables.html.markdown | 10 +- website/docs/d/security_groups.html.markdown | 10 +- website/docs/d/server_groups.html.markdown | 10 +- website/docs/d/snat_entries.html.markdown | 10 +- website/docs/d/subnets.html.markdown | 10 +- website/docs/d/volumes.html.markdown | 10 +- website/docs/d/vpcs.html.markdown | 10 +- website/docs/d/zones.html.markdown | 10 +- website/docs/index.html.markdown | 42 ++--- website/docs/r/acl.html.markdown | 12 +- website/docs/r/acl_entry.html.markdown | 16 +- website/docs/r/certificate.html.markdown | 12 +- website/docs/r/clb.html.markdown | 12 +- website/docs/r/ecs_instance.html.markdown | 32 ++-- .../docs/r/ecs_instance_state.html.markdown | 12 +- website/docs/r/eip_address.html.markdown | 12 +- website/docs/r/eip_associate.html.markdown | 12 +- website/docs/r/listener.html.markdown | 12 +- website/docs/r/nat_gateway.html.markdown | 12 +- .../docs/r/network_interface.html.markdown | 12 +- .../r/network_interface_attach.html.markdown | 12 +- website/docs/r/route_entry.html.markdown | 12 +- website/docs/r/route_table.html.markdown | 12 +- .../r/route_table_associate.html.markdown | 12 +- website/docs/r/security_group.html.markdown | 12 +- .../docs/r/security_group_rule.html.markdown | 12 +- website/docs/r/server_group.html.markdown | 12 +- website/docs/r/snat_entry.html.markdown | 12 +- website/docs/r/subnet.html.markdown | 12 +- website/docs/r/volume.html.markdown | 12 +- website/docs/r/volume_attach.html.markdown | 12 +- website/docs/r/vpc.html.markdown | 12 +- website/{vestack.erb => volcengine.erb} | 86 ++++----- 212 files changed, 1658 insertions(+), 1658 deletions(-) delete mode 100644 common/common_vestack_client.go rename common/{common_vestack_callback.go => common_volcengine_callback.go} (100%) rename common/{common_vestack_callback_test.go => common_volcengine_callback_test.go} (100%) create mode 100644 common/common_volcengine_client.go rename common/{common_vestack_config.go => common_volcengine_config.go} (54%) rename common/{common_vestack_const.go => common_volcengine_const.go} (100%) rename common/{common_vestack_convert.go => common_volcengine_convert.go} (100%) rename common/{common_vestack_data_source.go => common_volcengine_data_source.go} (100%) rename common/{common_vestack_diff_collection.go => common_volcengine_diff_collection.go} (100%) rename common/{common_vestack_diff_suppress_func.go => common_volcengine_diff_suppress_func.go} (100%) rename common/{common_vestack_dispatcher.go => common_volcengine_dispatcher.go} (100%) rename common/{common_vestack_error.go => common_volcengine_error.go} (75%) rename common/{common_vestack_handler.go => common_volcengine_handler.go} (100%) rename common/{common_vestack_hashcodes.go => common_volcengine_hashcodes.go} (100%) rename common/{common_vestack_interface.go => common_volcengine_interface.go} (100%) rename common/{common_vestack_lock.go => common_volcengine_lock.go} (100%) rename common/{common_vestack_page.go => common_volcengine_page.go} (100%) rename common/{common_vestack_sync_limit.go => common_volcengine_sync_limit.go} (100%) rename common/{common_vestack_tos_client.go => common_volcengine_tos_client.go} (90%) rename common/{common_vestack_tos_handler.go => common_volcengine_tos_handler.go} (93%) rename common/{common_vestack_tos_utils.go => common_volcengine_tos_utils.go} (100%) rename common/{common_vestack_universal_client.go => common_volcengine_universal_client.go} (73%) rename common/{common_vestack_util.go => common_volcengine_util.go} (100%) rename common/{common_vestack_version.go => common_volcengine_version.go} (50%) delete mode 100644 vestack/provider.go rename vestack/clb/acl/data_source_vestack_acls.go => volcengine/clb/acl/data_source_volcengine_acls.go (88%) rename vestack/clb/acl/resource_vestack_acl.go => volcengine/clb/acl/resource_volcengine_acl.go (57%) rename vestack/clb/acl/service_vestack_acl.go => volcengine/clb/acl/service_volcengine_acl.go (86%) rename vestack/clb/acl_entry/common_vestack_acl_entry.go => volcengine/clb/acl_entry/common_volcengine_acl_entry.go (100%) rename vestack/clb/acl_entry/resource_vestack_acl_entry.go => volcengine/clb/acl_entry/resource_volcengine_acl_entry.go (65%) rename vestack/clb/acl_entry/service_vestack_acl_entry.go => volcengine/clb/acl_entry/service_volcengine_acl_entry.go (78%) rename vestack/clb/certificate/data_source_vestack_certificates.go => volcengine/clb/certificate/data_source_volcengine_certificates.go (90%) rename vestack/clb/certificate/resource_vestack_certificate.go => volcengine/clb/certificate/resource_volcengine_certificate.go (66%) rename vestack/clb/certificate/service_vestack_certificate.go => volcengine/clb/certificate/service_volcengine_certificate.go (73%) rename vestack/clb/clb/data_source_vestack_clbs.go => volcengine/clb/clb/data_source_volcengine_clbs.go (93%) rename vestack/clb/clb/resource_vestack_clb.go => volcengine/clb/clb/resource_volcengine_clb.go (77%) rename vestack/clb/clb/service_vestack_clb.go => volcengine/clb/clb/service_volcengine_clb.go (84%) rename vestack/clb/listener/common_vestack_listener.go => volcengine/clb/listener/common_volcengine_listener.go (100%) rename vestack/clb/listener/data_source_vestack_listeners.go => volcengine/clb/listener/data_source_volcengine_listeners.go (94%) rename vestack/clb/listener/resource_vestack_listener.go => volcengine/clb/listener/resource_volcengine_listener.go (87%) rename vestack/clb/listener/service_vestack_listener.go => volcengine/clb/listener/service_volcengine_listener.go (85%) rename vestack/clb/rule/data_source_vestack_rules.go => volcengine/clb/rule/data_source_volcengine_rules.go (84%) rename vestack/clb/rule/resource_vestack_rule.go => volcengine/clb/rule/resource_volcengine_rule.go (68%) rename vestack/clb/rule/service_vestack_rule.go => volcengine/clb/rule/service_volcengine_rule.go (83%) rename vestack/clb/server_group/data_source_vestack_server_groups.go => volcengine/clb/server_group/data_source_volcengine_server_groups.go (89%) rename vestack/clb/server_group/resource_vestack_server_group.go => volcengine/clb/server_group/resource_volcengine_server_group.go (65%) rename vestack/clb/server_group/service_vestack_server_group.go => volcengine/clb/server_group/service_volcengine_server_group.go (79%) rename vestack/clb/server_group_server/common_vestack_server_grop_server.go => volcengine/clb/server_group_server/common_volcengine_server_grop_server.go (100%) rename vestack/clb/server_group_server/data_resource_vestack_server_group_servers.go => volcengine/clb/server_group_server/data_resource_volcengine_server_group_servers.go (88%) rename vestack/clb/server_group_server/resource_vestack_server_group.go => volcengine/clb/server_group_server/resource_volcengine_server_group.go (69%) rename vestack/clb/server_group_server/service_vestack_server_group_server.go => volcengine/clb/server_group_server/service_volcengine_server_group_server.go (82%) rename vestack/ebs/volume/data_source_vestack_volumes.go => volcengine/ebs/volume/data_source_volcengine_volumes.go (93%) rename vestack/ebs/volume/resource_vestack_volume.go => volcengine/ebs/volume/resource_volcengine_volume.go (79%) rename vestack/ebs/volume/service_vestack_volume.go => volcengine/ebs/volume/service_volcengine_volume.go (83%) rename vestack/ebs/volume/service_vestack_volume_test.go => volcengine/ebs/volume/service_volcengine_volume_test.go (100%) rename vestack/ebs/volume_attach/resource_vestack_volume_attach.go => volcengine/ebs/volume_attach/resource_volcengine_volume_attach.go (66%) rename vestack/ebs/volume_attach/service_vestack_volume_attach.go => volcengine/ebs/volume_attach/service_volcengine_volume_attach.go (79%) rename vestack/ebs/volume_attach/service_vestack_volume_attach_test.go => volcengine/ebs/volume_attach/service_volcengine_volume_attach_test.go (83%) rename vestack/ecs/ecs_instance/data_source_vestack_ecs_instances.go => volcengine/ecs/ecs_instance/data_source_volcengine_ecs_instances.go (95%) rename vestack/ecs/ecs_instance/resource_vestack_ecs_instance.go => volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go (86%) rename vestack/ecs/ecs_instance/service_vestack_ecs_instance.go => volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go (94%) rename vestack/ecs/ecs_instance_state/common_vestack_ecs_instance_state.go => volcengine/ecs/ecs_instance_state/common_volcengine_ecs_instance_state.go (100%) rename vestack/ecs/ecs_instance_state/resource_vestack_ecs_instance_state.go => volcengine/ecs/ecs_instance_state/resource_volcengine_ecs_instance_state.go (65%) rename vestack/ecs/ecs_instance_state/service_vestack_ecs_instance_state.go => volcengine/ecs/ecs_instance_state/service_volcengine_ecs_instance_state.go (80%) rename vestack/ecs/image/data_source_vestack_images.go => volcengine/ecs/image/data_source_volcengine_images.go (94%) rename vestack/ecs/image/service_vestack_image.go => volcengine/ecs/image/service_volcengine_image.go (63%) rename vestack/ecs/zone/data_source_vestack_zones.go => volcengine/ecs/zone/data_source_volcengine_zones.go (78%) rename vestack/ecs/zone/service_vestack_zone.go => volcengine/ecs/zone/service_volcengine_zone.go (57%) rename vestack/eip/eip_address/common_vestack_eip_address.go => volcengine/eip/eip_address/common_volcengine_eip_address.go (100%) rename vestack/eip/eip_address/data_source_vestack_eip_addresses.go => volcengine/eip/eip_address/data_source_volcengine_eip_addresses.go (94%) rename vestack/eip/eip_address/resource_vestack_eip_address.go => volcengine/eip/eip_address/resource_volcengine_eip_address.go (71%) rename vestack/eip/eip_address/service_vestack_eip_address.go => volcengine/eip/eip_address/service_volcengine_eip_address.go (82%) rename vestack/eip/eip_associate/common_vestack_eip_associate.go => volcengine/eip/eip_associate/common_volcengine_eip_associate.go (100%) rename vestack/eip/eip_associate/resource_vestack_eip_associate.go => volcengine/eip/eip_associate/resource_volcengine_eip_associate.go (66%) rename vestack/eip/eip_associate/service_vestack_eip_associate.go => volcengine/eip/eip_associate/service_volcengine_eip_associate.go (76%) rename vestack/nat/nat_gateway/data_source_vestack_nat_gateways.go => volcengine/nat/nat_gateway/data_source_volcengine_nat_gateways.go (94%) rename vestack/nat/nat_gateway/resource_vestack_nat_gateway.go => volcengine/nat/nat_gateway/resource_volcengine_nat_gateway.go (75%) rename vestack/nat/nat_gateway/service_vestack_nat_gateway.go => volcengine/nat/nat_gateway/service_volcengine_nat_gateway.go (84%) rename vestack/nat/snat_entry/data_source_vestack_snat_entries.go => volcengine/nat/snat_entry/data_source_volcengine_snat_entries.go (90%) rename vestack/nat/snat_entry/resource_vestack_snat_entry.go => volcengine/nat/snat_entry/resource_volcengine_snat_entry.go (66%) rename vestack/nat/snat_entry/service_vestack_snat_entry.go => volcengine/nat/snat_entry/service_volcengine_snat_entry.go (80%) create mode 100644 volcengine/provider.go rename vestack/tos/bucket/data_source_vestack_tos_buckets.go => volcengine/tos/bucket/data_source_volcengine_tos_buckets.go (86%) rename vestack/tos/bucket/resource_vestack_tos_bucket.go => volcengine/tos/bucket/resource_volcengine_tos_bucket.go (80%) rename vestack/tos/bucket/service_vestack_tos_bucket.go => volcengine/tos/bucket/service_volcengine_tos_bucket.go (87%) rename vestack/tos/object/data_source_vestack_tos_objects.go => volcengine/tos/object/data_source_volcengine_tos_objects.go (86%) rename vestack/tos/object/resource_vestack_tos_object.go => volcengine/tos/object/resource_volcengine_tos_object.go (84%) rename vestack/tos/object/service_vestack_tos_object.go => volcengine/tos/object/service_volcengine_tos_object.go (87%) rename vestack/vpc/network_interface/data_source_vestack_network_interfaces.go => volcengine/vpc/network_interface/data_source_volcengine_network_interfaces.go (94%) rename vestack/vpc/network_interface/resource_vestack_network_interface.go => volcengine/vpc/network_interface/resource_volcengine_network_interface.go (68%) rename vestack/vpc/network_interface/service_vestack_network_interface.go => volcengine/vpc/network_interface/service_volcengine_network_interface.go (80%) rename vestack/vpc/network_interface_attach/common_vestack_network_interface_attach.go => volcengine/vpc/network_interface_attach/common_volcengine_network_interface_attach.go (100%) rename vestack/vpc/network_interface_attach/resource_vestack_network_interface_attach.go => volcengine/vpc/network_interface_attach/resource_volcengine_network_interface_attach.go (58%) rename vestack/vpc/network_interface_attach/service_vestack_network_interface_attach.go => volcengine/vpc/network_interface_attach/service_volcengine_network_interface_attach.go (76%) rename vestack/vpc/route_entry/data_source_vestack_route_entries.go => volcengine/vpc/route_entry/data_source_volcengine_route_entries.go (92%) rename vestack/vpc/route_entry/resource_vestack_route_entry.go => volcengine/vpc/route_entry/resource_volcengine_route_entry.go (70%) rename vestack/vpc/route_entry/service_vestack_route_entry.go => volcengine/vpc/route_entry/service_volcengine_route_entry.go (83%) rename vestack/vpc/route_table/data_source_vestack_route_tables.go => volcengine/vpc/route_table/data_source_volcengine_route_tables.go (91%) rename vestack/vpc/route_table/resource_vestack_route_table.go => volcengine/vpc/route_table/resource_volcengine_route_table.go (60%) rename vestack/vpc/route_table/service_vestack_route_table.go => volcengine/vpc/route_table/service_volcengine_route_table.go (80%) rename vestack/vpc/route_table_associate/common_vestack_route_table_associate.go => volcengine/vpc/route_table_associate/common_volcengine_route_table_associate.go (100%) rename vestack/vpc/route_table_associate/resource_vestack_route_table_associate.go => volcengine/vpc/route_table_associate/resource_volcengine_route_table_associate.go (58%) rename vestack/vpc/route_table_associate/service_vestack_route_table_associate.go => volcengine/vpc/route_table_associate/service_volcengine_route_table_associate.go (76%) rename vestack/vpc/security_group/data_source_vestack_security_groups.go => volcengine/vpc/security_group/data_source_volcengine_security_groups.go (88%) rename vestack/vpc/security_group/resource_vestack_security_group.go => volcengine/vpc/security_group/resource_volcengine_security_group.go (65%) rename vestack/vpc/security_group/service_vestack_security_group.go => volcengine/vpc/security_group/service_volcengine_security_group.go (81%) rename vestack/vpc/security_group_rule/resource_vestack_security_group_rule.go => volcengine/vpc/security_group_rule/resource_volcengine_security_group_rule.go (74%) rename vestack/vpc/security_group_rule/service_vestack_security_group_rule.go => volcengine/vpc/security_group_rule/service_volcengine_security_group_rule.go (82%) rename vestack/vpc/subnet/data_source_vestack_subnets.go => volcengine/vpc/subnet/data_source_volcengine_subnets.go (91%) rename vestack/vpc/subnet/resource_vestack_subnet.go => volcengine/vpc/subnet/resource_volcengine_subnet.go (70%) rename vestack/vpc/subnet/service_vestack_subnet.go => volcengine/vpc/subnet/service_volcengine_subnet.go (81%) rename vestack/vpc/vpc/data_source_vestack_vpcs.go => volcengine/vpc/vpc/data_source_volcengine_vpcs.go (93%) rename vestack/vpc/vpc/resource_vestack_vpc.go => volcengine/vpc/vpc/resource_volcengine_vpc.go (63%) rename vestack/vpc/vpc/service_vestack_vpc.go => volcengine/vpc/vpc/service_volcengine_vpc.go (81%) rename website/{vestack.erb => volcengine.erb} (60%) diff --git a/README.md b/README.md index bedf6516..6a15d62d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# terraform-provider-volcstack +# terraform-provider-volcengine Terraform Provider ================== @@ -15,19 +15,19 @@ Requirements - [Go](https://golang.org/doc/install) 1.13 (to build the provider plugin) -# Vestack Provider +# Volcengine Provider -The Vestack provider is used to interact with many resources supported by [Vestack](https://www.volcengine.com/). +The Volcengine provider is used to interact with many resources supported by [Volcengine](https://www.volcengine.com/). The provider needs to be configured with the proper credentials before it can be used. Use the navigation on the left to read about the available resources. --> **Note:** This guide requires an available Vestack account or sub-account with project to create resources. +-> **Note:** This guide requires an available Volcengine account or sub-account with project to create resources. ## Example Usage ```hcl -# Configure the Vestack Provider -provider "vestack" { +# Configure the Volcengine Provider +provider "volcengine" { access_key = "your ak" secret_key = "your sk" session_token = "sts token" @@ -35,12 +35,12 @@ provider "vestack" { } # Query Vpc -data "vestack_vpcs" "default"{ +data "volcengine_vpcs" "default"{ ids = ["vpc-mizl7m1kqccg5smt1bdpijuj"] } #Create vpc -resource "vestack_vpc" "foo" { +resource "volcengine_vpc" "foo" { vpc_name = "tf-test-1" cidr_block = "172.16.0.0/16" dns_servers = ["8.8.8.8","114.114.114.114"] @@ -50,7 +50,7 @@ resource "vestack_vpc" "foo" { ## Authentication -The Vestack provider offers a flexible means of providing credentials for +The Volcengine provider offers a flexible means of providing credentials for authentication. The following methods are supported, in this order, and explained below: @@ -60,12 +60,12 @@ explained below: ### Static credentials Static credentials can be provided by adding an `public_key` and `private_key` in-line in the -vestack provider block: +volcengine provider block: Usage: ```hcl -provider "vestack" { +provider "volcengine" { access_key = "your ak" secret_key = "your sk" region = "cn-beijing" @@ -74,12 +74,12 @@ provider "vestack" { ### Environment variables -You can provide your credentials via `VESTACK_ACCESS_KEY` and `VESTACK_SECRET_KEY` -environment variables, representing your vestack public key and private key respectively. -`VESTACK_REGION` is also used, if applicable: +You can provide your credentials via `VOLCENGINE_ACCESS_KEY` and `VOLCENGINE_SECRET_KEY` +environment variables, representing your volcengine public key and private key respectively. +`VOLCENGINE_REGION` is also used, if applicable: ```hcl -provider "vestack" { +provider "volcengine" { } ``` @@ -87,9 +87,9 @@ provider "vestack" { Usage: ```hcl -$ export VESTACK_ACCESS_KEY="your_public_key" -$ export VESTACK_SECRET_KEY="your_private_key" -$ export VESTACK_REGION="cn-beijing" +$ export VOLCENGINE_ACCESS_KEY="your_public_key" +$ export VOLCENGINE_SECRET_KEY="your_private_key" +$ export VOLCENGINE_REGION="cn-beijing" $ terraform plan ``` diff --git a/build.sh b/build.sh index 30d95fc7..d2f77e3e 100644 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/bash OS=$1 -NAME="terraform-provider-vestack" +NAME="terraform-provider-volcengine" set -ea if [ "$OS" == "" ] @@ -15,8 +15,8 @@ cp $NAME $GOPATH/bin/ # 需要执行如下三条指令 来映射CLI到本地路径 # 如果小于此版本可以不做这三个操作 # shellcheck disable=SC2154 -#mkdir -p ~/.terraform.d/plugins/registry.terraform.io/hashicorp/vestack/0.0.1/"$OS"_amd64/ -#rm -f ~/.terraform.d/plugins/registry.terraform.io/hashicorp/vestack/0.0.1/"$OS"_amd64/"$NAME"_v0.0.1 -#cp $NAME ~/.terraform.d/plugins/registry.terraform.io/hashicorp/vestack/0.0.1/"$OS"_amd64/"$NAME"_v0.0.1 +#mkdir -p ~/.terraform.d/plugins/registry.terraform.io/hashicorp/volcengine/0.0.1/"$OS"_amd64/ +#rm -f ~/.terraform.d/plugins/registry.terraform.io/hashicorp/volcengine/0.0.1/"$OS"_amd64/"$NAME"_v0.0.1 +#cp $NAME ~/.terraform.d/plugins/registry.terraform.io/hashicorp/volcengine/0.0.1/"$OS"_amd64/"$NAME"_v0.0.1 rm -f $NAME \ No newline at end of file diff --git a/build_scm.sh b/build_scm.sh index 88002f6d..af09e3ee 100644 --- a/build_scm.sh +++ b/build_scm.sh @@ -7,7 +7,7 @@ LINUX_SUPPORT_GOARCH=("386" "amd64" "arm64" "arm") MAC_SUPPORT_GOARCH=("amd64" "arm64") WIN_SUPPORT_GOARCH=("386" "amd64") -NAME="terraform-provider-vestack" +NAME="terraform-provider-volcengine" set -ea for goos in "${SUPPORT_GOOS[@]}" diff --git a/common/common_vestack_client.go b/common/common_vestack_client.go deleted file mode 100644 index f8e79b7b..00000000 --- a/common/common_vestack_client.go +++ /dev/null @@ -1,28 +0,0 @@ -package common - -import ( - "github.com/volcengine/volcstack-go-sdk/service/autoscaling" - "github.com/volcengine/volcstack-go-sdk/service/clb" - "github.com/volcengine/volcstack-go-sdk/service/ecs" - "github.com/volcengine/volcstack-go-sdk/service/natgateway" - "github.com/volcengine/volcstack-go-sdk/service/rdsmysql" - "github.com/volcengine/volcstack-go-sdk/service/rdsmysqlv2" - "github.com/volcengine/volcstack-go-sdk/service/storageebs" - "github.com/volcengine/volcstack-go-sdk/service/vpc" - "github.com/volcengine/volcstack-go-sdk/service/vpn" -) - -type SdkClient struct { - Region string - VpcClient *vpc.VPC - ClbClient *clb.CLB - EcsClient *ecs.ECS - EbsClient *storageebs.STORAGEEBS - NatClient *natgateway.NATGATEWAY - VpnClient *vpn.VPN - AutoScalingClient *autoscaling.AUTOSCALING - RdsClient *rdsmysql.RDSMYSQL - RdsClientV2 *rdsmysqlv2.RDSMYSQLV2 - UniversalClient *Universal - TosClient *Tos -} diff --git a/common/common_vestack_callback.go b/common/common_volcengine_callback.go similarity index 100% rename from common/common_vestack_callback.go rename to common/common_volcengine_callback.go diff --git a/common/common_vestack_callback_test.go b/common/common_volcengine_callback_test.go similarity index 100% rename from common/common_vestack_callback_test.go rename to common/common_volcengine_callback_test.go diff --git a/common/common_volcengine_client.go b/common/common_volcengine_client.go new file mode 100644 index 00000000..64e281ee --- /dev/null +++ b/common/common_volcengine_client.go @@ -0,0 +1,28 @@ +package common + +import ( + "github.com/volcengine/volcengine-go-sdk/service/autoscaling" + "github.com/volcengine/volcengine-go-sdk/service/clb" + "github.com/volcengine/volcengine-go-sdk/service/ecs" + "github.com/volcengine/volcengine-go-sdk/service/natgateway" + "github.com/volcengine/volcengine-go-sdk/service/rdsmysql" + "github.com/volcengine/volcengine-go-sdk/service/rdsmysqlv2" + "github.com/volcengine/volcengine-go-sdk/service/storageebs" + "github.com/volcengine/volcengine-go-sdk/service/vpc" + "github.com/volcengine/volcengine-go-sdk/service/vpn" +) + +type SdkClient struct { + Region string + VpcClient *vpc.VPC + ClbClient *clb.CLB + EcsClient *ecs.ECS + EbsClient *storageebs.STORAGEEBS + NatClient *natgateway.NATGATEWAY + VpnClient *vpn.VPN + AutoScalingClient *autoscaling.AUTOSCALING + RdsClient *rdsmysql.RDSMYSQL + RdsClientV2 *rdsmysqlv2.RDSMYSQLV2 + UniversalClient *Universal + TosClient *Tos +} diff --git a/common/common_vestack_config.go b/common/common_volcengine_config.go similarity index 54% rename from common/common_vestack_config.go rename to common/common_volcengine_config.go index 66ac98bd..03080e2b 100644 --- a/common/common_vestack_config.go +++ b/common/common_volcengine_config.go @@ -3,19 +3,19 @@ package common import ( "fmt" - "github.com/volcengine/volcstack-go-sdk/service/autoscaling" - "github.com/volcengine/volcstack-go-sdk/service/clb" - "github.com/volcengine/volcstack-go-sdk/service/ecs" - "github.com/volcengine/volcstack-go-sdk/service/natgateway" - "github.com/volcengine/volcstack-go-sdk/service/rdsmysql" - "github.com/volcengine/volcstack-go-sdk/service/rdsmysqlv2" - "github.com/volcengine/volcstack-go-sdk/service/storageebs" - "github.com/volcengine/volcstack-go-sdk/service/vpc" - "github.com/volcengine/volcstack-go-sdk/service/vpn" - "github.com/volcengine/volcstack-go-sdk/volcstack" - "github.com/volcengine/volcstack-go-sdk/volcstack/credentials" - "github.com/volcengine/volcstack-go-sdk/volcstack/session" - "github.com/volcengine/volcstack-go-sdk/volcstack/volcstackutil" + "github.com/volcengine/volcengine-go-sdk/service/autoscaling" + "github.com/volcengine/volcengine-go-sdk/service/clb" + "github.com/volcengine/volcengine-go-sdk/service/ecs" + "github.com/volcengine/volcengine-go-sdk/service/natgateway" + "github.com/volcengine/volcengine-go-sdk/service/rdsmysql" + "github.com/volcengine/volcengine-go-sdk/service/rdsmysqlv2" + "github.com/volcengine/volcengine-go-sdk/service/storageebs" + "github.com/volcengine/volcengine-go-sdk/service/vpc" + "github.com/volcengine/volcengine-go-sdk/service/vpn" + "github.com/volcengine/volcengine-go-sdk/volcengine" + "github.com/volcengine/volcengine-go-sdk/volcengine/credentials" + "github.com/volcengine/volcengine-go-sdk/volcengine/session" + "github.com/volcengine/volcengine-go-sdk/volcengine/volcengineutil" ) type Config struct { @@ -31,12 +31,12 @@ func (c *Config) Client() (*SdkClient, error) { var client SdkClient version := fmt.Sprintf("%s/%s", TerraformProviderName, TerraformProviderVersion) - config := volcstack.NewConfig(). + config := volcengine.NewConfig(). WithRegion(c.Region). - WithExtraUserAgent(volcstack.String(version)). + WithExtraUserAgent(volcengine.String(version)). WithCredentials(credentials.NewStaticCredentials(c.AccessKey, c.SecretKey, c.SessionToken)). WithDisableSSL(c.DisableSSL). - WithEndpoint(volcstackutil.NewEndpoint().WithCustomerEndpoint(c.Endpoint).GetEndpoint()) + WithEndpoint(volcengineutil.NewEndpoint().WithCustomerEndpoint(c.Endpoint).GetEndpoint()) sess, err := session.NewSession(config) if err != nil { diff --git a/common/common_vestack_const.go b/common/common_volcengine_const.go similarity index 100% rename from common/common_vestack_const.go rename to common/common_volcengine_const.go diff --git a/common/common_vestack_convert.go b/common/common_volcengine_convert.go similarity index 100% rename from common/common_vestack_convert.go rename to common/common_volcengine_convert.go diff --git a/common/common_vestack_data_source.go b/common/common_volcengine_data_source.go similarity index 100% rename from common/common_vestack_data_source.go rename to common/common_volcengine_data_source.go diff --git a/common/common_vestack_diff_collection.go b/common/common_volcengine_diff_collection.go similarity index 100% rename from common/common_vestack_diff_collection.go rename to common/common_volcengine_diff_collection.go diff --git a/common/common_vestack_diff_suppress_func.go b/common/common_volcengine_diff_suppress_func.go similarity index 100% rename from common/common_vestack_diff_suppress_func.go rename to common/common_volcengine_diff_suppress_func.go diff --git a/common/common_vestack_dispatcher.go b/common/common_volcengine_dispatcher.go similarity index 100% rename from common/common_vestack_dispatcher.go rename to common/common_volcengine_dispatcher.go diff --git a/common/common_vestack_error.go b/common/common_volcengine_error.go similarity index 75% rename from common/common_vestack_error.go rename to common/common_volcengine_error.go index 8a078312..7bda567a 100644 --- a/common/common_vestack_error.go +++ b/common/common_volcengine_error.go @@ -3,11 +3,11 @@ package common import ( "strings" - "github.com/volcengine/volcstack-go-sdk/volcstack/volcstackerr" + "github.com/volcengine/volcengine-go-sdk/volcengine/volcengineerr" ) func ResourceNotFoundError(err error) bool { - if e, ok := err.(volcstackerr.RequestFailure); ok && e.StatusCode() == 404 { + if e, ok := err.(volcengineerr.RequestFailure); ok && e.StatusCode() == 404 { return true } errMessage := strings.ToLower(err.Error()) diff --git a/common/common_vestack_handler.go b/common/common_volcengine_handler.go similarity index 100% rename from common/common_vestack_handler.go rename to common/common_volcengine_handler.go diff --git a/common/common_vestack_hashcodes.go b/common/common_volcengine_hashcodes.go similarity index 100% rename from common/common_vestack_hashcodes.go rename to common/common_volcengine_hashcodes.go diff --git a/common/common_vestack_interface.go b/common/common_volcengine_interface.go similarity index 100% rename from common/common_vestack_interface.go rename to common/common_volcengine_interface.go diff --git a/common/common_vestack_lock.go b/common/common_volcengine_lock.go similarity index 100% rename from common/common_vestack_lock.go rename to common/common_volcengine_lock.go diff --git a/common/common_vestack_page.go b/common/common_volcengine_page.go similarity index 100% rename from common/common_vestack_page.go rename to common/common_volcengine_page.go diff --git a/common/common_vestack_sync_limit.go b/common/common_volcengine_sync_limit.go similarity index 100% rename from common/common_vestack_sync_limit.go rename to common/common_volcengine_sync_limit.go diff --git a/common/common_vestack_tos_client.go b/common/common_volcengine_tos_client.go similarity index 90% rename from common/common_vestack_tos_client.go rename to common/common_volcengine_tos_client.go index aeebfd43..0aaf6ae6 100644 --- a/common/common_vestack_tos_client.go +++ b/common/common_volcengine_tos_client.go @@ -4,11 +4,11 @@ import ( "fmt" "io/ioutil" - "github.com/volcengine/volcstack-go-sdk/volcstack/client" - "github.com/volcengine/volcstack-go-sdk/volcstack/client/metadata" - "github.com/volcengine/volcstack-go-sdk/volcstack/corehandlers" - "github.com/volcengine/volcstack-go-sdk/volcstack/request" - "github.com/volcengine/volcstack-go-sdk/volcstack/session" + "github.com/volcengine/volcengine-go-sdk/volcengine/client" + "github.com/volcengine/volcengine-go-sdk/volcengine/client/metadata" + "github.com/volcengine/volcengine-go-sdk/volcengine/corehandlers" + "github.com/volcengine/volcengine-go-sdk/volcengine/request" + "github.com/volcengine/volcengine-go-sdk/volcengine/session" ) const ( diff --git a/common/common_vestack_tos_handler.go b/common/common_volcengine_tos_handler.go similarity index 93% rename from common/common_vestack_tos_handler.go rename to common/common_volcengine_tos_handler.go index 516d1d93..772ea402 100644 --- a/common/common_vestack_tos_handler.go +++ b/common/common_volcengine_tos_handler.go @@ -17,10 +17,10 @@ import ( "strings" "time" - "github.com/volcengine/volcstack-go-sdk/volcstack" - "github.com/volcengine/volcstack-go-sdk/volcstack/request" - "github.com/volcengine/volcstack-go-sdk/volcstack/volcstackbody" - "github.com/volcengine/volcstack-go-sdk/volcstack/volcstackerr" + "github.com/volcengine/volcengine-go-sdk/volcengine" + "github.com/volcengine/volcengine-go-sdk/volcengine/request" + "github.com/volcengine/volcengine-go-sdk/volcengine/volcenginebody" + "github.com/volcengine/volcengine-go-sdk/volcengine/volcengineerr" ) var tosSignRequestHandler = request.NamedHandler{Name: "TosSignRequestHandler", Fn: tosSign} @@ -35,7 +35,7 @@ func tosSign(req *request.Request) { c Credentials ) - region = volcstack.StringValue(req.Config.Region) + region = volcengine.StringValue(req.Config.Region) name := req.ClientInfo.SigningName if name == "" { @@ -87,12 +87,12 @@ func tosBuild(r *request.Request) { strings.ToUpper(r.HTTPRequest.Method) == "PATCH") && strings.Contains(strings.ToLower(contentType), "application/json") { r.HTTPRequest.Header.Set("Content-Type", "application/json; charset=utf-8") - volcstackbody.BodyJson(&body, r) + volcenginebody.BodyJson(&body, r) } else { if len(contentType) > 0 && !strings.Contains(strings.ToLower(contentType), "x-www-form-urlencoded") { r.HTTPRequest.Header.Del("Content-Type") } - volcstackbody.BodyParam(&body, r) + volcenginebody.BodyParam(&body, r) if len(contentType) > 0 { r.HTTPRequest.Header.Set("Content-Type", contentType) } @@ -347,7 +347,7 @@ func tosUnmarshal(r *request.Request) { if r.DataFilled() { body, err := ioutil.ReadAll(r.HTTPResponse.Body) if err != nil { - fmt.Printf("read volcstackbody err, %v\n", err) + fmt.Printf("read volcenginebody err, %v\n", err) r.Error = err return } @@ -383,7 +383,7 @@ func tosUnmarshalError(r *request.Request) { if r.DataFilled() { body, err := ioutil.ReadAll(r.HTTPResponse.Body) if err != nil { - fmt.Printf("read volcstackbody err, %v\n", err) + fmt.Printf("read volcenginebody err, %v\n", err) r.Error = err return } @@ -393,16 +393,16 @@ func tosUnmarshalError(r *request.Request) { r.Error = err return } - r.Error = volcstackerr.NewRequestFailure( - volcstackerr.New(tos.Code, tos.Message, nil), + r.Error = volcengineerr.NewRequestFailure( + volcengineerr.New(tos.Code, tos.Message, nil), r.HTTPResponse.StatusCode, tos.RequestId, ) return } else { - r.Error = volcstackerr.NewRequestFailure( - volcstackerr.New("ServiceUnavailableException", "service is unavailable", nil), + r.Error = volcengineerr.NewRequestFailure( + volcengineerr.New("ServiceUnavailableException", "service is unavailable", nil), r.HTTPResponse.StatusCode, r.RequestID, ) diff --git a/common/common_vestack_tos_utils.go b/common/common_volcengine_tos_utils.go similarity index 100% rename from common/common_vestack_tos_utils.go rename to common/common_volcengine_tos_utils.go diff --git a/common/common_vestack_universal_client.go b/common/common_volcengine_universal_client.go similarity index 73% rename from common/common_vestack_universal_client.go rename to common/common_volcengine_universal_client.go index 2be67842..06eae723 100644 --- a/common/common_vestack_universal_client.go +++ b/common/common_volcengine_universal_client.go @@ -1,13 +1,13 @@ package common import ( - "github.com/volcengine/volcstack-go-sdk/volcstack/client" - "github.com/volcengine/volcstack-go-sdk/volcstack/client/metadata" - "github.com/volcengine/volcstack-go-sdk/volcstack/corehandlers" - "github.com/volcengine/volcstack-go-sdk/volcstack/request" - "github.com/volcengine/volcstack-go-sdk/volcstack/session" - "github.com/volcengine/volcstack-go-sdk/volcstack/signer/volc" - "github.com/volcengine/volcstack-go-sdk/volcstack/volcstackquery" + "github.com/volcengine/volcengine-go-sdk/volcengine/client" + "github.com/volcengine/volcengine-go-sdk/volcengine/client/metadata" + "github.com/volcengine/volcengine-go-sdk/volcengine/corehandlers" + "github.com/volcengine/volcengine-go-sdk/volcengine/request" + "github.com/volcengine/volcengine-go-sdk/volcengine/session" + "github.com/volcengine/volcengine-go-sdk/volcengine/signer/volc" + "github.com/volcengine/volcengine-go-sdk/volcengine/volcenginequery" ) type HttpMethod int @@ -62,10 +62,10 @@ func (u *Universal) newTargetClient(svc string, version string) *client.Client { c.Handlers.Build.PushBackNamed(corehandlers.SDKVersionUserAgentHandler) c.Handlers.Build.PushBackNamed(corehandlers.AddHostExecEnvUserAgentHandler) c.Handlers.Sign.PushBackNamed(volc.SignRequestHandler) - c.Handlers.Build.PushBackNamed(volcstackquery.BuildHandler) - c.Handlers.Unmarshal.PushBackNamed(volcstackquery.UnmarshalHandler) - c.Handlers.UnmarshalMeta.PushBackNamed(volcstackquery.UnmarshalMetaHandler) - c.Handlers.UnmarshalError.PushBackNamed(volcstackquery.UnmarshalErrorHandler) + c.Handlers.Build.PushBackNamed(volcenginequery.BuildHandler) + c.Handlers.Unmarshal.PushBackNamed(volcenginequery.UnmarshalHandler) + c.Handlers.UnmarshalMeta.PushBackNamed(volcenginequery.UnmarshalMetaHandler) + c.Handlers.UnmarshalError.PushBackNamed(volcenginequery.UnmarshalErrorHandler) return c } diff --git a/common/common_vestack_util.go b/common/common_volcengine_util.go similarity index 100% rename from common/common_vestack_util.go rename to common/common_volcengine_util.go diff --git a/common/common_vestack_version.go b/common/common_volcengine_version.go similarity index 50% rename from common/common_vestack_version.go rename to common/common_volcengine_version.go index 962d32d3..511a9576 100644 --- a/common/common_vestack_version.go +++ b/common/common_volcengine_version.go @@ -1,6 +1,6 @@ package common const ( - TerraformProviderName = "terraform-provider-vestack" + TerraformProviderName = "terraform-provider-volcengine" TerraformProviderVersion = "0.0.5" ) diff --git a/docgen/main.go b/docgen/main.go index 4f6d5b39..2202ecef 100644 --- a/docgen/main.go +++ b/docgen/main.go @@ -15,8 +15,8 @@ import ( "github.com/fatih/color" "github.com/hashicorp/hcl/v2/hclwrite" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/volcengine/terraform-provider-vestack/common" - ve "github.com/volcengine/terraform-provider-vestack/vestack" + "github.com/volcengine/terraform-provider-volcengine/common" + ve "github.com/volcengine/terraform-provider-volcengine/volcengine" ) const ( @@ -87,11 +87,11 @@ In addition to all arguments above, the following attributes are exported: ) const ( - cloudMark = "vestack" - cloudTitle = "Vestack" + cloudMark = "volcengine" + cloudTitle = "Volcengine" cloudPrefix = cloudMark + "_" docRoot = "/website" - providerRoot = "/vestack" + providerRoot = "/volcengine" exampleRoot = "/example" ) diff --git a/example/acl/main.tf b/example/acl/main.tf index 00ca82f4..20d3577a 100644 --- a/example/acl/main.tf +++ b/example/acl/main.tf @@ -1,4 +1,4 @@ -resource "vestack_acl" "foo" { +resource "volcengine_acl" "foo" { acl_name = "tf-test-2" acl_entries { entry = "172.20.1.0/24" diff --git a/example/aclEntry/main.tf b/example/aclEntry/main.tf index fef8713e..c49c7cb3 100644 --- a/example/aclEntry/main.tf +++ b/example/aclEntry/main.tf @@ -1,10 +1,10 @@ -resource "vestack_acl" "foo" { +resource "volcengine_acl" "foo" { acl_name = "tf-test-3" description = "tf-test" } -resource "vestack_acl_entry" "foo" { - acl_id = vestack_acl.foo.id +resource "volcengine_acl_entry" "foo" { + acl_id = volcengine_acl.foo.id description = "tf acl entry desc demo" entry = "192.2.2.1/32" } \ No newline at end of file diff --git a/example/certificate/main.tf b/example/certificate/main.tf index d76d9930..d442b5d4 100644 --- a/example/certificate/main.tf +++ b/example/certificate/main.tf @@ -5,7 +5,7 @@ variable "certificate" { }) } -resource "vestack_certificate" "foo" { +resource "volcengine_certificate" "foo" { certificate_name = "demo-certificate" description = "This is a clb certificate" public_key = var.certificate.public_key diff --git a/example/clb/main.tf b/example/clb/main.tf index acdec9d2..cec1a44d 100644 --- a/example/clb/main.tf +++ b/example/clb/main.tf @@ -1,4 +1,4 @@ -resource "vestack_clb" "foo" { +resource "volcengine_clb" "foo" { type = "public" subnet_id = "subnet-2744i7u9alnnk7fap8tkq8aft" load_balancer_spec = "small_1" diff --git a/example/dataAcls/main.tf b/example/dataAcls/main.tf index ceb430c2..fb1d38bf 100644 --- a/example/dataAcls/main.tf +++ b/example/dataAcls/main.tf @@ -1,3 +1,3 @@ -data "vestack_acls" "default"{ +data "volcengine_acls" "default"{ ids = ["acl-3ti8n0rurx4bwbh9jzdy"] } diff --git a/example/dataCertificates/main.tf b/example/dataCertificates/main.tf index a47bf64f..c6c1afa2 100644 --- a/example/dataCertificates/main.tf +++ b/example/dataCertificates/main.tf @@ -1,3 +1,3 @@ -data "vestack_certificates" "default" { +data "volcengine_certificates" "default" { ids = ["cert-274scdwqufwg07fap8u5fu8pi"] } diff --git a/example/dataClbs/main.tf b/example/dataClbs/main.tf index 1cb3bf51..b2df6676 100644 --- a/example/dataClbs/main.tf +++ b/example/dataClbs/main.tf @@ -1,3 +1,3 @@ -data "vestack_clbs" "default"{ +data "volcengine_clbs" "default"{ ids = ["clb-273y2ok6ets007fap8txvf6us"] } \ No newline at end of file diff --git a/example/dataEcsInstances/main.tf b/example/dataEcsInstances/main.tf index c336d2e5..f72fe9c0 100644 --- a/example/dataEcsInstances/main.tf +++ b/example/dataEcsInstances/main.tf @@ -1,3 +1,3 @@ -data "vestack_ecs_instances" "foo" { +data "volcengine_ecs_instances" "foo" { ids = ["i-ebgy6xmgjve0384ncgsc"] } \ No newline at end of file diff --git a/example/dataEipAddresses/main.tf b/example/dataEipAddresses/main.tf index e3d1237e..cc2aad03 100644 --- a/example/dataEipAddresses/main.tf +++ b/example/dataEipAddresses/main.tf @@ -1,3 +1,3 @@ -data "vestack_eip_addresses" "default"{ +data "volcengine_eip_addresses" "default"{ ids = ["eip-2748mbpjqzhfk7fap8teu0k1a"] } \ No newline at end of file diff --git a/example/dataImages/main.tf b/example/dataImages/main.tf index 542d4b71..0edd5a80 100644 --- a/example/dataImages/main.tf +++ b/example/dataImages/main.tf @@ -1,3 +1,3 @@ -data "vestack_images" "default" { +data "volcengine_images" "default" { ids = ["image-cm9ssb4eqmhdas306zlp", "image-ybkzct2rtj4ay5rmlfc3"] } \ No newline at end of file diff --git a/example/dataListeners/main.tf b/example/dataListeners/main.tf index d112327f..cc598e3d 100644 --- a/example/dataListeners/main.tf +++ b/example/dataListeners/main.tf @@ -1,3 +1,3 @@ -data "vestack_listeners" "default" { +data "volcengine_listeners" "default" { ids = ["lsn-273yv0mhs5xj47fap8sehiiso", "lsn-273yw6zps6pz47fap8swa0q2z"] } \ No newline at end of file diff --git a/example/dataNatGateways/main.tf b/example/dataNatGateways/main.tf index ebe732b9..fa065093 100644 --- a/example/dataNatGateways/main.tf +++ b/example/dataNatGateways/main.tf @@ -1,3 +1,3 @@ -data "vestack_nat_gateways" "default" { +data "volcengine_nat_gateways" "default" { ids = ["ngw-2743w1f6iqby87fap8tvm9kop", "ngw-274gwbqe340zk7fap8spkzo7x"] } \ No newline at end of file diff --git a/example/dataNetworkInterfaces/main.tf b/example/dataNetworkInterfaces/main.tf index 6161cce3..c300ffca 100644 --- a/example/dataNetworkInterfaces/main.tf +++ b/example/dataNetworkInterfaces/main.tf @@ -1,3 +1,3 @@ -data "vestack_network_interfaces" "default"{ +data "volcengine_network_interfaces" "default"{ ids = ["eni-2744htx2w0j5s7fap8t3ivwze"] } \ No newline at end of file diff --git a/example/dataRouteEntries/main.tf b/example/dataRouteEntries/main.tf index 70548fab..a96e77a0 100644 --- a/example/dataRouteEntries/main.tf +++ b/example/dataRouteEntries/main.tf @@ -1,4 +1,4 @@ -data "vestack_route_entries" "default"{ +data "volcengine_route_entries" "default"{ ids = [] route_table_id = "vtb-274e19skkuhog7fap8u4i8ird" } \ No newline at end of file diff --git a/example/dataRouteTables/main.tf b/example/dataRouteTables/main.tf index 49d090bb..aea41e20 100644 --- a/example/dataRouteTables/main.tf +++ b/example/dataRouteTables/main.tf @@ -1,4 +1,4 @@ -data "vestack_route_tables" "default"{ +data "volcengine_route_tables" "default"{ ids = ["vtb-274e19skkuhog7fap8u4i8ird", "vtb-2744hslq5b7r47fap8tjomgnj"] route_table_name = "vpc-fast" } \ No newline at end of file diff --git a/example/dataRules/main.tf b/example/dataRules/main.tf index b8669e9e..25f8f1ed 100644 --- a/example/dataRules/main.tf +++ b/example/dataRules/main.tf @@ -1,8 +1,8 @@ -data "vestack_clb_rules" "default"{ +data "volcengine_clb_rules" "default"{ listener_id = "lsn-273ywvnmiu70g7fap8u2xzg9d" ids = ["rule-273z9jo9v3mrk7fap8sq8v5x7"] } output "data" { - value = data.vestack_clb_rules.default + value = data.volcengine_clb_rules.default } \ No newline at end of file diff --git a/example/dataSecurityGroups/main.tf b/example/dataSecurityGroups/main.tf index b3794bfb..2762d418 100644 --- a/example/dataSecurityGroups/main.tf +++ b/example/dataSecurityGroups/main.tf @@ -1,3 +1,3 @@ -data "vestack_security_groups" "default"{ +data "volcengine_security_groups" "default"{ ids = ["sg-273ycgql3ig3k7fap8t3dyvqx"] } \ No newline at end of file diff --git a/example/dataServerGroupServers/main.tf b/example/dataServerGroupServers/main.tf index 5b87bb5a..6d602e7a 100644 --- a/example/dataServerGroupServers/main.tf +++ b/example/dataServerGroupServers/main.tf @@ -1,4 +1,4 @@ -data "vestack_server_group_servers" "default" { +data "volcengine_server_group_servers" "default" { ids = ["rs-273z9pv8mtfcw7fap8sp6ie8k"] server_group_id = "rsp-273z9pt9lpdds7fap8sqdvfrf" } \ No newline at end of file diff --git a/example/dataServerGroups/main.tf b/example/dataServerGroups/main.tf index 8ed6008a..f78ac71b 100644 --- a/example/dataServerGroups/main.tf +++ b/example/dataServerGroups/main.tf @@ -1,3 +1,3 @@ -data "vestack_server_groups" "default" { +data "volcengine_server_groups" "default" { ids = ["rsp-273yv0kir1vk07fap8tt9jtwg", "rsp-273yxuqfova4g7fap8tyemn6t", "rsp-273z9pt9lpdds7fap8sqdvfrf"] } \ No newline at end of file diff --git a/example/dataSnatEntries/main.tf b/example/dataSnatEntries/main.tf index 1484a3b8..411462fc 100644 --- a/example/dataSnatEntries/main.tf +++ b/example/dataSnatEntries/main.tf @@ -1,3 +1,3 @@ -data "vestack_snat_entries" "default" { +data "volcengine_snat_entries" "default" { ids = ["snat-274zl8b1kxzb47fap8u35uune"] } \ No newline at end of file diff --git a/example/dataSubnets/main.tf b/example/dataSubnets/main.tf index 90aa5ba5..9fc831d4 100644 --- a/example/dataSubnets/main.tf +++ b/example/dataSubnets/main.tf @@ -1,3 +1,3 @@ -data "vestack_subnets" "default"{ +data "volcengine_subnets" "default"{ ids = ["subnet-274zsa5kfmj287fap8soo5e19"] } \ No newline at end of file diff --git a/example/dataTosBuckets/main.tf b/example/dataTosBuckets/main.tf index a6ca42fe..c3fcb09c 100644 --- a/example/dataTosBuckets/main.tf +++ b/example/dataTosBuckets/main.tf @@ -1,3 +1,3 @@ -data "vestack_tos_buckets" "default" { +data "volcengine_tos_buckets" "default" { name_regex= "test" } \ No newline at end of file diff --git a/example/dataVolumes/main.tf b/example/dataVolumes/main.tf index 18d6b978..ffa2f0df 100644 --- a/example/dataVolumes/main.tf +++ b/example/dataVolumes/main.tf @@ -1,3 +1,3 @@ -data "vestack_volumes" "default"{ +data "volcengine_volumes" "default"{ ids = ["vol-3tzg6y5imn3b9fchkedb"] } \ No newline at end of file diff --git a/example/dataVpcs/main.tf b/example/dataVpcs/main.tf index e980f9a7..13dd9cfd 100644 --- a/example/dataVpcs/main.tf +++ b/example/dataVpcs/main.tf @@ -1,3 +1,3 @@ -data "vestack_vpcs" "default"{ +data "volcengine_vpcs" "default"{ ids = ["vpc-mizl7m1kqccg5smt1bdpijuj"] } \ No newline at end of file diff --git a/example/dataZones/main.tf b/example/dataZones/main.tf index b44f7c04..71ab07ca 100644 --- a/example/dataZones/main.tf +++ b/example/dataZones/main.tf @@ -1,3 +1,3 @@ -data "vestack_zones" "default"{ +data "volcengine_zones" "default"{ ids = ["cn-lingqiu-a"] } \ No newline at end of file diff --git a/example/demo/main.tf b/example/demo/main.tf index 0cf6202e..9fcce1be 100644 --- a/example/demo/main.tf +++ b/example/demo/main.tf @@ -1,4 +1,4 @@ -resource "vestack_demo" "default" { +resource "volcengine_demo" "default" { name = "vif-name" network_interfaces { subnet_id = "vnet-id" diff --git a/example/ecsInstance/main.tf b/example/ecsInstance/main.tf index 8925913a..571248d5 100644 --- a/example/ecsInstance/main.tf +++ b/example/ecsInstance/main.tf @@ -1,21 +1,21 @@ -resource "vestack_vpc" "foo" { +resource "volcengine_vpc" "foo" { vpc_name = "tf-test-2" cidr_block = "172.16.0.0/16" } -resource "vestack_subnet" "foo1" { +resource "volcengine_subnet" "foo1" { subnet_name = "subnet-test-1" cidr_block = "172.16.1.0/24" zone_id = "cn-beijing-a" - vpc_id = vestack_vpc.foo.id + vpc_id = volcengine_vpc.foo.id } -resource "vestack_security_group" "foo1" { - depends_on = [vestack_subnet.foo1] - vpc_id = vestack_vpc.foo.id +resource "volcengine_security_group" "foo1" { + depends_on = [volcengine_subnet.foo1] + vpc_id = volcengine_vpc.foo.id } -resource "vestack_ecs_instance" "default" { +resource "volcengine_ecs_instance" "default" { zone_id = "cn-beijing-a" image_id = "image-aagd56zrw2jtdro3bnrl" instance_type = "ecs.g1.large" @@ -25,15 +25,15 @@ resource "vestack_ecs_instance" "default" { instance_charge_type = "PostPaid" system_volume_type = "PTSSD" system_volume_size = 60 - subnet_id = vestack_subnet.foo1.id - security_group_ids = [vestack_security_group.foo1.id] + subnet_id = volcengine_subnet.foo1.id + security_group_ids = [volcengine_security_group.foo1.id] data_volumes { volume_type = "PTSSD" size = 100 delete_with_instance = true } # secondary_network_interfaces { -# subnet_id = vestack_subnet.foo1.id -# security_group_ids = [vestack_security_group.foo1.id] +# subnet_id = volcengine_subnet.foo1.id +# security_group_ids = [volcengine_security_group.foo1.id] # } } diff --git a/example/ecsInstanceState/main.tf b/example/ecsInstanceState/main.tf index 60771b26..b4c1ed37 100644 --- a/example/ecsInstanceState/main.tf +++ b/example/ecsInstanceState/main.tf @@ -1,4 +1,4 @@ -resource "vestack_ecs_instance_state" "foo" { +resource "volcengine_ecs_instance_state" "foo" { instance_id = "i-l8u2ai4j0fauo6mrpgk8" action = "Start" } \ No newline at end of file diff --git a/example/eipAddress/main.tf b/example/eipAddress/main.tf index 5dc779f6..fa792e73 100644 --- a/example/eipAddress/main.tf +++ b/example/eipAddress/main.tf @@ -1,4 +1,4 @@ -resource "vestack_eip_address" "foo" { +resource "volcengine_eip_address" "foo" { billing_type = "PostPaidByBandwidth" bandwidth = 1 isp = "BGP" diff --git a/example/eipAssociate/main.tf b/example/eipAssociate/main.tf index 2974a7c8..36643dd6 100644 --- a/example/eipAssociate/main.tf +++ b/example/eipAssociate/main.tf @@ -1,4 +1,4 @@ -resource "vestack_eip_associate" "foo" { +resource "volcengine_eip_associate" "foo" { allocation_id = "eip-273ybrd0oeo007fap8t0nggtx" instance_id = "i-cm9tjw9zp9j942mfkczp" instance_type = "EcsInstance" diff --git a/example/listener/main.tf b/example/listener/main.tf index 07d5e648..1eec493a 100644 --- a/example/listener/main.tf +++ b/example/listener/main.tf @@ -1,4 +1,4 @@ -resource "vestack_listener" "foo" { +resource "volcengine_listener" "foo" { load_balancer_id = "clb-273ylkl0a3i807fap8t4unbsq" listener_name = "Demo-HTTP-90" protocol = "HTTP" diff --git a/example/natGateway/main.tf b/example/natGateway/main.tf index 30d26a0c..91ded8cf 100644 --- a/example/natGateway/main.tf +++ b/example/natGateway/main.tf @@ -1,4 +1,4 @@ -resource "vestack_nat_gateway" "foo" { +resource "volcengine_nat_gateway" "foo" { vpc_id = "vpc-2740cxyk9im0w7fap8u013dfe" subnet_id = "subnet-2740cym8mv9q87fap8u3hfx4i" spec = "Medium" diff --git a/example/networkInterface/main.tf b/example/networkInterface/main.tf index 4be447ad..49f141e5 100644 --- a/example/networkInterface/main.tf +++ b/example/networkInterface/main.tf @@ -1,4 +1,4 @@ -resource "vestack_network_interface" "foo" { +resource "volcengine_network_interface" "foo" { subnet_id = "subnet-2744ht7fhjthc7fap8tm10eqg" security_group_ids = ["sg-2744hspo7jbpc7fap8t7lef1p"] primary_ip_address = "192.168.0.253" diff --git a/example/networkInterfaceAttach/main.tf b/example/networkInterfaceAttach/main.tf index 0fe049da..7a5c7c4e 100644 --- a/example/networkInterfaceAttach/main.tf +++ b/example/networkInterfaceAttach/main.tf @@ -1,4 +1,4 @@ -resource "vestack_network_interface_attach" "foo" { +resource "volcengine_network_interface_attach" "foo" { network_interface_id = "eni-274ecj646ylts7fap8t6xbba1" instance_id = "i-72q20hi6s082wcafdem8" } \ No newline at end of file diff --git a/example/routeEntry/main.tf b/example/routeEntry/main.tf index 00cb6d77..bb43441d 100644 --- a/example/routeEntry/main.tf +++ b/example/routeEntry/main.tf @@ -1,4 +1,4 @@ -resource "vestack_route_entry" "foo" { +resource "volcengine_route_entry" "foo" { route_table_id = "vtb-2744hslq5b7r47fap8tjomgnj" destination_cidr_block = "0.0.0.0/2" next_hop_type = "NatGW" diff --git a/example/routeTable/main.tf b/example/routeTable/main.tf index ebcdc260..2bc1834e 100644 --- a/example/routeTable/main.tf +++ b/example/routeTable/main.tf @@ -1,4 +1,4 @@ -resource "vestack_route_table" "foo" { +resource "volcengine_route_table" "foo" { vpc_id = "vpc-2744hsjr475s07fap8t4jbl1c" route_table_name = "tf-test1" description = "tf-test1" diff --git a/example/routeTableAssociate/main.tf b/example/routeTableAssociate/main.tf index 1f16f67e..554bdd83 100644 --- a/example/routeTableAssociate/main.tf +++ b/example/routeTableAssociate/main.tf @@ -1,4 +1,4 @@ -resource "vestack_route_table_associate" "foo" { +resource "volcengine_route_table_associate" "foo" { route_table_id = "vtb-274e19skkuhog7fap8u4i8ird" subnet_id = "subnet-2744ht7fhjthc7fap8tm10eqg" } \ No newline at end of file diff --git a/example/rule/main.tf b/example/rule/main.tf index 32ec2741..d97f4261 100644 --- a/example/rule/main.tf +++ b/example/rule/main.tf @@ -1,4 +1,4 @@ -resource "vestack_clb_rule" "foo" { +resource "volcengine_clb_rule" "foo" { listener_id = "lsn-273ywvnmiu70g7fap8u2xzg9d" server_group_id = "rsp-273yxuqfova4g7fap8tyemn6t" domain = "test-volc123.com" diff --git a/example/securityGroup/main.tf b/example/securityGroup/main.tf index fe199b79..265dc65c 100644 --- a/example/securityGroup/main.tf +++ b/example/securityGroup/main.tf @@ -1,3 +1,3 @@ -resource "vestack_security_group" "g1test1" { +resource "volcengine_security_group" "g1test1" { vpc_id = "sg-273ycgql3ig3k7fap8t3dyvqx" } \ No newline at end of file diff --git a/example/securityGroupRule/main.tf b/example/securityGroupRule/main.tf index fcc6c8ef..740351ca 100644 --- a/example/securityGroupRule/main.tf +++ b/example/securityGroupRule/main.tf @@ -1,4 +1,4 @@ -resource "vestack_security_group_rule" "g1test3" { +resource "volcengine_security_group_rule" "g1test3" { direction = "egress" security_group_id = "sg-273ycgql3ig3k7fap8t3dyvqx" protocol = "tcp" diff --git a/example/serverGroup/main.tf b/example/serverGroup/main.tf index cbfdce0d..1f3e5a76 100644 --- a/example/serverGroup/main.tf +++ b/example/serverGroup/main.tf @@ -1,4 +1,4 @@ -resource "vestack_server_group" "foo" { +resource "volcengine_server_group" "foo" { load_balancer_id = "clb-273z7d4r8tvk07fap8tsniyfe" server_group_name = "demo-demo11" description = "hello demo11" diff --git a/example/serverGroupServer/main.tf b/example/serverGroupServer/main.tf index 554b461c..e5df88b1 100644 --- a/example/serverGroupServer/main.tf +++ b/example/serverGroupServer/main.tf @@ -1,4 +1,4 @@ -resource "vestack_server_group_server" "foo" { +resource "volcengine_server_group_server" "foo" { server_group_id = "rsp-273zn4ewlhkw07fap8tig9ujz" instance_id = "i-72q1zvko6i5lnawvg940" type = "ecs" diff --git a/example/snatEntry/main.tf b/example/snatEntry/main.tf index dc27282d..b82d1f1d 100644 --- a/example/snatEntry/main.tf +++ b/example/snatEntry/main.tf @@ -1,4 +1,4 @@ -resource "vestack_snat_entry" "foo" { +resource "volcengine_snat_entry" "foo" { nat_gateway_id = "ngw-2743w1f6iqby87fap8tvm9kop" subnet_id = "subnet-2744i7u9alnnk7fap8tkq8aft" eip_id = "eip-274zlae117nr47fap8tzl24v4" diff --git a/example/subnet/main.tf b/example/subnet/main.tf index 1cbbbbf6..cf92d372 100644 --- a/example/subnet/main.tf +++ b/example/subnet/main.tf @@ -1,4 +1,4 @@ -resource "vestack_subnet" "foo" { +resource "volcengine_subnet" "foo" { subnet_name = "subnet-test-2" cidr_block = "192.168.1.0/24" zone_id = "cn-beijing" diff --git a/example/tosBucket/main.tf b/example/tosBucket/main.tf index 77a557a0..06b74e0f 100644 --- a/example/tosBucket/main.tf +++ b/example/tosBucket/main.tf @@ -1,4 +1,4 @@ -resource "vestack_tos_bucket" "default" { +resource "volcengine_tos_bucket" "default" { bucket_name = "test-xym-1" # storage_class ="IA" public_acl = "private" diff --git a/example/tosObject/main.tf b/example/tosObject/main.tf index dbb6fdea..0015110b 100644 --- a/example/tosObject/main.tf +++ b/example/tosObject/main.tf @@ -1,4 +1,4 @@ -resource "vestack_tos_object" "default" { +resource "volcengine_tos_object" "default" { bucket_name = "test-xym-1" object_name = "demo_xym" file_path = "/Users/bytedance/Work/Go/build/test.txt" diff --git a/example/volume/main.tf b/example/volume/main.tf index b3f7c127..c3822862 100644 --- a/example/volume/main.tf +++ b/example/volume/main.tf @@ -1,4 +1,4 @@ -resource "vestack_volume" "foo" { +resource "volcengine_volume" "foo" { volume_name = "terraform-test" zone_id = "cn-lingqiu-a" volume_type = "PTSSD" diff --git a/example/volumeAttach/main.tf b/example/volumeAttach/main.tf index ea821d62..6a571bbd 100644 --- a/example/volumeAttach/main.tf +++ b/example/volumeAttach/main.tf @@ -1,4 +1,4 @@ -resource "vestack_volume_attach" "foo" { +resource "volcengine_volume_attach" "foo" { volume_id = "vol-3tzl52wubz3b9fciw7ev" instance_id = "i-4ay59ww7dq8dt9c29hd4" } \ No newline at end of file diff --git a/example/vpc/main.tf b/example/vpc/main.tf index 9e7a5fb5..35282f2b 100644 --- a/example/vpc/main.tf +++ b/example/vpc/main.tf @@ -1,4 +1,4 @@ -resource "vestack_vpc" "foo" { +resource "volcengine_vpc" "foo" { vpc_name = "tf-test-2" cidr_block = "172.16.0.0/16" dns_servers = ["8.8.8.8","114.114.114.114"] diff --git a/go.mod b/go.mod index ded0711f..94861c80 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/volcengine/terraform-provider-vestack +module github.com/volcengine/terraform-provider-volcengine go 1.12 @@ -8,6 +8,6 @@ require ( github.com/hashicorp/hcl/v2 v2.0.0 github.com/hashicorp/terraform-plugin-sdk v1.7.0 github.com/stretchr/testify v1.7.0 - github.com/volcengine/volcstack-go-sdk v1.0.3 + github.com/volcengine/volcengine-go-sdk v1.0.3 golang.org/x/sync v0.0.0-20190423024810-112230192c58 ) diff --git a/main.go b/main.go index c4cbb536..cb7369f0 100644 --- a/main.go +++ b/main.go @@ -2,11 +2,11 @@ package main import ( "github.com/hashicorp/terraform-plugin-sdk/plugin" - "github.com/volcengine/terraform-provider-vestack/vestack" + "github.com/volcengine/terraform-provider-volcengine/volcengine" ) func main() { plugin.Serve(&plugin.ServeOpts{ - ProviderFunc: vestack.Provider, + ProviderFunc: volcengine.Provider, }) } diff --git a/vestack/provider.go b/vestack/provider.go deleted file mode 100644 index fe666451..00000000 --- a/vestack/provider.go +++ /dev/null @@ -1,169 +0,0 @@ -package vestack - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/terraform" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/vestack/clb/acl" - "github.com/volcengine/terraform-provider-vestack/vestack/clb/acl_entry" - "github.com/volcengine/terraform-provider-vestack/vestack/clb/certificate" - "github.com/volcengine/terraform-provider-vestack/vestack/clb/clb" - "github.com/volcengine/terraform-provider-vestack/vestack/clb/listener" - "github.com/volcengine/terraform-provider-vestack/vestack/clb/rule" - "github.com/volcengine/terraform-provider-vestack/vestack/clb/server_group" - "github.com/volcengine/terraform-provider-vestack/vestack/clb/server_group_server" - "github.com/volcengine/terraform-provider-vestack/vestack/ebs/volume" - "github.com/volcengine/terraform-provider-vestack/vestack/ebs/volume_attach" - "github.com/volcengine/terraform-provider-vestack/vestack/ecs/ecs_instance" - "github.com/volcengine/terraform-provider-vestack/vestack/ecs/ecs_instance_state" - "github.com/volcengine/terraform-provider-vestack/vestack/ecs/image" - "github.com/volcengine/terraform-provider-vestack/vestack/ecs/zone" - "github.com/volcengine/terraform-provider-vestack/vestack/eip/eip_address" - "github.com/volcengine/terraform-provider-vestack/vestack/eip/eip_associate" - "github.com/volcengine/terraform-provider-vestack/vestack/nat/nat_gateway" - "github.com/volcengine/terraform-provider-vestack/vestack/nat/snat_entry" - "github.com/volcengine/terraform-provider-vestack/vestack/tos/bucket" - "github.com/volcengine/terraform-provider-vestack/vestack/tos/object" - "github.com/volcengine/terraform-provider-vestack/vestack/vpc/network_interface" - "github.com/volcengine/terraform-provider-vestack/vestack/vpc/network_interface_attach" - "github.com/volcengine/terraform-provider-vestack/vestack/vpc/route_entry" - "github.com/volcengine/terraform-provider-vestack/vestack/vpc/route_table" - "github.com/volcengine/terraform-provider-vestack/vestack/vpc/route_table_associate" - "github.com/volcengine/terraform-provider-vestack/vestack/vpc/security_group" - "github.com/volcengine/terraform-provider-vestack/vestack/vpc/security_group_rule" - "github.com/volcengine/terraform-provider-vestack/vestack/vpc/subnet" - "github.com/volcengine/terraform-provider-vestack/vestack/vpc/vpc" -) - -func Provider() terraform.ResourceProvider { - return &schema.Provider{ - Schema: map[string]*schema.Schema{ - "access_key": { - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("VESTACK_ACCESS_KEY", nil), - Description: "The Access Key for Vestack Provider", - }, - "secret_key": { - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("VESTACK_SECRET_KEY", nil), - Description: "The Secret Key for Vestack Provider", - }, - "session_token": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("VESTACK_SESSION_TOKEN", nil), - Description: "The Session Token for Vestack Provider", - }, - "region": { - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("VESTACK_REGION", nil), - Description: "The Region for Vestack Provider", - }, - "endpoint": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("VESTACK_ENDPOINT", nil), - Description: "The Customer Endpoint for Vestack Provider", - }, - "disable_ssl": { - Type: schema.TypeBool, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("vestack_DISABLE_SSL", nil), - Description: "Disable SSL for Vestack Provider", - }, - }, - DataSourcesMap: map[string]*schema.Resource{ - "vestack_vpcs": vpc.DataSourceVestackVpcs(), - "vestack_subnets": subnet.DataSourceVestackSubnets(), - "vestack_route_tables": route_table.DataSourceVestackRouteTables(), - "vestack_route_entries": route_entry.DataSourceVestackRouteEntries(), - "vestack_security_groups": security_group.DataSourceVestackSecurityGroups(), - "vestack_network_interfaces": network_interface.DataSourceVestackNetworkInterfaces(), - - // ================ EIP ================ - "vestack_eip_addresses": eip_address.DataSourceVestackEipAddresses(), - - // ================ CLB ================ - "vestack_acls": acl.DataSourceVestackAcls(), - "vestack_clbs": clb.DataSourceVestackClbs(), - "vestack_listeners": listener.DataSourceVestackListeners(), - "vestack_server_groups": server_group.DataSourceVestackServerGroups(), - "vestack_certificates": certificate.DataSourceVestackCertificates(), - "vestack_clb_rules": rule.DataSourceVestackRules(), - "vestack_server_group_servers": server_group_server.DataSourceVestackServerGroupServers(), - - // ================ EBS ================ - "vestack_volumes": volume.DataSourceVestackVolumes(), - - // ================ ECS ================ - "vestack_ecs_instances": ecs_instance.DataSourceVestackEcsInstances(), - "vestack_images": image.DataSourceVestackImages(), - "vestack_zones": zone.DataSourceVestackZones(), - - // ================ NAT ================ - "vestack_snat_entries": snat_entry.DataSourceVestackSnatEntries(), - "vestack_nat_gateways": nat_gateway.DataSourceVestackNatGateways(), - - // ================ TOS ================ - "vestack_tos_buckets": bucket.DataSourceVestackTosBuckets(), - }, - ResourcesMap: map[string]*schema.Resource{ - "vestack_vpc": vpc.ResourceVestackVpc(), - "vestack_subnet": subnet.ResourceVestackSubnet(), - "vestack_route_table": route_table.ResourceVestackRouteTable(), - "vestack_route_entry": route_entry.ResourceVestackRouteEntry(), - "vestack_route_table_associate": route_table_associate.ResourceVestackRouteTableAssociate(), - "vestack_security_group": security_group.ResourceVestackSecurityGroup(), - "vestack_network_interface": network_interface.ResourceVestackNetworkInterface(), - "vestack_network_interface_attach": network_interface_attach.ResourceVestackNetworkInterfaceAttach(), - "vestack_security_group_rule": security_group_rule.ResourceVestackSecurityGroupRule(), - - // ================ EIP ================ - "vestack_eip_address": eip_address.ResourceVestackEipAddress(), - "vestack_eip_associate": eip_associate.ResourceVestackEipAssociate(), - - // ================ CLB ================ - "vestack_acl": acl.ResourceVestackAcl(), - "vestack_clb": clb.ResourceVestackClb(), - "vestack_listener": listener.ResourceVestackListener(), - "vestack_server_group": server_group.ResourceVestackServerGroup(), - "vestack_certificate": certificate.ResourceVestackCertificate(), - "vestack_clb_rule": rule.ResourceVestackRule(), - "vestack_server_group_server": server_group_server.ResourceVestackServerGroupServer(), - "vestack_acl_entry": acl_entry.ResourceVestackAclEntry(), - - // ================ EBS ================ - "vestack_volume": volume.ResourceVestackVolume(), - "vestack_volume_attach": volume_attach.ResourceVestackVolumeAttach(), - - // ================ ECS ================ - "vestack_ecs_instance": ecs_instance.ResourceVestackEcsInstance(), - "vestack_ecs_instance_state": ecs_instance_state.ResourceVestackEcsInstanceState(), - - // ================ NAT ================ - "vestack_snat_entry": snat_entry.ResourceVestackSnatEntry(), - "vestack_nat_gateway": nat_gateway.ResourceVestackNatGateway(), - - //================= TOS ================= - "vestack_tos_bucket": bucket.ResourceVestackTosBucket(), - "vestack_tos_object": object.ResourceVestackTosObject(), - }, - ConfigureFunc: ProviderConfigure, - } -} - -func ProviderConfigure(d *schema.ResourceData) (interface{}, error) { - config := ve.Config{ - AccessKey: d.Get("access_key").(string), - SecretKey: d.Get("secret_key").(string), - SessionToken: d.Get("session_token").(string), - Region: d.Get("region").(string), - Endpoint: d.Get("endpoint").(string), - DisableSSL: d.Get("disable_ssl").(bool), - } - client, err := config.Client() - return client, err -} diff --git a/vestack/clb/acl/data_source_vestack_acls.go b/volcengine/clb/acl/data_source_volcengine_acls.go similarity index 88% rename from vestack/clb/acl/data_source_vestack_acls.go rename to volcengine/clb/acl/data_source_volcengine_acls.go index e579252d..21d776ac 100644 --- a/vestack/clb/acl/data_source_vestack_acls.go +++ b/volcengine/clb/acl/data_source_volcengine_acls.go @@ -3,12 +3,12 @@ package acl import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackAcls() *schema.Resource { +func DataSourceVolcengineAcls() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackAclsRead, + Read: dataSourceVolcengineAclsRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -97,7 +97,7 @@ func DataSourceVestackAcls() *schema.Resource { } } -func dataSourceVestackAclsRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineAclsRead(d *schema.ResourceData, meta interface{}) error { aclService := NewAclService(meta.(*ve.SdkClient)) - return aclService.Dispatcher.Data(aclService, d, DataSourceVestackAcls()) + return aclService.Dispatcher.Data(aclService, d, DataSourceVolcengineAcls()) } diff --git a/vestack/clb/acl/resource_vestack_acl.go b/volcengine/clb/acl/resource_volcengine_acl.go similarity index 57% rename from vestack/clb/acl/resource_vestack_acl.go rename to volcengine/clb/acl/resource_volcengine_acl.go index bf2248ce..f8ef2836 100644 --- a/vestack/clb/acl/resource_vestack_acl.go +++ b/volcengine/clb/acl/resource_volcengine_acl.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/vestack/clb/acl_entry" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/acl_entry" ) /* @@ -13,13 +13,13 @@ import ( Import Acl can be imported using the id, e.g. ``` -$ terraform import vestack_acl.default acl-mizl7m1kqccg5smt1bdpijuj +$ terraform import volcengine_acl.default acl-mizl7m1kqccg5smt1bdpijuj ``` */ -func ResourceVestackAcl() *schema.Resource { - entry := acl_entry.ResourceVestackAclEntry().Schema +func ResourceVolcengineAcl() *schema.Resource { + entry := acl_entry.ResourceVolcengineAclEntry().Schema for k, v := range entry { if k == "acl_id" { delete(entry, k) @@ -29,10 +29,10 @@ func ResourceVestackAcl() *schema.Resource { } return &schema.Resource{ - Create: resourceVestackAclCreate, - Read: resourceVestackAclRead, - Update: resourceVestackAclUpdate, - Delete: resourceVestackAclDelete, + Create: resourceVolcengineAclCreate, + Read: resourceVolcengineAclRead, + Update: resourceVolcengineAclUpdate, + Delete: resourceVolcengineAclDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -66,36 +66,36 @@ func ResourceVestackAcl() *schema.Resource { } } -func resourceVestackAclCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineAclCreate(d *schema.ResourceData, meta interface{}) (err error) { aclService := NewAclService(meta.(*ve.SdkClient)) - err = aclService.Dispatcher.Create(aclService, d, ResourceVestackAcl()) + err = aclService.Dispatcher.Create(aclService, d, ResourceVolcengineAcl()) if err != nil { return fmt.Errorf("error on creating acl %q, %w", d.Id(), err) } - return resourceVestackAclRead(d, meta) + return resourceVolcengineAclRead(d, meta) } -func resourceVestackAclRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineAclRead(d *schema.ResourceData, meta interface{}) (err error) { aclService := NewAclService(meta.(*ve.SdkClient)) - err = aclService.Dispatcher.Read(aclService, d, ResourceVestackAcl()) + err = aclService.Dispatcher.Read(aclService, d, ResourceVolcengineAcl()) if err != nil { return fmt.Errorf("error on reading acl %q, %w", d.Id(), err) } return err } -func resourceVestackAclUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineAclUpdate(d *schema.ResourceData, meta interface{}) (err error) { aclService := NewAclService(meta.(*ve.SdkClient)) - err = aclService.Dispatcher.Update(aclService, d, ResourceVestackAcl()) + err = aclService.Dispatcher.Update(aclService, d, ResourceVolcengineAcl()) if err != nil { return fmt.Errorf("error on updating acl %q, %w", d.Id(), err) } - return resourceVestackAclRead(d, meta) + return resourceVolcengineAclRead(d, meta) } -func resourceVestackAclDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineAclDelete(d *schema.ResourceData, meta interface{}) (err error) { aclService := NewAclService(meta.(*ve.SdkClient)) - err = aclService.Dispatcher.Delete(aclService, d, ResourceVestackAcl()) + err = aclService.Dispatcher.Delete(aclService, d, ResourceVolcengineAcl()) if err != nil { return fmt.Errorf("error on deleting acl %q, %w", d.Id(), err) } diff --git a/vestack/clb/acl/service_vestack_acl.go b/volcengine/clb/acl/service_volcengine_acl.go similarity index 86% rename from vestack/clb/acl/service_vestack_acl.go rename to volcengine/clb/acl/service_volcengine_acl.go index 1598643b..36052322 100644 --- a/vestack/clb/acl/service_vestack_acl.go +++ b/volcengine/clb/acl/service_volcengine_acl.go @@ -8,27 +8,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackAclService struct { +type VolcengineAclService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewAclService(c *ve.SdkClient) *VestackAclService { - return &VestackAclService{ +func NewAclService(c *ve.SdkClient) *VolcengineAclService { + return &VolcengineAclService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackAclService) GetClient() *ve.SdkClient { +func (s *VolcengineAclService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackAclService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineAclService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -61,7 +61,7 @@ func (s *VestackAclService) ReadResources(condition map[string]interface{}) (dat }) } -func (s *VestackAclService) ReadResource(resourceData *schema.ResourceData, aclId string) (data map[string]interface{}, err error) { +func (s *VolcengineAclService) ReadResource(resourceData *schema.ResourceData, aclId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -104,7 +104,7 @@ func (s *VestackAclService) ReadResource(resourceData *schema.ResourceData, aclI return data, err } -func (s *VestackAclService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineAclService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -116,7 +116,7 @@ func (s *VestackAclService) RefreshResourceState(resourceData *schema.ResourceDa } -func (VestackAclService) WithResourceResponseHandlers(acl map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineAclService) WithResourceResponseHandlers(acl map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return acl, nil, nil } @@ -124,7 +124,7 @@ func (VestackAclService) WithResourceResponseHandlers(acl map[string]interface{} } -func (s *VestackAclService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineAclService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { var callbacks []ve.Callback callback := ve.Callback{ @@ -178,7 +178,7 @@ func (s *VestackAclService) CreateResource(resourceData *schema.ResourceData, re } -func (s *VestackAclService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineAclService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { var callbacks []ve.Callback callback := ve.Callback{ @@ -258,7 +258,7 @@ func (s *VestackAclService) ModifyResource(resourceData *schema.ResourceData, re return callbacks } -func (s *VestackAclService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineAclService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "DeleteAcl", @@ -293,7 +293,7 @@ func (s *VestackAclService) RemoveResource(resourceData *schema.ResourceData, r return []ve.Callback{callback} } -func (s *VestackAclService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineAclService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -313,6 +313,6 @@ func (s *VestackAclService) DatasourceResources(*schema.ResourceData, *schema.Re } } -func (s *VestackAclService) ReadResourceId(id string) string { +func (s *VolcengineAclService) ReadResourceId(id string) string { return id } diff --git a/vestack/clb/acl_entry/common_vestack_acl_entry.go b/volcengine/clb/acl_entry/common_volcengine_acl_entry.go similarity index 100% rename from vestack/clb/acl_entry/common_vestack_acl_entry.go rename to volcengine/clb/acl_entry/common_volcengine_acl_entry.go diff --git a/vestack/clb/acl_entry/resource_vestack_acl_entry.go b/volcengine/clb/acl_entry/resource_volcengine_acl_entry.go similarity index 65% rename from vestack/clb/acl_entry/resource_vestack_acl_entry.go rename to volcengine/clb/acl_entry/resource_volcengine_acl_entry.go index 5fed3fe4..3f455471 100644 --- a/vestack/clb/acl_entry/resource_vestack_acl_entry.go +++ b/volcengine/clb/acl_entry/resource_volcengine_acl_entry.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -12,16 +12,16 @@ import ( Import AclEntry can be imported using the id, e.g. ``` -$ terraform import vestack_acl_entry.default ID is a string concatenated with colons(AclId:Entry) +$ terraform import volcengine_acl_entry.default ID is a string concatenated with colons(AclId:Entry) ``` */ -func ResourceVestackAclEntry() *schema.Resource { +func ResourceVolcengineAclEntry() *schema.Resource { return &schema.Resource{ - Create: resourceVestackAclEntryCreate, - Read: resourceVestackAclEntryRead, - Delete: resourceVestackAclEntryDelete, + Create: resourceVolcengineAclEntryCreate, + Read: resourceVolcengineAclEntryRead, + Delete: resourceVolcengineAclEntryDelete, Importer: &schema.ResourceImporter{ State: aclEntryImporter, }, @@ -48,27 +48,27 @@ func ResourceVestackAclEntry() *schema.Resource { } } -func resourceVestackAclEntryCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineAclEntryCreate(d *schema.ResourceData, meta interface{}) (err error) { aclEntryService := NewAclEntryService(meta.(*ve.SdkClient)) - err = aclEntryService.Dispatcher.Create(aclEntryService, d, ResourceVestackAclEntry()) + err = aclEntryService.Dispatcher.Create(aclEntryService, d, ResourceVolcengineAclEntry()) if err != nil { return fmt.Errorf("error on creating acl entry %q, %w", d.Id(), err) } - return resourceVestackAclEntryRead(d, meta) + return resourceVolcengineAclEntryRead(d, meta) } -func resourceVestackAclEntryRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineAclEntryRead(d *schema.ResourceData, meta interface{}) (err error) { aclEntryService := NewAclEntryService(meta.(*ve.SdkClient)) - err = aclEntryService.Dispatcher.Read(aclEntryService, d, ResourceVestackAclEntry()) + err = aclEntryService.Dispatcher.Read(aclEntryService, d, ResourceVolcengineAclEntry()) if err != nil { return fmt.Errorf("error on reading acl entry %q, %w", d.Id(), err) } return err } -func resourceVestackAclEntryDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineAclEntryDelete(d *schema.ResourceData, meta interface{}) (err error) { aclEntryService := NewAclEntryService(meta.(*ve.SdkClient)) - err = aclEntryService.Dispatcher.Delete(aclEntryService, d, ResourceVestackAclEntry()) + err = aclEntryService.Dispatcher.Delete(aclEntryService, d, ResourceVolcengineAclEntry()) if err != nil { return fmt.Errorf("error on deleting acl entry %q, %w", d.Id(), err) } diff --git a/vestack/clb/acl_entry/service_vestack_acl_entry.go b/volcengine/clb/acl_entry/service_volcengine_acl_entry.go similarity index 78% rename from vestack/clb/acl_entry/service_vestack_acl_entry.go rename to volcengine/clb/acl_entry/service_volcengine_acl_entry.go index 31aaddbe..fc8da80c 100644 --- a/vestack/clb/acl_entry/service_vestack_acl_entry.go +++ b/volcengine/clb/acl_entry/service_volcengine_acl_entry.go @@ -9,27 +9,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackAclEntryService struct { +type VolcengineAclEntryService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewAclEntryService(c *ve.SdkClient) *VestackAclEntryService { - return &VestackAclEntryService{ +func NewAclEntryService(c *ve.SdkClient) *VolcengineAclEntryService { + return &VolcengineAclEntryService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackAclEntryService) GetClient() *ve.SdkClient { +func (s *VolcengineAclEntryService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackAclEntryService) ReadResources(condition map[string]interface{}) ([]interface{}, error) { +func (s *VolcengineAclEntryService) ReadResources(condition map[string]interface{}) ([]interface{}, error) { var ( aclEntryIdMap = make(map[string]bool) res = make([]interface{}, 0) @@ -95,7 +95,7 @@ func (s *VestackAclEntryService) ReadResources(condition map[string]interface{}) return res, nil } -func (s *VestackAclEntryService) ReadResource(resourceData *schema.ResourceData, tmpId string) (map[string]interface{}, error) { +func (s *VolcengineAclEntryService) ReadResource(resourceData *schema.ResourceData, tmpId string) (map[string]interface{}, error) { if tmpId == "" { tmpId = resourceData.Id() } @@ -130,11 +130,11 @@ func (s *VestackAclEntryService) ReadResource(resourceData *schema.ResourceData, return aclEntries[0].(map[string]interface{}), err } -func (s *VestackAclEntryService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineAclEntryService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return nil } -func (VestackAclEntryService) WithResourceResponseHandlers(aclEntry map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineAclEntryService) WithResourceResponseHandlers(aclEntry map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return aclEntry, nil, nil } @@ -142,7 +142,7 @@ func (VestackAclEntryService) WithResourceResponseHandlers(aclEntry map[string]i } -func (s *VestackAclEntryService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineAclEntryService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "AddAclEntries", @@ -168,11 +168,11 @@ func (s *VestackAclEntryService) CreateResource(resourceData *schema.ResourceDat } -func (s *VestackAclEntryService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineAclEntryService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { return []ve.Callback{} } -func (s *VestackAclEntryService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineAclEntryService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "RemoveAclEntries", @@ -214,10 +214,10 @@ func (s *VestackAclEntryService) RemoveResource(resourceData *schema.ResourceDat return []ve.Callback{callback} } -func (s *VestackAclEntryService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineAclEntryService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{} } -func (s *VestackAclEntryService) ReadResourceId(id string) string { +func (s *VolcengineAclEntryService) ReadResourceId(id string) string { return id } diff --git a/vestack/clb/certificate/data_source_vestack_certificates.go b/volcengine/clb/certificate/data_source_volcengine_certificates.go similarity index 90% rename from vestack/clb/certificate/data_source_vestack_certificates.go rename to volcengine/clb/certificate/data_source_volcengine_certificates.go index c71dc58e..e221085f 100644 --- a/vestack/clb/certificate/data_source_vestack_certificates.go +++ b/volcengine/clb/certificate/data_source_volcengine_certificates.go @@ -3,12 +3,12 @@ package certificate import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackCertificates() *schema.Resource { +func DataSourceVolcengineCertificates() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackCertificatesRead, + Read: dataSourceVolcengineCertificatesRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -99,7 +99,7 @@ func DataSourceVestackCertificates() *schema.Resource { } } -func dataSourceVestackCertificatesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineCertificatesRead(d *schema.ResourceData, meta interface{}) error { certificateService := NewCertificateService(meta.(*ve.SdkClient)) - return certificateService.Dispatcher.Data(certificateService, d, DataSourceVestackCertificates()) + return certificateService.Dispatcher.Data(certificateService, d, DataSourceVolcengineCertificates()) } diff --git a/vestack/clb/certificate/resource_vestack_certificate.go b/volcengine/clb/certificate/resource_volcengine_certificate.go similarity index 66% rename from vestack/clb/certificate/resource_vestack_certificate.go rename to volcengine/clb/certificate/resource_volcengine_certificate.go index 9cd67a68..3bb4a6eb 100644 --- a/vestack/clb/certificate/resource_vestack_certificate.go +++ b/volcengine/clb/certificate/resource_volcengine_certificate.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -12,16 +12,16 @@ import ( Import Certificate can be imported using the id, e.g. ``` -$ terraform import vestack_certificate.default cert-2fe5k****c16o5oxruvtk3qf5 +$ terraform import volcengine_certificate.default cert-2fe5k****c16o5oxruvtk3qf5 ``` */ -func ResourceVestackCertificate() *schema.Resource { +func ResourceVolcengineCertificate() *schema.Resource { return &schema.Resource{ - Create: resourceVestackCertificateCreate, - Read: resourceVestackCertificateRead, - Delete: resourceVestackCertificateDelete, + Create: resourceVolcengineCertificateCreate, + Read: resourceVolcengineCertificateRead, + Delete: resourceVolcengineCertificateDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -54,36 +54,36 @@ func ResourceVestackCertificate() *schema.Resource { } } -func resourceVestackCertificateCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineCertificateCreate(d *schema.ResourceData, meta interface{}) (err error) { certificateService := NewCertificateService(meta.(*ve.SdkClient)) - err = certificateService.Dispatcher.Create(certificateService, d, ResourceVestackCertificate()) + err = certificateService.Dispatcher.Create(certificateService, d, ResourceVolcengineCertificate()) if err != nil { return fmt.Errorf("error on creating certificate %q, %w", d.Id(), err) } - return resourceVestackCertificateRead(d, meta) + return resourceVolcengineCertificateRead(d, meta) } -func resourceVestackCertificateRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineCertificateRead(d *schema.ResourceData, meta interface{}) (err error) { certificateService := NewCertificateService(meta.(*ve.SdkClient)) - err = certificateService.Dispatcher.Read(certificateService, d, ResourceVestackCertificate()) + err = certificateService.Dispatcher.Read(certificateService, d, ResourceVolcengineCertificate()) if err != nil { return fmt.Errorf("error on reading certificate %q, %w", d.Id(), err) } return err } -func resourceVestackCertificateUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineCertificateUpdate(d *schema.ResourceData, meta interface{}) (err error) { certificateService := NewCertificateService(meta.(*ve.SdkClient)) - err = certificateService.Dispatcher.Update(certificateService, d, ResourceVestackCertificate()) + err = certificateService.Dispatcher.Update(certificateService, d, ResourceVolcengineCertificate()) if err != nil { return fmt.Errorf("error on updating certificate %q, %w", d.Id(), err) } - return resourceVestackCertificateRead(d, meta) + return resourceVolcengineCertificateRead(d, meta) } -func resourceVestackCertificateDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineCertificateDelete(d *schema.ResourceData, meta interface{}) (err error) { certificateService := NewCertificateService(meta.(*ve.SdkClient)) - err = certificateService.Dispatcher.Delete(certificateService, d, ResourceVestackCertificate()) + err = certificateService.Dispatcher.Delete(certificateService, d, ResourceVolcengineCertificate()) if err != nil { return fmt.Errorf("error on deleting certificate %q, %w", d.Id(), err) } diff --git a/vestack/clb/certificate/service_vestack_certificate.go b/volcengine/clb/certificate/service_volcengine_certificate.go similarity index 73% rename from vestack/clb/certificate/service_vestack_certificate.go rename to volcengine/clb/certificate/service_volcengine_certificate.go index 6cebf9c2..ec87a969 100644 --- a/vestack/clb/certificate/service_vestack_certificate.go +++ b/volcengine/clb/certificate/service_volcengine_certificate.go @@ -7,27 +7,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackCertificateService struct { +type VolcengineCertificateService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewCertificateService(c *ve.SdkClient) *VestackCertificateService { - return &VestackCertificateService{ +func NewCertificateService(c *ve.SdkClient) *VolcengineCertificateService { + return &VolcengineCertificateService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackCertificateService) GetClient() *ve.SdkClient { +func (s *VolcengineCertificateService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackCertificateService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineCertificateService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -63,7 +63,7 @@ func (s *VestackCertificateService) ReadResources(condition map[string]interface }) } -func (s *VestackCertificateService) ReadResource(resourceData *schema.ResourceData, certificateId string) (data map[string]interface{}, err error) { +func (s *VolcengineCertificateService) ReadResource(resourceData *schema.ResourceData, certificateId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -89,11 +89,11 @@ func (s *VestackCertificateService) ReadResource(resourceData *schema.ResourceDa return data, err } -func (s *VestackCertificateService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineCertificateService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return nil } -func (VestackCertificateService) WithResourceResponseHandlers(certificate map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineCertificateService) WithResourceResponseHandlers(certificate map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return certificate, nil, nil } @@ -101,7 +101,7 @@ func (VestackCertificateService) WithResourceResponseHandlers(certificate map[st } -func (s *VestackCertificateService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineCertificateService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "UploadCertificate", @@ -123,11 +123,11 @@ func (s *VestackCertificateService) CreateResource(resourceData *schema.Resource } -func (s *VestackCertificateService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineCertificateService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { return []ve.Callback{} } -func (s *VestackCertificateService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineCertificateService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "DeleteCertificate", @@ -163,7 +163,7 @@ func (s *VestackCertificateService) RemoveResource(resourceData *schema.Resource return []ve.Callback{callback} } -func (s *VestackCertificateService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineCertificateService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -183,6 +183,6 @@ func (s *VestackCertificateService) DatasourceResources(*schema.ResourceData, *s } } -func (s *VestackCertificateService) ReadResourceId(id string) string { +func (s *VolcengineCertificateService) ReadResourceId(id string) string { return id } diff --git a/vestack/clb/clb/data_source_vestack_clbs.go b/volcengine/clb/clb/data_source_volcengine_clbs.go similarity index 93% rename from vestack/clb/clb/data_source_vestack_clbs.go rename to volcengine/clb/clb/data_source_volcengine_clbs.go index 9de36f15..4fc14804 100644 --- a/vestack/clb/clb/data_source_vestack_clbs.go +++ b/volcengine/clb/clb/data_source_volcengine_clbs.go @@ -3,12 +3,12 @@ package clb import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackClbs() *schema.Resource { +func DataSourceVolcengineClbs() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackClbsRead, + Read: dataSourceVolcengineClbsRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -175,7 +175,7 @@ func DataSourceVestackClbs() *schema.Resource { } } -func dataSourceVestackClbsRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineClbsRead(d *schema.ResourceData, meta interface{}) error { clbService := NewClbService(meta.(*ve.SdkClient)) - return clbService.Dispatcher.Data(clbService, d, DataSourceVestackClbs()) + return clbService.Dispatcher.Data(clbService, d, DataSourceVolcengineClbs()) } diff --git a/vestack/clb/clb/resource_vestack_clb.go b/volcengine/clb/clb/resource_volcengine_clb.go similarity index 77% rename from vestack/clb/clb/resource_vestack_clb.go rename to volcengine/clb/clb/resource_volcengine_clb.go index ad7f1aac..f7d45838 100644 --- a/vestack/clb/clb/resource_vestack_clb.go +++ b/volcengine/clb/clb/resource_volcengine_clb.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -13,17 +13,17 @@ import ( Import CLB can be imported using the id, e.g. ``` -$ terraform import vestack_clb.default clb-273y2ok6ets007fap8txvf6us +$ terraform import volcengine_clb.default clb-273y2ok6ets007fap8txvf6us ``` */ -func ResourceVestackClb() *schema.Resource { +func ResourceVolcengineClb() *schema.Resource { return &schema.Resource{ - Create: resourceVestackClbCreate, - Read: resourceVestackClbRead, - Update: resourceVestackClbUpdate, - Delete: resourceVestackClbDelete, + Create: resourceVolcengineClbCreate, + Read: resourceVolcengineClbRead, + Update: resourceVolcengineClbUpdate, + Delete: resourceVolcengineClbDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -117,36 +117,36 @@ func ResourceVestackClb() *schema.Resource { } } -func resourceVestackClbCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineClbCreate(d *schema.ResourceData, meta interface{}) (err error) { clbService := NewClbService(meta.(*ve.SdkClient)) - err = clbService.Dispatcher.Create(clbService, d, ResourceVestackClb()) + err = clbService.Dispatcher.Create(clbService, d, ResourceVolcengineClb()) if err != nil { return fmt.Errorf("error on creating clb %q, %w", d.Id(), err) } - return resourceVestackClbRead(d, meta) + return resourceVolcengineClbRead(d, meta) } -func resourceVestackClbRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineClbRead(d *schema.ResourceData, meta interface{}) (err error) { clbService := NewClbService(meta.(*ve.SdkClient)) - err = clbService.Dispatcher.Read(clbService, d, ResourceVestackClb()) + err = clbService.Dispatcher.Read(clbService, d, ResourceVolcengineClb()) if err != nil { return fmt.Errorf("error on reading clb %q, %w", d.Id(), err) } return err } -func resourceVestackClbUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineClbUpdate(d *schema.ResourceData, meta interface{}) (err error) { clbService := NewClbService(meta.(*ve.SdkClient)) - err = clbService.Dispatcher.Update(clbService, d, ResourceVestackClb()) + err = clbService.Dispatcher.Update(clbService, d, ResourceVolcengineClb()) if err != nil { return fmt.Errorf("error on updating clb %q, %w", d.Id(), err) } - return resourceVestackClbRead(d, meta) + return resourceVolcengineClbRead(d, meta) } -func resourceVestackClbDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineClbDelete(d *schema.ResourceData, meta interface{}) (err error) { clbService := NewClbService(meta.(*ve.SdkClient)) - err = clbService.Dispatcher.Delete(clbService, d, ResourceVestackClb()) + err = clbService.Dispatcher.Delete(clbService, d, ResourceVolcengineClb()) if err != nil { return fmt.Errorf("error on deleting clb %q, %w", d.Id(), err) } diff --git a/vestack/clb/clb/service_vestack_clb.go b/volcengine/clb/clb/service_volcengine_clb.go similarity index 84% rename from vestack/clb/clb/service_vestack_clb.go rename to volcengine/clb/clb/service_volcengine_clb.go index 2cd9237d..d0064cff 100644 --- a/vestack/clb/clb/service_vestack_clb.go +++ b/volcengine/clb/clb/service_volcengine_clb.go @@ -7,27 +7,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackClbService struct { +type VolcengineClbService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewClbService(c *ve.SdkClient) *VestackClbService { - return &VestackClbService{ +func NewClbService(c *ve.SdkClient) *VolcengineClbService { + return &VolcengineClbService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackClbService) GetClient() *ve.SdkClient { +func (s *VolcengineClbService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackClbService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineClbService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -63,7 +63,7 @@ func (s *VestackClbService) ReadResources(condition map[string]interface{}) (dat }) } -func (s *VestackClbService) ReadResource(resourceData *schema.ResourceData, clbId string) (data map[string]interface{}, err error) { +func (s *VolcengineClbService) ReadResource(resourceData *schema.ResourceData, clbId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -89,7 +89,7 @@ func (s *VestackClbService) ReadResource(resourceData *schema.ResourceData, clbI return data, err } -func (s *VestackClbService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineClbService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -123,7 +123,7 @@ func (s *VestackClbService) RefreshResourceState(resourceData *schema.ResourceDa } -func (VestackClbService) WithResourceResponseHandlers(clb map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineClbService) WithResourceResponseHandlers(clb map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return clb, map[string]ve.ResponseConvert{ "LoadBalancerBillingType": { @@ -148,7 +148,7 @@ func (VestackClbService) WithResourceResponseHandlers(clb map[string]interface{} } -func (s *VestackClbService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineClbService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "CreateLoadBalancer", @@ -192,7 +192,7 @@ func (s *VestackClbService) CreateResource(resourceData *schema.ResourceData, re } -func (s *VestackClbService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineClbService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifyLoadBalancerAttributes", @@ -233,7 +233,7 @@ func (s *VestackClbService) ModifyResource(resourceData *schema.ResourceData, re return []ve.Callback{callback} } -func (s *VestackClbService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineClbService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "DeleteLoadBalancer", @@ -269,7 +269,7 @@ func (s *VestackClbService) RemoveResource(resourceData *schema.ResourceData, r return []ve.Callback{callback} } -func (s *VestackClbService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineClbService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -311,6 +311,6 @@ func (s *VestackClbService) DatasourceResources(*schema.ResourceData, *schema.Re } } -func (s *VestackClbService) ReadResourceId(id string) string { +func (s *VolcengineClbService) ReadResourceId(id string) string { return id } diff --git a/vestack/clb/listener/common_vestack_listener.go b/volcengine/clb/listener/common_volcengine_listener.go similarity index 100% rename from vestack/clb/listener/common_vestack_listener.go rename to volcengine/clb/listener/common_volcengine_listener.go diff --git a/vestack/clb/listener/data_source_vestack_listeners.go b/volcengine/clb/listener/data_source_volcengine_listeners.go similarity index 94% rename from vestack/clb/listener/data_source_vestack_listeners.go rename to volcengine/clb/listener/data_source_volcengine_listeners.go index 02dd5521..04b8659c 100644 --- a/vestack/clb/listener/data_source_vestack_listeners.go +++ b/volcengine/clb/listener/data_source_volcengine_listeners.go @@ -3,12 +3,12 @@ package listener import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackListeners() *schema.Resource { +func DataSourceVolcengineListeners() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackListenersRead, + Read: dataSourceVolcengineListenersRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -179,7 +179,7 @@ func DataSourceVestackListeners() *schema.Resource { } } -func dataSourceVestackListenersRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineListenersRead(d *schema.ResourceData, meta interface{}) error { listenerService := NewListenerService(meta.(*ve.SdkClient)) - return listenerService.Dispatcher.Data(listenerService, d, DataSourceVestackListeners()) + return listenerService.Dispatcher.Data(listenerService, d, DataSourceVolcengineListeners()) } diff --git a/vestack/clb/listener/resource_vestack_listener.go b/volcengine/clb/listener/resource_volcengine_listener.go similarity index 87% rename from vestack/clb/listener/resource_vestack_listener.go rename to volcengine/clb/listener/resource_volcengine_listener.go index 44163358..1ac4fe95 100644 --- a/vestack/clb/listener/resource_vestack_listener.go +++ b/volcengine/clb/listener/resource_volcengine_listener.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -13,17 +13,17 @@ import ( Import Listener can be imported using the id, e.g. ``` -$ terraform import vestack_listener.default lsn-273yv0mhs5xj47fap8sehiiso +$ terraform import volcengine_listener.default lsn-273yv0mhs5xj47fap8sehiiso ``` */ -func ResourceVestackListener() *schema.Resource { +func ResourceVolcengineListener() *schema.Resource { return &schema.Resource{ - Create: resourceVestackListenerCreate, - Read: resourceVestackListenerRead, - Update: resourceVestackListenerUpdate, - Delete: resourceVestackListenerDelete, + Create: resourceVolcengineListenerCreate, + Read: resourceVolcengineListenerRead, + Update: resourceVolcengineListenerUpdate, + Delete: resourceVolcengineListenerDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -191,36 +191,36 @@ func ResourceVestackListener() *schema.Resource { } } -func resourceVestackListenerCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineListenerCreate(d *schema.ResourceData, meta interface{}) (err error) { listenerService := NewListenerService(meta.(*ve.SdkClient)) - err = listenerService.Dispatcher.Create(listenerService, d, ResourceVestackListener()) + err = listenerService.Dispatcher.Create(listenerService, d, ResourceVolcengineListener()) if err != nil { return fmt.Errorf("error on creating listener %q, %w", d.Id(), err) } - return resourceVestackListenerRead(d, meta) + return resourceVolcengineListenerRead(d, meta) } -func resourceVestackListenerRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineListenerRead(d *schema.ResourceData, meta interface{}) (err error) { listenerService := NewListenerService(meta.(*ve.SdkClient)) - err = listenerService.Dispatcher.Read(listenerService, d, ResourceVestackListener()) + err = listenerService.Dispatcher.Read(listenerService, d, ResourceVolcengineListener()) if err != nil { return fmt.Errorf("error on reading listener %q, %w", d.Id(), err) } return err } -func resourceVestackListenerUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineListenerUpdate(d *schema.ResourceData, meta interface{}) (err error) { listenerService := NewListenerService(meta.(*ve.SdkClient)) - err = listenerService.Dispatcher.Update(listenerService, d, ResourceVestackListener()) + err = listenerService.Dispatcher.Update(listenerService, d, ResourceVolcengineListener()) if err != nil { return fmt.Errorf("error on updating listener %q, %w", d.Id(), err) } - return resourceVestackListenerRead(d, meta) + return resourceVolcengineListenerRead(d, meta) } -func resourceVestackListenerDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineListenerDelete(d *schema.ResourceData, meta interface{}) (err error) { listenerService := NewListenerService(meta.(*ve.SdkClient)) - err = listenerService.Dispatcher.Delete(listenerService, d, ResourceVestackListener()) + err = listenerService.Dispatcher.Delete(listenerService, d, ResourceVolcengineListener()) if err != nil { return fmt.Errorf("error on deleting listener %q, %w", d.Id(), err) } diff --git a/vestack/clb/listener/service_vestack_listener.go b/volcengine/clb/listener/service_volcengine_listener.go similarity index 85% rename from vestack/clb/listener/service_vestack_listener.go rename to volcengine/clb/listener/service_volcengine_listener.go index c2115e2e..b6c97a07 100644 --- a/vestack/clb/listener/service_vestack_listener.go +++ b/volcengine/clb/listener/service_volcengine_listener.go @@ -7,28 +7,28 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" - "github.com/volcengine/terraform-provider-vestack/vestack/clb/clb" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" + "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/clb" ) -type VestackListenerService struct { +type VolcengineListenerService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewListenerService(c *ve.SdkClient) *VestackListenerService { - return &VestackListenerService{ +func NewListenerService(c *ve.SdkClient) *VolcengineListenerService { + return &VolcengineListenerService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackListenerService) GetClient() *ve.SdkClient { +func (s *VolcengineListenerService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackListenerService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineListenerService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -64,7 +64,7 @@ func (s *VestackListenerService) ReadResources(condition map[string]interface{}) }) } -func (s *VestackListenerService) ReadResource(resourceData *schema.ResourceData, listenerId string) (data map[string]interface{}, err error) { +func (s *VolcengineListenerService) ReadResource(resourceData *schema.ResourceData, listenerId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -120,7 +120,7 @@ func (s *VestackListenerService) ReadResource(resourceData *schema.ResourceData, return data, err } -func (s *VestackListenerService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineListenerService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -147,7 +147,7 @@ func (s *VestackListenerService) RefreshResourceState(resourceData *schema.Resou } -func (VestackListenerService) WithResourceResponseHandlers(listener map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineListenerService) WithResourceResponseHandlers(listener map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return listener, nil, nil } @@ -155,7 +155,7 @@ func (VestackListenerService) WithResourceResponseHandlers(listener map[string]i } -func (s *VestackListenerService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineListenerService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "CreateListener", @@ -199,7 +199,7 @@ func (s *VestackListenerService) CreateResource(resourceData *schema.ResourceDat } -func (s *VestackListenerService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineListenerService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { clbId, err := s.queryLoadBalancerId(resourceData.Id()) if err != nil { return []ve.Callback{{ @@ -261,7 +261,7 @@ func (s *VestackListenerService) ModifyResource(resourceData *schema.ResourceDat return []ve.Callback{callback} } -func (s *VestackListenerService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineListenerService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { clbId, err := s.queryLoadBalancerId(resourceData.Id()) if err != nil { return []ve.Callback{{ @@ -314,7 +314,7 @@ func (s *VestackListenerService) RemoveResource(resourceData *schema.ResourceDat return []ve.Callback{callback} } -func (s *VestackListenerService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineListenerService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -361,11 +361,11 @@ func (s *VestackListenerService) DatasourceResources(*schema.ResourceData, *sche } } -func (s *VestackListenerService) ReadResourceId(id string) string { +func (s *VolcengineListenerService) ReadResourceId(id string) string { return id } -func (s *VestackListenerService) queryLoadBalancerId(listenerId string) (string, error) { +func (s *VolcengineListenerService) queryLoadBalancerId(listenerId string) (string, error) { if listenerId == "" { return "", fmt.Errorf("listener ID cannot be empty") } diff --git a/vestack/clb/rule/data_source_vestack_rules.go b/volcengine/clb/rule/data_source_volcengine_rules.go similarity index 84% rename from vestack/clb/rule/data_source_vestack_rules.go rename to volcengine/clb/rule/data_source_volcengine_rules.go index 7133c565..d5d12432 100644 --- a/vestack/clb/rule/data_source_vestack_rules.go +++ b/volcengine/clb/rule/data_source_volcengine_rules.go @@ -2,12 +2,12 @@ package rule import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackRules() *schema.Resource { +func DataSourceVolcengineRules() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackRulesRead, + Read: dataSourceVolcengineRulesRead, Schema: map[string]*schema.Schema{ "listener_id": { Type: schema.TypeString, @@ -71,7 +71,7 @@ func DataSourceVestackRules() *schema.Resource { } } -func dataSourceVestackRulesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineRulesRead(d *schema.ResourceData, meta interface{}) error { ruleService := NewRuleService(meta.(*ve.SdkClient)) - return ruleService.Dispatcher.Data(ruleService, d, DataSourceVestackRules()) + return ruleService.Dispatcher.Data(ruleService, d, DataSourceVolcengineRules()) } diff --git a/vestack/clb/rule/resource_vestack_rule.go b/volcengine/clb/rule/resource_volcengine_rule.go similarity index 68% rename from vestack/clb/rule/resource_vestack_rule.go rename to volcengine/clb/rule/resource_volcengine_rule.go index 5b4a404e..83ac5cc1 100644 --- a/vestack/clb/rule/resource_vestack_rule.go +++ b/volcengine/clb/rule/resource_volcengine_rule.go @@ -5,7 +5,7 @@ import ( "strings" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -15,7 +15,7 @@ Rule can be imported using the id, e.g. Notice: resourceId is ruleId, due to the lack of describeRuleAttributes in openapi, for import resources, please use ruleId:listenerId to import. we will fix this problem later. ``` -$ terraform import vestack_clb_rule.foo rule-273zb9hzi1gqo7fap8u1k3utb:lsn-273ywvnmiu70g7fap8u2xzg9d +$ terraform import volcengine_clb_rule.foo rule-273zb9hzi1gqo7fap8u1k3utb:lsn-273ywvnmiu70g7fap8u2xzg9d ``` */ @@ -29,12 +29,12 @@ func resourceParseId(id string) (string, string, error) { return parts[0], parts[1], nil } -func ResourceVestackRule() *schema.Resource { +func ResourceVolcengineRule() *schema.Resource { return &schema.Resource{ - Create: resourceVestackRuleCreate, - Read: resourceVestackRuleRead, - Update: resourceVestackRuleUpdate, - Delete: resourceVestackRuleDelete, + Create: resourceVolcengineRuleCreate, + Read: resourceVolcengineRuleRead, + Update: resourceVolcengineRuleUpdate, + Delete: resourceVolcengineRuleDelete, Importer: &schema.ResourceImporter{ State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { ruleId, listenerId, err := resourceParseId(d.Id()) @@ -83,36 +83,36 @@ func ResourceVestackRule() *schema.Resource { } } -func resourceVestackRuleCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineRuleCreate(d *schema.ResourceData, meta interface{}) (err error) { ruleService := NewRuleService(meta.(*ve.SdkClient)) - err = ruleService.Dispatcher.Create(ruleService, d, ResourceVestackRule()) + err = ruleService.Dispatcher.Create(ruleService, d, ResourceVolcengineRule()) if err != nil { return fmt.Errorf("error on creating rule %q, %w", d.Id(), err) } - return resourceVestackRuleRead(d, meta) + return resourceVolcengineRuleRead(d, meta) } -func resourceVestackRuleRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineRuleRead(d *schema.ResourceData, meta interface{}) (err error) { ruleService := NewRuleService(meta.(*ve.SdkClient)) - err = ruleService.Dispatcher.Read(ruleService, d, ResourceVestackRule()) + err = ruleService.Dispatcher.Read(ruleService, d, ResourceVolcengineRule()) if err != nil { return fmt.Errorf("error on reading rule %q, %w", d.Id(), err) } return err } -func resourceVestackRuleUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineRuleUpdate(d *schema.ResourceData, meta interface{}) (err error) { ruleService := NewRuleService(meta.(*ve.SdkClient)) - err = ruleService.Dispatcher.Update(ruleService, d, ResourceVestackRule()) + err = ruleService.Dispatcher.Update(ruleService, d, ResourceVolcengineRule()) if err != nil { return fmt.Errorf("error on updating rule %q, %w", d.Id(), err) } - return resourceVestackRuleRead(d, meta) + return resourceVolcengineRuleRead(d, meta) } -func resourceVestackRuleDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineRuleDelete(d *schema.ResourceData, meta interface{}) (err error) { ruleService := NewRuleService(meta.(*ve.SdkClient)) - err = ruleService.Dispatcher.Delete(ruleService, d, ResourceVestackRule()) + err = ruleService.Dispatcher.Delete(ruleService, d, ResourceVolcengineRule()) if err != nil { return fmt.Errorf("error on deleting rule %q, %w", d.Id(), err) } diff --git a/vestack/clb/rule/service_vestack_rule.go b/volcengine/clb/rule/service_volcengine_rule.go similarity index 83% rename from vestack/clb/rule/service_vestack_rule.go rename to volcengine/clb/rule/service_volcengine_rule.go index 8af5f06f..f87e7011 100644 --- a/vestack/clb/rule/service_vestack_rule.go +++ b/volcengine/clb/rule/service_volcengine_rule.go @@ -8,28 +8,28 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" - "github.com/volcengine/terraform-provider-vestack/vestack/clb/clb" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" + "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/clb" ) -type VestackRuleService struct { +type VolcengineRuleService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewRuleService(c *ve.SdkClient) *VestackRuleService { - return &VestackRuleService{ +func NewRuleService(c *ve.SdkClient) *VolcengineRuleService { + return &VolcengineRuleService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackRuleService) GetClient() *ve.SdkClient { +func (s *VolcengineRuleService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackRuleService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineRuleService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -95,7 +95,7 @@ func (s *VestackRuleService) ReadResources(condition map[string]interface{}) (da }) } -func (s *VestackRuleService) ReadResource(resourceData *schema.ResourceData, ruleId string) (data map[string]interface{}, err error) { +func (s *VolcengineRuleService) ReadResource(resourceData *schema.ResourceData, ruleId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -123,7 +123,7 @@ func (s *VestackRuleService) ReadResource(resourceData *schema.ResourceData, rul return data, err } -func (s *VestackRuleService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineRuleService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -134,14 +134,14 @@ func (s *VestackRuleService) RefreshResourceState(resourceData *schema.ResourceD } } -func (VestackRuleService) WithResourceResponseHandlers(rule map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineRuleService) WithResourceResponseHandlers(rule map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return rule, nil, nil } return []ve.ResourceResponseHandler{handler} } -func (s *VestackRuleService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineRuleService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { // 查询 LoadBalancerId clbId, err := s.queryLoadBalancerId(resourceData.Get("server_group_id").(string)) if err != nil { @@ -192,7 +192,7 @@ func (s *VestackRuleService) CreateResource(resourceData *schema.ResourceData, r return []ve.Callback{callback} } -func (s *VestackRuleService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineRuleService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { // 查询 LoadBalancerId clbId, err := s.queryLoadBalancerId(resourceData.Get("server_group_id").(string)) if err != nil { @@ -237,7 +237,7 @@ func (s *VestackRuleService) ModifyResource(resourceData *schema.ResourceData, r return []ve.Callback{callback} } -func (s *VestackRuleService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineRuleService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { // 查询 LoadBalancerId clbId, err := s.queryLoadBalancerId(resourceData.Get("server_group_id").(string)) if err != nil { @@ -290,7 +290,7 @@ func (s *VestackRuleService) RemoveResource(resourceData *schema.ResourceData, r return []ve.Callback{callback} } -func (s *VestackRuleService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineRuleService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -308,11 +308,11 @@ func (s *VestackRuleService) DatasourceResources(*schema.ResourceData, *schema.R } } -func (s *VestackRuleService) ReadResourceId(id string) string { +func (s *VolcengineRuleService) ReadResourceId(id string) string { return id } -func (s *VestackRuleService) queryLoadBalancerId(serverGroupId string) (string, error) { +func (s *VolcengineRuleService) queryLoadBalancerId(serverGroupId string) (string, error) { // 查询 LoadBalancerId serverGroupResp, err := s.Client.ClbClient.DescribeServerGroupAttributesCommon(&map[string]interface{}{ "ServerGroupId": serverGroupId, diff --git a/vestack/clb/server_group/data_source_vestack_server_groups.go b/volcengine/clb/server_group/data_source_volcengine_server_groups.go similarity index 89% rename from vestack/clb/server_group/data_source_vestack_server_groups.go rename to volcengine/clb/server_group/data_source_volcengine_server_groups.go index 57e3b8bb..4e2de90d 100644 --- a/vestack/clb/server_group/data_source_vestack_server_groups.go +++ b/volcengine/clb/server_group/data_source_volcengine_server_groups.go @@ -3,12 +3,12 @@ package server_group import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackServerGroups() *schema.Resource { +func DataSourceVolcengineServerGroups() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackServerGroupsRead, + Read: dataSourceVolcengineServerGroupsRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -90,7 +90,7 @@ func DataSourceVestackServerGroups() *schema.Resource { } } -func dataSourceVestackServerGroupsRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineServerGroupsRead(d *schema.ResourceData, meta interface{}) error { serverGroupService := NewServerGroupService(meta.(*ve.SdkClient)) - return serverGroupService.Dispatcher.Data(serverGroupService, d, DataSourceVestackServerGroups()) + return serverGroupService.Dispatcher.Data(serverGroupService, d, DataSourceVolcengineServerGroups()) } diff --git a/vestack/clb/server_group/resource_vestack_server_group.go b/volcengine/clb/server_group/resource_volcengine_server_group.go similarity index 65% rename from vestack/clb/server_group/resource_vestack_server_group.go rename to volcengine/clb/server_group/resource_volcengine_server_group.go index 6cba6df2..012bba2d 100644 --- a/vestack/clb/server_group/resource_vestack_server_group.go +++ b/volcengine/clb/server_group/resource_volcengine_server_group.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -12,17 +12,17 @@ import ( Import ServerGroup can be imported using the id, e.g. ``` -$ terraform import vestack_server_group.default rsp-273yv0kir1vk07fap8tt9jtwg +$ terraform import volcengine_server_group.default rsp-273yv0kir1vk07fap8tt9jtwg ``` */ -func ResourceVestackServerGroup() *schema.Resource { +func ResourceVolcengineServerGroup() *schema.Resource { return &schema.Resource{ - Create: resourceVestackServerGroupCreate, - Read: resourceVestackServerGroupRead, - Update: resourceVestackServerGroupUpdate, - Delete: resourceVestackServerGroupDelete, + Create: resourceVolcengineServerGroupCreate, + Read: resourceVolcengineServerGroupRead, + Update: resourceVolcengineServerGroupUpdate, + Delete: resourceVolcengineServerGroupDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -55,36 +55,36 @@ func ResourceVestackServerGroup() *schema.Resource { } } -func resourceVestackServerGroupCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineServerGroupCreate(d *schema.ResourceData, meta interface{}) (err error) { serverGroupService := NewServerGroupService(meta.(*ve.SdkClient)) - err = serverGroupService.Dispatcher.Create(serverGroupService, d, ResourceVestackServerGroup()) + err = serverGroupService.Dispatcher.Create(serverGroupService, d, ResourceVolcengineServerGroup()) if err != nil { return fmt.Errorf("error on creating serverGroup %q, %w", d.Id(), err) } - return resourceVestackServerGroupRead(d, meta) + return resourceVolcengineServerGroupRead(d, meta) } -func resourceVestackServerGroupRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineServerGroupRead(d *schema.ResourceData, meta interface{}) (err error) { serverGroupService := NewServerGroupService(meta.(*ve.SdkClient)) - err = serverGroupService.Dispatcher.Read(serverGroupService, d, ResourceVestackServerGroup()) + err = serverGroupService.Dispatcher.Read(serverGroupService, d, ResourceVolcengineServerGroup()) if err != nil { return fmt.Errorf("error on reading serverGroup %q, %w", d.Id(), err) } return err } -func resourceVestackServerGroupUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineServerGroupUpdate(d *schema.ResourceData, meta interface{}) (err error) { serverGroupService := NewServerGroupService(meta.(*ve.SdkClient)) - err = serverGroupService.Dispatcher.Update(serverGroupService, d, ResourceVestackServerGroup()) + err = serverGroupService.Dispatcher.Update(serverGroupService, d, ResourceVolcengineServerGroup()) if err != nil { return fmt.Errorf("error on updating serverGroup %q, %w", d.Id(), err) } - return resourceVestackServerGroupRead(d, meta) + return resourceVolcengineServerGroupRead(d, meta) } -func resourceVestackServerGroupDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineServerGroupDelete(d *schema.ResourceData, meta interface{}) (err error) { serverGroupService := NewServerGroupService(meta.(*ve.SdkClient)) - err = serverGroupService.Dispatcher.Delete(serverGroupService, d, ResourceVestackServerGroup()) + err = serverGroupService.Dispatcher.Delete(serverGroupService, d, ResourceVolcengineServerGroup()) if err != nil { return fmt.Errorf("error on deleting serverGroup %q, %w", d.Id(), err) } diff --git a/vestack/clb/server_group/service_vestack_server_group.go b/volcengine/clb/server_group/service_volcengine_server_group.go similarity index 79% rename from vestack/clb/server_group/service_vestack_server_group.go rename to volcengine/clb/server_group/service_volcengine_server_group.go index 7777e988..f7d872f3 100644 --- a/vestack/clb/server_group/service_vestack_server_group.go +++ b/volcengine/clb/server_group/service_volcengine_server_group.go @@ -7,28 +7,28 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" - "github.com/volcengine/terraform-provider-vestack/vestack/clb/clb" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" + "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/clb" ) -type VestackServerGroupService struct { +type VolcengineServerGroupService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewServerGroupService(c *ve.SdkClient) *VestackServerGroupService { - return &VestackServerGroupService{ +func NewServerGroupService(c *ve.SdkClient) *VolcengineServerGroupService { + return &VolcengineServerGroupService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackServerGroupService) GetClient() *ve.SdkClient { +func (s *VolcengineServerGroupService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackServerGroupService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineServerGroupService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -65,7 +65,7 @@ func (s *VestackServerGroupService) ReadResources(condition map[string]interface }) } -func (s *VestackServerGroupService) ReadResource(resourceData *schema.ResourceData, serverGroupId string) (data map[string]interface{}, err error) { +func (s *VolcengineServerGroupService) ReadResource(resourceData *schema.ResourceData, serverGroupId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -91,11 +91,11 @@ func (s *VestackServerGroupService) ReadResource(resourceData *schema.ResourceDa return data, err } -func (s *VestackServerGroupService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineServerGroupService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return nil } -func (VestackServerGroupService) WithResourceResponseHandlers(serverGroup map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineServerGroupService) WithResourceResponseHandlers(serverGroup map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return serverGroup, nil, nil } @@ -103,7 +103,7 @@ func (VestackServerGroupService) WithResourceResponseHandlers(serverGroup map[st } -func (s *VestackServerGroupService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineServerGroupService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "CreateServerGroup", @@ -140,7 +140,7 @@ func (s *VestackServerGroupService) CreateResource(resourceData *schema.Resource } -func (s *VestackServerGroupService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineServerGroupService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { clbId, err := s.queryLoadBalancerId(resourceData.Id()) if err != nil { return []ve.Callback{{ @@ -176,7 +176,7 @@ func (s *VestackServerGroupService) ModifyResource(resourceData *schema.Resource return []ve.Callback{callback} } -func (s *VestackServerGroupService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineServerGroupService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { clbId, err := s.queryLoadBalancerId(resourceData.Id()) if err != nil { return []ve.Callback{{ @@ -229,7 +229,7 @@ func (s *VestackServerGroupService) RemoveResource(resourceData *schema.Resource return []ve.Callback{callback} } -func (s *VestackServerGroupService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineServerGroupService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -249,11 +249,11 @@ func (s *VestackServerGroupService) DatasourceResources(*schema.ResourceData, *s } } -func (s *VestackServerGroupService) ReadResourceId(id string) string { +func (s *VolcengineServerGroupService) ReadResourceId(id string) string { return id } -func (s *VestackServerGroupService) queryLoadBalancerId(serverGroupId string) (string, error) { +func (s *VolcengineServerGroupService) queryLoadBalancerId(serverGroupId string) (string, error) { if serverGroupId == "" { return "", fmt.Errorf("server_group_id cannot be empty") } diff --git a/vestack/clb/server_group_server/common_vestack_server_grop_server.go b/volcengine/clb/server_group_server/common_volcengine_server_grop_server.go similarity index 100% rename from vestack/clb/server_group_server/common_vestack_server_grop_server.go rename to volcengine/clb/server_group_server/common_volcengine_server_grop_server.go diff --git a/vestack/clb/server_group_server/data_resource_vestack_server_group_servers.go b/volcengine/clb/server_group_server/data_resource_volcengine_server_group_servers.go similarity index 88% rename from vestack/clb/server_group_server/data_resource_vestack_server_group_servers.go rename to volcengine/clb/server_group_server/data_resource_volcengine_server_group_servers.go index ba361ee7..dbb92594 100644 --- a/vestack/clb/server_group_server/data_resource_vestack_server_group_servers.go +++ b/volcengine/clb/server_group_server/data_resource_volcengine_server_group_servers.go @@ -3,12 +3,12 @@ package server_group_server import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackServerGroupServers() *schema.Resource { +func DataSourceVolcengineServerGroupServers() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackServerGroupServersRead, + Read: dataSourceVolcengineServerGroupServersRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -94,7 +94,7 @@ func DataSourceVestackServerGroupServers() *schema.Resource { } } -func dataSourceVestackServerGroupServersRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineServerGroupServersRead(d *schema.ResourceData, meta interface{}) error { serverGroupServerService := NewServerGroupServerService(meta.(*ve.SdkClient)) - return serverGroupServerService.Dispatcher.Data(serverGroupServerService, d, DataSourceVestackServerGroupServers()) + return serverGroupServerService.Dispatcher.Data(serverGroupServerService, d, DataSourceVolcengineServerGroupServers()) } diff --git a/vestack/clb/server_group_server/resource_vestack_server_group.go b/volcengine/clb/server_group_server/resource_volcengine_server_group.go similarity index 69% rename from vestack/clb/server_group_server/resource_vestack_server_group.go rename to volcengine/clb/server_group_server/resource_volcengine_server_group.go index 48c7bda1..b48de3da 100644 --- a/vestack/clb/server_group_server/resource_vestack_server_group.go +++ b/volcengine/clb/server_group_server/resource_volcengine_server_group.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -13,17 +13,17 @@ import ( Import ServerGroupServer can be imported using the id, e.g. ``` -$ terraform import vestack_server_group_server.default rs-3ciynux6i1x4w****rszh49sj +$ terraform import volcengine_server_group_server.default rs-3ciynux6i1x4w****rszh49sj ``` */ -func ResourceVestackServerGroupServer() *schema.Resource { +func ResourceVolcengineServerGroupServer() *schema.Resource { return &schema.Resource{ - Create: resourceVestackServerGroupServerCreate, - Read: resourceVestackServerGroupServerRead, - Update: resourceVestackServerGroupServerUpdate, - Delete: resourceVestackServerGroupServerDelete, + Create: resourceVolcengineServerGroupServerCreate, + Read: resourceVolcengineServerGroupServerRead, + Update: resourceVolcengineServerGroupServerUpdate, + Delete: resourceVolcengineServerGroupServerDelete, Importer: &schema.ResourceImporter{ State: serverGroupServerImporter, }, @@ -77,36 +77,36 @@ func ResourceVestackServerGroupServer() *schema.Resource { } } -func resourceVestackServerGroupServerCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineServerGroupServerCreate(d *schema.ResourceData, meta interface{}) (err error) { serverGroupServerService := NewServerGroupServerService(meta.(*ve.SdkClient)) - err = serverGroupServerService.Dispatcher.Create(serverGroupServerService, d, ResourceVestackServerGroupServer()) + err = serverGroupServerService.Dispatcher.Create(serverGroupServerService, d, ResourceVolcengineServerGroupServer()) if err != nil { return fmt.Errorf("error on creating serverGroupServer %q, %w", d.Id(), err) } - return resourceVestackServerGroupServerRead(d, meta) + return resourceVolcengineServerGroupServerRead(d, meta) } -func resourceVestackServerGroupServerRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineServerGroupServerRead(d *schema.ResourceData, meta interface{}) (err error) { serverGroupServerService := NewServerGroupServerService(meta.(*ve.SdkClient)) - err = serverGroupServerService.Dispatcher.Read(serverGroupServerService, d, ResourceVestackServerGroupServer()) + err = serverGroupServerService.Dispatcher.Read(serverGroupServerService, d, ResourceVolcengineServerGroupServer()) if err != nil { return fmt.Errorf("error on reading serverGroupServer %q, %w", d.Id(), err) } return err } -func resourceVestackServerGroupServerUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineServerGroupServerUpdate(d *schema.ResourceData, meta interface{}) (err error) { serverGroupServerService := NewServerGroupServerService(meta.(*ve.SdkClient)) - err = serverGroupServerService.Dispatcher.Update(serverGroupServerService, d, ResourceVestackServerGroupServer()) + err = serverGroupServerService.Dispatcher.Update(serverGroupServerService, d, ResourceVolcengineServerGroupServer()) if err != nil { return fmt.Errorf("error on updating serverGroupServer %q, %w", d.Id(), err) } - return resourceVestackServerGroupServerRead(d, meta) + return resourceVolcengineServerGroupServerRead(d, meta) } -func resourceVestackServerGroupServerDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineServerGroupServerDelete(d *schema.ResourceData, meta interface{}) (err error) { serverGroupServerService := NewServerGroupServerService(meta.(*ve.SdkClient)) - err = serverGroupServerService.Dispatcher.Delete(serverGroupServerService, d, ResourceVestackServerGroupServer()) + err = serverGroupServerService.Dispatcher.Delete(serverGroupServerService, d, ResourceVolcengineServerGroupServer()) if err != nil { return fmt.Errorf("error on deleting serverGroupServer %q, %w", d.Id(), err) } diff --git a/vestack/clb/server_group_server/service_vestack_server_group_server.go b/volcengine/clb/server_group_server/service_volcengine_server_group_server.go similarity index 82% rename from vestack/clb/server_group_server/service_vestack_server_group_server.go rename to volcengine/clb/server_group_server/service_volcengine_server_group_server.go index dd084469..283ee039 100644 --- a/vestack/clb/server_group_server/service_vestack_server_group_server.go +++ b/volcengine/clb/server_group_server/service_volcengine_server_group_server.go @@ -8,28 +8,28 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" - "github.com/volcengine/terraform-provider-vestack/vestack/clb/clb" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" + "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/clb" ) -type VestackServerGroupServerService struct { +type VolcengineServerGroupServerService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewServerGroupServerService(c *ve.SdkClient) *VestackServerGroupServerService { - return &VestackServerGroupServerService{ +func NewServerGroupServerService(c *ve.SdkClient) *VolcengineServerGroupServerService { + return &VolcengineServerGroupServerService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackServerGroupServerService) GetClient() *ve.SdkClient { +func (s *VolcengineServerGroupServerService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackServerGroupServerService) ReadResources(condition map[string]interface{}) ([]interface{}, error) { +func (s *VolcengineServerGroupServerService) ReadResources(condition map[string]interface{}) ([]interface{}, error) { var ( serverIdMap = make(map[string]bool) res = make([]interface{}, 0) @@ -95,7 +95,7 @@ func (s *VestackServerGroupServerService) ReadResources(condition map[string]int return res, nil } -func (s *VestackServerGroupServerService) ReadResource(resourceData *schema.ResourceData, serverGroupServerId string) (data map[string]interface{}, err error) { +func (s *VolcengineServerGroupServerService) ReadResource(resourceData *schema.ResourceData, serverGroupServerId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -123,11 +123,11 @@ func (s *VestackServerGroupServerService) ReadResource(resourceData *schema.Reso return data, err } -func (s *VestackServerGroupServerService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineServerGroupServerService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return nil } -func (VestackServerGroupServerService) WithResourceResponseHandlers(serverGroupServer map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineServerGroupServerService) WithResourceResponseHandlers(serverGroupServer map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return serverGroupServer, nil, nil } @@ -135,7 +135,7 @@ func (VestackServerGroupServerService) WithResourceResponseHandlers(serverGroupS } -func (s *VestackServerGroupServerService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineServerGroupServerService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { clbId, err := s.queryLoadBalancerId(resourceData.Get("server_group_id").(string)) if err != nil { return []ve.Callback{{ @@ -183,7 +183,7 @@ func (s *VestackServerGroupServerService) CreateResource(resourceData *schema.Re } -func (s *VestackServerGroupServerService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineServerGroupServerService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { ids := strings.Split(resourceData.Id(), ":") clbId, err := s.queryLoadBalancerId(ids[0]) @@ -224,7 +224,7 @@ func (s *VestackServerGroupServerService) ModifyResource(resourceData *schema.Re return []ve.Callback{callback} } -func (s *VestackServerGroupServerService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineServerGroupServerService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { ids := strings.Split(resourceData.Id(), ":") clbId, err := s.queryLoadBalancerId(ids[0]) @@ -280,7 +280,7 @@ func (s *VestackServerGroupServerService) RemoveResource(resourceData *schema.Re return []ve.Callback{callback} } -func (s *VestackServerGroupServerService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineServerGroupServerService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -300,11 +300,11 @@ func (s *VestackServerGroupServerService) DatasourceResources(*schema.ResourceDa } } -func (s *VestackServerGroupServerService) ReadResourceId(id string) string { +func (s *VolcengineServerGroupServerService) ReadResourceId(id string) string { return id } -func (s *VestackServerGroupServerService) queryLoadBalancerId(serverGroupId string) (string, error) { +func (s *VolcengineServerGroupServerService) queryLoadBalancerId(serverGroupId string) (string, error) { if serverGroupId == "" { return "", fmt.Errorf("server_group_id cannot be empty") } diff --git a/vestack/ebs/volume/data_source_vestack_volumes.go b/volcengine/ebs/volume/data_source_volcengine_volumes.go similarity index 93% rename from vestack/ebs/volume/data_source_vestack_volumes.go rename to volcengine/ebs/volume/data_source_volcengine_volumes.go index a23a074c..297e47de 100644 --- a/vestack/ebs/volume/data_source_vestack_volumes.go +++ b/volcengine/ebs/volume/data_source_volcengine_volumes.go @@ -3,12 +3,12 @@ package volume import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackVolumes() *schema.Resource { +func DataSourceVolcengineVolumes() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackVolumesRead, + Read: dataSourceVolcengineVolumesRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -160,7 +160,7 @@ func DataSourceVestackVolumes() *schema.Resource { } } -func dataSourceVestackVolumesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineVolumesRead(d *schema.ResourceData, meta interface{}) error { volumeService := NewVolumeService(meta.(*ve.SdkClient)) - return volumeService.Dispatcher.Data(volumeService, d, DataSourceVestackVolumes()) + return volumeService.Dispatcher.Data(volumeService, d, DataSourceVolcengineVolumes()) } diff --git a/vestack/ebs/volume/resource_vestack_volume.go b/volcengine/ebs/volume/resource_volcengine_volume.go similarity index 79% rename from vestack/ebs/volume/resource_vestack_volume.go rename to volcengine/ebs/volume/resource_volcengine_volume.go index 80440a41..30428ee0 100644 --- a/vestack/ebs/volume/resource_vestack_volume.go +++ b/volcengine/ebs/volume/resource_volcengine_volume.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -13,17 +13,17 @@ import ( Import Volume can be imported using the id, e.g. ``` -$ terraform import vestack_volume.default vol-mizl7m1kqccg5smt1bdpijuj +$ terraform import volcengine_volume.default vol-mizl7m1kqccg5smt1bdpijuj ``` */ -func ResourceVestackVolume() *schema.Resource { +func ResourceVolcengineVolume() *schema.Resource { return &schema.Resource{ - Create: resourceVestackVolumeCreate, - Read: resourceVestackVolumeRead, - Update: resourceVestackVolumeUpdate, - Delete: resourceVestackVolumeDelete, + Create: resourceVolcengineVolumeCreate, + Read: resourceVolcengineVolumeRead, + Update: resourceVolcengineVolumeUpdate, + Delete: resourceVolcengineVolumeDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -111,36 +111,36 @@ func ResourceVestackVolume() *schema.Resource { } } -func resourceVestackVolumeCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineVolumeCreate(d *schema.ResourceData, meta interface{}) (err error) { volumeService := NewVolumeService(meta.(*ve.SdkClient)) - err = volumeService.Dispatcher.Create(volumeService, d, ResourceVestackVolume()) + err = volumeService.Dispatcher.Create(volumeService, d, ResourceVolcengineVolume()) if err != nil { return fmt.Errorf("error on creating volume %q, %w", d.Id(), err) } - return resourceVestackVolumeRead(d, meta) + return resourceVolcengineVolumeRead(d, meta) } -func resourceVestackVolumeRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineVolumeRead(d *schema.ResourceData, meta interface{}) (err error) { volumeService := NewVolumeService(meta.(*ve.SdkClient)) - err = volumeService.Dispatcher.Read(volumeService, d, ResourceVestackVolume()) + err = volumeService.Dispatcher.Read(volumeService, d, ResourceVolcengineVolume()) if err != nil { return fmt.Errorf("error on reading volume %q, %w", d.Id(), err) } return err } -func resourceVestackVolumeUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineVolumeUpdate(d *schema.ResourceData, meta interface{}) (err error) { volumeService := NewVolumeService(meta.(*ve.SdkClient)) - err = volumeService.Dispatcher.Update(volumeService, d, ResourceVestackVolume()) + err = volumeService.Dispatcher.Update(volumeService, d, ResourceVolcengineVolume()) if err != nil { return fmt.Errorf("error on updating volume %q, %w", d.Id(), err) } - return resourceVestackVolumeRead(d, meta) + return resourceVolcengineVolumeRead(d, meta) } -func resourceVestackVolumeDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineVolumeDelete(d *schema.ResourceData, meta interface{}) (err error) { volumeService := NewVolumeService(meta.(*ve.SdkClient)) - err = volumeService.Dispatcher.Delete(volumeService, d, ResourceVestackVolume()) + err = volumeService.Dispatcher.Delete(volumeService, d, ResourceVolcengineVolume()) if err != nil { return fmt.Errorf("error on deleting volume %q, %w", d.Id(), err) } diff --git a/vestack/ebs/volume/service_vestack_volume.go b/volcengine/ebs/volume/service_volcengine_volume.go similarity index 83% rename from vestack/ebs/volume/service_vestack_volume.go rename to volcengine/ebs/volume/service_volcengine_volume.go index 7e48aede..3c0ffbc0 100644 --- a/vestack/ebs/volume/service_vestack_volume.go +++ b/volcengine/ebs/volume/service_volcengine_volume.go @@ -8,27 +8,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackVolumeService struct { +type VolcengineVolumeService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewVolumeService(c *ve.SdkClient) *VestackVolumeService { - return &VestackVolumeService{ +func NewVolumeService(c *ve.SdkClient) *VolcengineVolumeService { + return &VolcengineVolumeService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackVolumeService) GetClient() *ve.SdkClient { +func (s *VolcengineVolumeService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackVolumeService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineVolumeService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -62,7 +62,7 @@ func (s *VestackVolumeService) ReadResources(condition map[string]interface{}) ( }) } -func (s *VestackVolumeService) ReadResource(resourceData *schema.ResourceData, volumeId string) (data map[string]interface{}, err error) { +func (s *VolcengineVolumeService) ReadResource(resourceData *schema.ResourceData, volumeId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -88,7 +88,7 @@ func (s *VestackVolumeService) ReadResource(resourceData *schema.ResourceData, v return data, err } -func (s *VestackVolumeService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineVolumeService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -120,7 +120,7 @@ func (s *VestackVolumeService) RefreshResourceState(resourceData *schema.Resourc } } -func (VestackVolumeService) WithResourceResponseHandlers(volume map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineVolumeService) WithResourceResponseHandlers(volume map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return volume, map[string]ve.ResponseConvert{ "Size": { @@ -132,7 +132,7 @@ func (VestackVolumeService) WithResourceResponseHandlers(volume map[string]inter return []ve.ResourceResponseHandler{handler} } -func (s *VestackVolumeService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineVolumeService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "CreateVolume", @@ -155,7 +155,7 @@ func (s *VestackVolumeService) CreateResource(resourceData *schema.ResourceData, return []ve.Callback{callback} } -func (s *VestackVolumeService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineVolumeService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { var callbacks []ve.Callback if resourceData.HasChanges("volume_name", "description", "delete_with_instance") { callbacks = append(callbacks, ve.Callback{ @@ -202,7 +202,7 @@ func (s *VestackVolumeService) ModifyResource(resourceData *schema.ResourceData, return callbacks } -func (s *VestackVolumeService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineVolumeService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "DeleteVolume", @@ -236,7 +236,7 @@ func (s *VestackVolumeService) RemoveResource(resourceData *schema.ResourceData, return []ve.Callback{callback} } -func (s *VestackVolumeService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineVolumeService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -274,6 +274,6 @@ var sizeConvertFunc = func(i interface{}) interface{} { return res } -func (s *VestackVolumeService) ReadResourceId(id string) string { +func (s *VolcengineVolumeService) ReadResourceId(id string) string { return id } diff --git a/vestack/ebs/volume/service_vestack_volume_test.go b/volcengine/ebs/volume/service_volcengine_volume_test.go similarity index 100% rename from vestack/ebs/volume/service_vestack_volume_test.go rename to volcengine/ebs/volume/service_volcengine_volume_test.go diff --git a/vestack/ebs/volume_attach/resource_vestack_volume_attach.go b/volcengine/ebs/volume_attach/resource_volcengine_volume_attach.go similarity index 66% rename from vestack/ebs/volume_attach/resource_vestack_volume_attach.go rename to volcengine/ebs/volume_attach/resource_volcengine_volume_attach.go index 088909b8..103f953e 100644 --- a/vestack/ebs/volume_attach/resource_vestack_volume_attach.go +++ b/volcengine/ebs/volume_attach/resource_volcengine_volume_attach.go @@ -5,7 +5,7 @@ import ( "time" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -13,17 +13,17 @@ import ( Import VolumeAttach can be imported using the id, e.g. ``` -$ terraform import vestack_volume_attach.default vol-abc12345:i-abc12345 +$ terraform import volcengine_volume_attach.default vol-abc12345:i-abc12345 ``` */ -func ResourceVestackVolumeAttach() *schema.Resource { +func ResourceVolcengineVolumeAttach() *schema.Resource { return &schema.Resource{ - Create: resourceVestackVolumeAttachCreate, - Read: resourceVestackVolumeAttachRead, - Update: resourceVestackVolumeAttachUpdate, - Delete: resourceVestackVolumeAttachDelete, + Create: resourceVolcengineVolumeAttachCreate, + Read: resourceVolcengineVolumeAttachRead, + Update: resourceVolcengineVolumeAttachUpdate, + Delete: resourceVolcengineVolumeAttachDelete, Importer: &schema.ResourceImporter{ State: importVolumeAttach, }, @@ -69,31 +69,31 @@ func ResourceVestackVolumeAttach() *schema.Resource { } } -func resourceVestackVolumeAttachCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineVolumeAttachCreate(d *schema.ResourceData, meta interface{}) (err error) { volumeAttachService := NewVolumeAttachService(meta.(*ve.SdkClient)) - err = volumeAttachService.Dispatcher.Create(volumeAttachService, d, ResourceVestackVolumeAttach()) + err = volumeAttachService.Dispatcher.Create(volumeAttachService, d, ResourceVolcengineVolumeAttach()) if err != nil { return fmt.Errorf("error on attach volume %q, %w", d.Id(), err) } - return resourceVestackVolumeAttachRead(d, meta) + return resourceVolcengineVolumeAttachRead(d, meta) } -func resourceVestackVolumeAttachRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineVolumeAttachRead(d *schema.ResourceData, meta interface{}) (err error) { volumeAttachService := NewVolumeAttachService(meta.(*ve.SdkClient)) - err = volumeAttachService.Dispatcher.Read(volumeAttachService, d, ResourceVestackVolumeAttach()) + err = volumeAttachService.Dispatcher.Read(volumeAttachService, d, ResourceVolcengineVolumeAttach()) if err != nil { return fmt.Errorf("error on reading volume %q, %w", d.Id(), err) } return err } -func resourceVestackVolumeAttachUpdate(d *schema.ResourceData, meta interface{}) (err error) { - return resourceVestackVolumeAttachRead(d, meta) +func resourceVolcengineVolumeAttachUpdate(d *schema.ResourceData, meta interface{}) (err error) { + return resourceVolcengineVolumeAttachRead(d, meta) } -func resourceVestackVolumeAttachDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineVolumeAttachDelete(d *schema.ResourceData, meta interface{}) (err error) { volumeAttachService := NewVolumeAttachService(meta.(*ve.SdkClient)) - err = volumeAttachService.Dispatcher.Delete(volumeAttachService, d, ResourceVestackVolumeAttach()) + err = volumeAttachService.Dispatcher.Delete(volumeAttachService, d, ResourceVolcengineVolumeAttach()) if err != nil { return fmt.Errorf("error on detach volume %q, %w", d.Id(), err) } diff --git a/vestack/ebs/volume_attach/service_vestack_volume_attach.go b/volcengine/ebs/volume_attach/service_volcengine_volume_attach.go similarity index 79% rename from vestack/ebs/volume_attach/service_vestack_volume_attach.go rename to volcengine/ebs/volume_attach/service_volcengine_volume_attach.go index 67d08cc2..0aed7458 100644 --- a/vestack/ebs/volume_attach/service_vestack_volume_attach.go +++ b/volcengine/ebs/volume_attach/service_volcengine_volume_attach.go @@ -8,27 +8,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackVolumeAttachService struct { +type VolcengineVolumeAttachService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewVolumeAttachService(c *ve.SdkClient) *VestackVolumeAttachService { - return &VestackVolumeAttachService{ +func NewVolumeAttachService(c *ve.SdkClient) *VolcengineVolumeAttachService { + return &VolcengineVolumeAttachService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackVolumeAttachService) GetClient() *ve.SdkClient { +func (s *VolcengineVolumeAttachService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackVolumeAttachService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineVolumeAttachService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -62,7 +62,7 @@ func (s *VestackVolumeAttachService) ReadResources(condition map[string]interfac }) } -func (s *VestackVolumeAttachService) ReadResource(resourceData *schema.ResourceData, volumeAttachId string) (data map[string]interface{}, err error) { +func (s *VolcengineVolumeAttachService) ReadResource(resourceData *schema.ResourceData, volumeAttachId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -98,7 +98,7 @@ func (s *VestackVolumeAttachService) ReadResource(resourceData *schema.ResourceD return data, err } -func (s *VestackVolumeAttachService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineVolumeAttachService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -130,14 +130,14 @@ func (s *VestackVolumeAttachService) RefreshResourceState(resourceData *schema.R } } -func (VestackVolumeAttachService) WithResourceResponseHandlers(volume map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineVolumeAttachService) WithResourceResponseHandlers(volume map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return volume, nil, nil } return []ve.ResourceResponseHandler{handler} } -func (s *VestackVolumeAttachService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineVolumeAttachService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "AttachVolume", @@ -159,7 +159,7 @@ func (s *VestackVolumeAttachService) CreateResource(resourceData *schema.Resourc return []ve.Callback{callback} } -func (s *VestackVolumeAttachService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineVolumeAttachService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { strs := strings.Split(resourceData.Id(), ":") callback := ve.Callback{ Call: ve.SdkCall{ @@ -199,11 +199,11 @@ func (s *VestackVolumeAttachService) RemoveResource(resourceData *schema.Resourc return []ve.Callback{callback} } -func (s *VestackVolumeAttachService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineVolumeAttachService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { return []ve.Callback{} } -func (s *VestackVolumeAttachService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineVolumeAttachService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{} } @@ -225,6 +225,6 @@ func importVolumeAttach(d *schema.ResourceData, meta interface{}) ([]*schema.Res return []*schema.ResourceData{d}, nil } -func (s *VestackVolumeAttachService) ReadResourceId(id string) string { +func (s *VolcengineVolumeAttachService) ReadResourceId(id string) string { return id } diff --git a/vestack/ebs/volume_attach/service_vestack_volume_attach_test.go b/volcengine/ebs/volume_attach/service_volcengine_volume_attach_test.go similarity index 83% rename from vestack/ebs/volume_attach/service_vestack_volume_attach_test.go rename to volcengine/ebs/volume_attach/service_volcengine_volume_attach_test.go index 9aa0d99a..816f42aa 100644 --- a/vestack/ebs/volume_attach/service_vestack_volume_attach_test.go +++ b/volcengine/ebs/volume_attach/service_volcengine_volume_attach_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) func Test_ResourceNotFoundError(t *testing.T) { diff --git a/vestack/ecs/ecs_instance/data_source_vestack_ecs_instances.go b/volcengine/ecs/ecs_instance/data_source_volcengine_ecs_instances.go similarity index 95% rename from vestack/ecs/ecs_instance/data_source_vestack_ecs_instances.go rename to volcengine/ecs/ecs_instance/data_source_volcengine_ecs_instances.go index f9a48fee..afbb40e2 100644 --- a/vestack/ecs/ecs_instance/data_source_vestack_ecs_instances.go +++ b/volcengine/ecs/ecs_instance/data_source_volcengine_ecs_instances.go @@ -3,12 +3,12 @@ package ecs_instance import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackEcsInstances() *schema.Resource { +func DataSourceVolcengineEcsInstances() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackInstancesRead, + Read: dataSourceVolcengineInstancesRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -257,7 +257,7 @@ func DataSourceVestackEcsInstances() *schema.Resource { } } -func dataSourceVestackInstancesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineInstancesRead(d *schema.ResourceData, meta interface{}) error { ecsService := NewEcsService(meta.(*ve.SdkClient)) - return ecsService.Dispatcher.Data(ecsService, d, DataSourceVestackEcsInstances()) + return ecsService.Dispatcher.Data(ecsService, d, DataSourceVolcengineEcsInstances()) } diff --git a/vestack/ecs/ecs_instance/resource_vestack_ecs_instance.go b/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go similarity index 86% rename from vestack/ecs/ecs_instance/resource_vestack_ecs_instance.go rename to volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go index e55afe2f..ebdb9583 100644 --- a/vestack/ecs/ecs_instance/resource_vestack_ecs_instance.go +++ b/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -14,18 +14,18 @@ import ( Import ECS Instance can be imported using the id, e.g. ``` -$ terraform import vestack_ecs_instance.default i-mizl7m1kqccg5smt1bdpijuj +$ terraform import volcengine_ecs_instance.default i-mizl7m1kqccg5smt1bdpijuj ``` */ -func ResourceVestackEcsInstance() *schema.Resource { +func ResourceVolcengineEcsInstance() *schema.Resource { resource := &schema.Resource{ - Create: resourceVestackEcsInstanceCreate, - Read: resourceVestackEcsInstanceRead, - Update: resourceVestackEcsInstanceUpdate, - Delete: resourceVestackEcsInstanceDelete, - Exists: resourceVestackEcsInstanceExist, + Create: resourceVolcengineEcsInstanceCreate, + Read: resourceVolcengineEcsInstanceRead, + Update: resourceVolcengineEcsInstanceUpdate, + Delete: resourceVolcengineEcsInstanceDelete, + Exists: resourceVolcengineEcsInstanceExist, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -259,51 +259,51 @@ func ResourceVestackEcsInstance() *schema.Resource { }, }, } - dataSource := DataSourceVestackEcsInstances().Schema["instances"].Elem.(*schema.Resource).Schema + dataSource := DataSourceVolcengineEcsInstances().Schema["instances"].Elem.(*schema.Resource).Schema delete(dataSource, "network_interfaces") delete(dataSource, "volumes") ve.MergeDateSourceToResource(dataSource, &resource.Schema) return resource } -func resourceVestackEcsInstanceCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineEcsInstanceCreate(d *schema.ResourceData, meta interface{}) (err error) { instanceService := NewEcsService(meta.(*ve.SdkClient)) - err = instanceService.Dispatcher.Create(instanceService, d, ResourceVestackEcsInstance()) + err = instanceService.Dispatcher.Create(instanceService, d, ResourceVolcengineEcsInstance()) if err != nil { return fmt.Errorf("error on creating ecs instance %q, %s", d.Id(), err) } - return resourceVestackEcsInstanceRead(d, meta) + return resourceVolcengineEcsInstanceRead(d, meta) } -func resourceVestackEcsInstanceRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineEcsInstanceRead(d *schema.ResourceData, meta interface{}) (err error) { instanceService := NewEcsService(meta.(*ve.SdkClient)) - err = instanceService.Dispatcher.Read(instanceService, d, ResourceVestackEcsInstance()) + err = instanceService.Dispatcher.Read(instanceService, d, ResourceVolcengineEcsInstance()) if err != nil { return fmt.Errorf("error on reading ecs instance %q, %s", d.Id(), err) } return err } -func resourceVestackEcsInstanceUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineEcsInstanceUpdate(d *schema.ResourceData, meta interface{}) (err error) { instanceService := NewEcsService(meta.(*ve.SdkClient)) - err = instanceService.Dispatcher.Update(instanceService, d, ResourceVestackEcsInstance()) + err = instanceService.Dispatcher.Update(instanceService, d, ResourceVolcengineEcsInstance()) if err != nil { return fmt.Errorf("error on updating ecs instance %q, %s", d.Id(), err) } - return resourceVestackEcsInstanceRead(d, meta) + return resourceVolcengineEcsInstanceRead(d, meta) } -func resourceVestackEcsInstanceDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineEcsInstanceDelete(d *schema.ResourceData, meta interface{}) (err error) { instanceService := NewEcsService(meta.(*ve.SdkClient)) - err = instanceService.Dispatcher.Delete(instanceService, d, ResourceVestackEcsInstance()) + err = instanceService.Dispatcher.Delete(instanceService, d, ResourceVolcengineEcsInstance()) if err != nil { return fmt.Errorf("error on deleting ecs instance %q, %s", d.Id(), err) } return err } -func resourceVestackEcsInstanceExist(d *schema.ResourceData, meta interface{}) (flag bool, err error) { - err = resourceVestackEcsInstanceRead(d, meta) +func resourceVolcengineEcsInstanceExist(d *schema.ResourceData, meta interface{}) (flag bool, err error) { + err = resourceVolcengineEcsInstanceRead(d, meta) if err != nil { if strings.Contains(err.Error(), "notfound") || strings.Contains(err.Error(), "not found") || strings.Contains(err.Error(), "not exist") || strings.Contains(err.Error(), "not associate") || diff --git a/vestack/ecs/ecs_instance/service_vestack_ecs_instance.go b/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go similarity index 94% rename from vestack/ecs/ecs_instance/service_vestack_ecs_instance.go rename to volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go index 79060439..e58ad14b 100644 --- a/vestack/ecs/ecs_instance/service_vestack_ecs_instance.go +++ b/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go @@ -12,27 +12,27 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackEcsService struct { +type VolcengineEcsService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewEcsService(c *ve.SdkClient) *VestackEcsService { - return &VestackEcsService{ +func NewEcsService(c *ve.SdkClient) *VolcengineEcsService { + return &VolcengineEcsService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackEcsService) GetClient() *ve.SdkClient { +func (s *VolcengineEcsService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackEcsService) ReadResources(condition map[string]interface{}) ([]interface{}, error) { +func (s *VolcengineEcsService) ReadResources(condition map[string]interface{}) ([]interface{}, error) { var ( resp *map[string]interface{} results interface{} @@ -75,7 +75,7 @@ func (s *VestackEcsService) ReadResources(condition map[string]interface{}) ([]i }) } -func (s *VestackEcsService) ReadResource(resourceData *schema.ResourceData, instanceId string) (data map[string]interface{}, err error) { +func (s *VolcengineEcsService) ReadResource(resourceData *schema.ResourceData, instanceId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -102,7 +102,7 @@ func (s *VestackEcsService) ReadResource(resourceData *schema.ResourceData, inst return data, nil } -func (s *VestackEcsService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineEcsService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 5 * time.Second, @@ -145,7 +145,7 @@ func (s *VestackEcsService) RefreshResourceState(resourceData *schema.ResourceDa } } -func (s *VestackEcsService) WithResourceResponseHandlers(ecs map[string]interface{}) []ve.ResourceResponseHandler { +func (s *VolcengineEcsService) WithResourceResponseHandlers(ecs map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { var ( ebsErr error @@ -305,7 +305,7 @@ func (s *VestackEcsService) WithResourceResponseHandlers(ecs map[string]interfac return []ve.ResourceResponseHandler{handler} } -func (s *VestackEcsService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineEcsService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "RunInstances", @@ -377,7 +377,7 @@ func (s *VestackEcsService) CreateResource(resourceData *schema.ResourceData, re return []ve.Callback{callback} } -func (s *VestackEcsService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) (callbacks []ve.Callback) { +func (s *VolcengineEcsService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) (callbacks []ve.Callback) { var ( passwordChange bool ) @@ -710,7 +710,7 @@ func (s *VestackEcsService) ModifyResource(resourceData *schema.ResourceData, re return callbacks } -func (s *VestackEcsService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineEcsService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "DeleteInstance", @@ -750,7 +750,7 @@ func (s *VestackEcsService) RemoveResource(resourceData *schema.ResourceData, r return []ve.Callback{callback} } -func (s *VestackEcsService) DatasourceResources(data *schema.ResourceData, resource *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineEcsService) DatasourceResources(data *schema.ResourceData, resource *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -768,7 +768,7 @@ func (s *VestackEcsService) DatasourceResources(data *schema.ResourceData, resou } } -func (s *VestackEcsService) CommonResponseConvert() map[string]ve.ResponseConvert { +func (s *VolcengineEcsService) CommonResponseConvert() map[string]ve.ResponseConvert { return map[string]ve.ResponseConvert{ "Id": { TargetField: "instance_id", @@ -823,7 +823,7 @@ func (s *VestackEcsService) CommonResponseConvert() map[string]ve.ResponseConver } } -func (s *VestackEcsService) StartOrStopInstanceCallback(resourceData *schema.ResourceData, isStop bool) ve.Callback { +func (s *VolcengineEcsService) StartOrStopInstanceCallback(resourceData *schema.ResourceData, isStop bool) ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ ConvertMode: ve.RequestConvertIgnore, @@ -856,11 +856,11 @@ func (s *VestackEcsService) StartOrStopInstanceCallback(resourceData *schema.Res return callback } -func (s *VestackEcsService) ReadResourceId(id string) string { +func (s *VolcengineEcsService) ReadResourceId(id string) string { return id } -func (s *VestackEcsService) readEbsVolumes(sourceData []interface{}) (extraData []interface{}, err error) { +func (s *VolcengineEcsService) readEbsVolumes(sourceData []interface{}) (extraData []interface{}, err error) { //merge ebs var ( wg sync.WaitGroup diff --git a/vestack/ecs/ecs_instance_state/common_vestack_ecs_instance_state.go b/volcengine/ecs/ecs_instance_state/common_volcengine_ecs_instance_state.go similarity index 100% rename from vestack/ecs/ecs_instance_state/common_vestack_ecs_instance_state.go rename to volcengine/ecs/ecs_instance_state/common_volcengine_ecs_instance_state.go diff --git a/vestack/ecs/ecs_instance_state/resource_vestack_ecs_instance_state.go b/volcengine/ecs/ecs_instance_state/resource_volcengine_ecs_instance_state.go similarity index 65% rename from vestack/ecs/ecs_instance_state/resource_vestack_ecs_instance_state.go rename to volcengine/ecs/ecs_instance_state/resource_volcengine_ecs_instance_state.go index 6d69aeed..d0315d4c 100644 --- a/vestack/ecs/ecs_instance_state/resource_vestack_ecs_instance_state.go +++ b/volcengine/ecs/ecs_instance_state/resource_volcengine_ecs_instance_state.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -13,17 +13,17 @@ import ( Import State Instance can be imported using the id, e.g. ``` -$ terraform import vestack_ecs_instance_state.default state:i-mizl7m1kqccg5smt1bdpijuj +$ terraform import volcengine_ecs_instance_state.default state:i-mizl7m1kqccg5smt1bdpijuj ``` */ -func ResourceVestackEcsInstanceState() *schema.Resource { +func ResourceVolcengineEcsInstanceState() *schema.Resource { return &schema.Resource{ - Delete: resourceVestackEcsInstanceStateDelete, - Create: resourceVestackEcsInstanceStateCreate, - Read: resourceVestackEcsInstanceStateRead, - Update: resourceVestackEcsInstanceStateUpdate, + Delete: resourceVolcengineEcsInstanceStateDelete, + Create: resourceVolcengineEcsInstanceStateCreate, + Read: resourceVolcengineEcsInstanceStateRead, + Update: resourceVolcengineEcsInstanceStateUpdate, Importer: &schema.ResourceImporter{ State: ecsInstanceStateImporter, }, @@ -62,33 +62,33 @@ func ResourceVestackEcsInstanceState() *schema.Resource { } } -func resourceVestackEcsInstanceStateCreate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineEcsInstanceStateCreate(d *schema.ResourceData, meta interface{}) error { instanceStateService := NewInstanceStateService(meta.(*ve.SdkClient)) - if err := instanceStateService.Dispatcher.Create(instanceStateService, d, ResourceVestackEcsInstanceState()); err != nil { + if err := instanceStateService.Dispatcher.Create(instanceStateService, d, ResourceVolcengineEcsInstanceState()); err != nil { return fmt.Errorf("error on creating instance state %q, %w", d.Id(), err) } - return resourceVestackEcsInstanceStateRead(d, meta) + return resourceVolcengineEcsInstanceStateRead(d, meta) } -func resourceVestackEcsInstanceStateRead(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineEcsInstanceStateRead(d *schema.ResourceData, meta interface{}) error { instanceStateService := NewInstanceStateService(meta.(*ve.SdkClient)) - if err := instanceStateService.Dispatcher.Read(instanceStateService, d, ResourceVestackEcsInstanceState()); err != nil { + if err := instanceStateService.Dispatcher.Read(instanceStateService, d, ResourceVolcengineEcsInstanceState()); err != nil { return fmt.Errorf("error on reading instance state %q, %w", d.Id(), err) } return nil } -func resourceVestackEcsInstanceStateUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineEcsInstanceStateUpdate(d *schema.ResourceData, meta interface{}) error { instanceStateService := NewInstanceStateService(meta.(*ve.SdkClient)) - if err := instanceStateService.Dispatcher.Update(instanceStateService, d, ResourceVestackEcsInstanceState()); err != nil { + if err := instanceStateService.Dispatcher.Update(instanceStateService, d, ResourceVolcengineEcsInstanceState()); err != nil { return fmt.Errorf("error on updating instance state %q, %w", d.Id(), err) } - return resourceVestackEcsInstanceStateRead(d, meta) + return resourceVolcengineEcsInstanceStateRead(d, meta) } -func resourceVestackEcsInstanceStateDelete(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineEcsInstanceStateDelete(d *schema.ResourceData, meta interface{}) error { instanceStateService := NewInstanceStateService(meta.(*ve.SdkClient)) - if err := instanceStateService.Dispatcher.Delete(instanceStateService, d, ResourceVestackEcsInstanceState()); err != nil { + if err := instanceStateService.Dispatcher.Delete(instanceStateService, d, ResourceVolcengineEcsInstanceState()); err != nil { return fmt.Errorf("error on deleting instance state %q, %w", d.Id(), err) } return nil diff --git a/vestack/ecs/ecs_instance_state/service_vestack_ecs_instance_state.go b/volcengine/ecs/ecs_instance_state/service_volcengine_ecs_instance_state.go similarity index 80% rename from vestack/ecs/ecs_instance_state/service_vestack_ecs_instance_state.go rename to volcengine/ecs/ecs_instance_state/service_volcengine_ecs_instance_state.go index 04eab65d..5a60afe0 100644 --- a/vestack/ecs/ecs_instance_state/service_vestack_ecs_instance_state.go +++ b/volcengine/ecs/ecs_instance_state/service_volcengine_ecs_instance_state.go @@ -8,27 +8,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackInstanceStateService struct { +type VolcengineInstanceStateService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewInstanceStateService(c *ve.SdkClient) *VestackInstanceStateService { - return &VestackInstanceStateService{ +func NewInstanceStateService(c *ve.SdkClient) *VolcengineInstanceStateService { + return &VolcengineInstanceStateService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackInstanceStateService) GetClient() *ve.SdkClient { +func (s *VolcengineInstanceStateService) GetClient() *ve.SdkClient { return s.Client } -func (VestackInstanceStateService) WithResourceResponseHandlers(subnet map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineInstanceStateService) WithResourceResponseHandlers(subnet map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return subnet, nil, nil } @@ -36,7 +36,7 @@ func (VestackInstanceStateService) WithResourceResponseHandlers(subnet map[strin } -func (s *VestackInstanceStateService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineInstanceStateService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { var action string targetStatus := []string{"RUNNING"} instanceAction := resourceData.Get("action").(string) @@ -86,7 +86,7 @@ func (s *VestackInstanceStateService) CreateResource(resourceData *schema.Resour return []ve.Callback{callback} } -func (s *VestackInstanceStateService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineInstanceStateService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -123,7 +123,7 @@ func (s *VestackInstanceStateService) ReadResources(condition map[string]interfa }) } -func (s *VestackInstanceStateService) ReadResource(resourceData *schema.ResourceData, tmpId string) (data map[string]interface{}, err error) { +func (s *VolcengineInstanceStateService) ReadResource(resourceData *schema.ResourceData, tmpId string) (data map[string]interface{}, err error) { var ( ok bool ) @@ -165,7 +165,7 @@ func (s *VestackInstanceStateService) ReadResource(resourceData *schema.Resource return data, nil } -func (s *VestackInstanceStateService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineInstanceStateService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -200,7 +200,7 @@ func (s *VestackInstanceStateService) RefreshResourceState(resourceData *schema. } } -func (s *VestackInstanceStateService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineInstanceStateService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { var action string targetStatus := []string{"RUNNING"} instanceAction := resourceData.Get("action").(string) @@ -246,15 +246,15 @@ func (s *VestackInstanceStateService) ModifyResource(resourceData *schema.Resour return []ve.Callback{callback} } -func (s *VestackInstanceStateService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineInstanceStateService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { return []ve.Callback{} } -func (s *VestackInstanceStateService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineInstanceStateService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{} } -func (s *VestackInstanceStateService) ReadResourceId(id string) string { +func (s *VolcengineInstanceStateService) ReadResourceId(id string) string { items := strings.Split(id, ":") return items[1] } diff --git a/vestack/ecs/image/data_source_vestack_images.go b/volcengine/ecs/image/data_source_volcengine_images.go similarity index 94% rename from vestack/ecs/image/data_source_vestack_images.go rename to volcengine/ecs/image/data_source_volcengine_images.go index e97d5889..b158da1f 100644 --- a/vestack/ecs/image/data_source_vestack_images.go +++ b/volcengine/ecs/image/data_source_volcengine_images.go @@ -3,12 +3,12 @@ package image import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackImages() *schema.Resource { +func DataSourceVolcengineImages() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackImagesRead, + Read: dataSourceVolcengineImagesRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -154,7 +154,7 @@ func DataSourceVestackImages() *schema.Resource { } } -func dataSourceVestackImagesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineImagesRead(d *schema.ResourceData, meta interface{}) error { imageService := NewImageService(meta.(*ve.SdkClient)) - return imageService.Dispatcher.Data(imageService, d, DataSourceVestackImages()) + return imageService.Dispatcher.Data(imageService, d, DataSourceVolcengineImages()) } diff --git a/vestack/ecs/image/service_vestack_image.go b/volcengine/ecs/image/service_volcengine_image.go similarity index 63% rename from vestack/ecs/image/service_vestack_image.go rename to volcengine/ecs/image/service_volcengine_image.go index cdffe41e..e1ef5140 100644 --- a/vestack/ecs/image/service_vestack_image.go +++ b/volcengine/ecs/image/service_volcengine_image.go @@ -7,27 +7,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackImageService struct { +type VolcengineImageService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewImageService(c *ve.SdkClient) *VestackImageService { - return &VestackImageService{ +func NewImageService(c *ve.SdkClient) *VolcengineImageService { + return &VolcengineImageService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackImageService) GetClient() *ve.SdkClient { +func (s *VolcengineImageService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackImageService) ReadResources(condition map[string]interface{}) ([]interface{}, error) { +func (s *VolcengineImageService) ReadResources(condition map[string]interface{}) ([]interface{}, error) { var ( resp *map[string]interface{} results interface{} @@ -71,7 +71,7 @@ func (s *VestackImageService) ReadResources(condition map[string]interface{}) ([ }) } -func (s *VestackImageService) ReadResource(resourceData *schema.ResourceData, imageId string) (data map[string]interface{}, err error) { +func (s *VolcengineImageService) ReadResource(resourceData *schema.ResourceData, imageId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -98,30 +98,30 @@ func (s *VestackImageService) ReadResource(resourceData *schema.ResourceData, im return data, err } -func (s *VestackImageService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineImageService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return nil } -func (s *VestackImageService) WithResourceResponseHandlers(image map[string]interface{}) []ve.ResourceResponseHandler { +func (s *VolcengineImageService) WithResourceResponseHandlers(image map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return image, nil, nil } return []ve.ResourceResponseHandler{handler} } -func (s *VestackImageService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineImageService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { return []ve.Callback{} } -func (s *VestackImageService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineImageService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { return []ve.Callback{} } -func (s *VestackImageService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineImageService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { return []ve.Callback{} } -func (s *VestackImageService) DatasourceResources(data *schema.ResourceData, resource *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineImageService) DatasourceResources(data *schema.ResourceData, resource *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -135,6 +135,6 @@ func (s *VestackImageService) DatasourceResources(data *schema.ResourceData, res } } -func (s *VestackImageService) ReadResourceId(id string) string { +func (s *VolcengineImageService) ReadResourceId(id string) string { return id } diff --git a/vestack/ecs/zone/data_source_vestack_zones.go b/volcengine/ecs/zone/data_source_volcengine_zones.go similarity index 78% rename from vestack/ecs/zone/data_source_vestack_zones.go rename to volcengine/ecs/zone/data_source_volcengine_zones.go index 81ff8e69..b2fc7089 100644 --- a/vestack/ecs/zone/data_source_vestack_zones.go +++ b/volcengine/ecs/zone/data_source_volcengine_zones.go @@ -2,12 +2,12 @@ package zone import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackZones() *schema.Resource { +func DataSourceVolcengineZones() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackZonesRead, + Read: dataSourceVolcengineZonesRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -53,7 +53,7 @@ func DataSourceVestackZones() *schema.Resource { } } -func dataSourceVestackZonesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineZonesRead(d *schema.ResourceData, meta interface{}) error { zoneService := NewZoneService(meta.(*ve.SdkClient)) - return zoneService.Dispatcher.Data(zoneService, d, DataSourceVestackZones()) + return zoneService.Dispatcher.Data(zoneService, d, DataSourceVolcengineZones()) } diff --git a/vestack/ecs/zone/service_vestack_zone.go b/volcengine/ecs/zone/service_volcengine_zone.go similarity index 57% rename from vestack/ecs/zone/service_vestack_zone.go rename to volcengine/ecs/zone/service_volcengine_zone.go index 78cce10d..1cddb21b 100644 --- a/vestack/ecs/zone/service_vestack_zone.go +++ b/volcengine/ecs/zone/service_volcengine_zone.go @@ -6,27 +6,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackZoneService struct { +type VolcengineZoneService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewZoneService(c *ve.SdkClient) *VestackZoneService { - return &VestackZoneService{ +func NewZoneService(c *ve.SdkClient) *VolcengineZoneService { + return &VolcengineZoneService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackZoneService) GetClient() *ve.SdkClient { +func (s *VolcengineZoneService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackZoneService) ReadResources(condition map[string]interface{}) ([]interface{}, error) { +func (s *VolcengineZoneService) ReadResources(condition map[string]interface{}) ([]interface{}, error) { var ( resp *map[string]interface{} results interface{} @@ -62,11 +62,11 @@ func (s *VestackZoneService) ReadResources(condition map[string]interface{}) ([] return data, nil } -func (s *VestackZoneService) ReadResource(resourceData *schema.ResourceData, id string) (data map[string]interface{}, err error) { +func (s *VolcengineZoneService) ReadResource(resourceData *schema.ResourceData, id string) (data map[string]interface{}, err error) { return nil, nil } -func (s *VestackZoneService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineZoneService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 5 * time.Second, @@ -79,26 +79,26 @@ func (s *VestackZoneService) RefreshResourceState(resourceData *schema.ResourceD } } -func (s *VestackZoneService) WithResourceResponseHandlers(zone map[string]interface{}) []ve.ResourceResponseHandler { +func (s *VolcengineZoneService) WithResourceResponseHandlers(zone map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return zone, nil, nil } return []ve.ResourceResponseHandler{handler} } -func (s *VestackZoneService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineZoneService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { return []ve.Callback{} } -func (s *VestackZoneService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) (callbacks []ve.Callback) { +func (s *VolcengineZoneService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) (callbacks []ve.Callback) { return callbacks } -func (s *VestackZoneService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineZoneService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { return []ve.Callback{} } -func (s *VestackZoneService) DatasourceResources(data *schema.ResourceData, resource *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineZoneService) DatasourceResources(data *schema.ResourceData, resource *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -118,6 +118,6 @@ func (s *VestackZoneService) DatasourceResources(data *schema.ResourceData, reso } } -func (s *VestackZoneService) ReadResourceId(id string) string { +func (s *VolcengineZoneService) ReadResourceId(id string) string { return id } diff --git a/vestack/eip/eip_address/common_vestack_eip_address.go b/volcengine/eip/eip_address/common_volcengine_eip_address.go similarity index 100% rename from vestack/eip/eip_address/common_vestack_eip_address.go rename to volcengine/eip/eip_address/common_volcengine_eip_address.go diff --git a/vestack/eip/eip_address/data_source_vestack_eip_addresses.go b/volcengine/eip/eip_address/data_source_volcengine_eip_addresses.go similarity index 94% rename from vestack/eip/eip_address/data_source_vestack_eip_addresses.go rename to volcengine/eip/eip_address/data_source_volcengine_eip_addresses.go index 5d12fc80..f5a56096 100644 --- a/vestack/eip/eip_address/data_source_vestack_eip_addresses.go +++ b/volcengine/eip/eip_address/data_source_volcengine_eip_addresses.go @@ -3,12 +3,12 @@ package eip_address import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackEipAddresses() *schema.Resource { +func DataSourceVolcengineEipAddresses() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackEipAddressesRead, + Read: dataSourceVolcengineEipAddressesRead, Schema: map[string]*schema.Schema{ "status": { Type: schema.TypeString, @@ -170,7 +170,7 @@ func DataSourceVestackEipAddresses() *schema.Resource { } } -func dataSourceVestackEipAddressesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineEipAddressesRead(d *schema.ResourceData, meta interface{}) error { eipAddressService := NewEipAddressService(meta.(*ve.SdkClient)) - return eipAddressService.Dispatcher.Data(eipAddressService, d, DataSourceVestackEipAddresses()) + return eipAddressService.Dispatcher.Data(eipAddressService, d, DataSourceVolcengineEipAddresses()) } diff --git a/vestack/eip/eip_address/resource_vestack_eip_address.go b/volcengine/eip/eip_address/resource_volcengine_eip_address.go similarity index 71% rename from vestack/eip/eip_address/resource_vestack_eip_address.go rename to volcengine/eip/eip_address/resource_volcengine_eip_address.go index b53104c7..a77ab5cb 100644 --- a/vestack/eip/eip_address/resource_vestack_eip_address.go +++ b/volcengine/eip/eip_address/resource_volcengine_eip_address.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -13,17 +13,17 @@ import ( Import Eip address can be imported using the id, e.g. ``` -$ terraform import vestack_eip_address.default eip-274oj9a8rs9a87fap8sf9515b +$ terraform import volcengine_eip_address.default eip-274oj9a8rs9a87fap8sf9515b ``` */ -func ResourceVestackEipAddress() *schema.Resource { +func ResourceVolcengineEipAddress() *schema.Resource { return &schema.Resource{ - Delete: resourceVestackEipAddressDelete, - Create: resourceVestackEipAddressCreate, - Read: resourceVestackEipAddressRead, - Update: resourceVestackEipAddressUpdate, + Delete: resourceVolcengineEipAddressDelete, + Create: resourceVolcengineEipAddressCreate, + Read: resourceVolcengineEipAddressRead, + Update: resourceVolcengineEipAddressUpdate, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -74,33 +74,33 @@ func ResourceVestackEipAddress() *schema.Resource { } } -func resourceVestackEipAddressCreate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineEipAddressCreate(d *schema.ResourceData, meta interface{}) error { eipAddressService := NewEipAddressService(meta.(*ve.SdkClient)) - if err := eipAddressService.Dispatcher.Create(eipAddressService, d, ResourceVestackEipAddress()); err != nil { + if err := eipAddressService.Dispatcher.Create(eipAddressService, d, ResourceVolcengineEipAddress()); err != nil { return fmt.Errorf("error on creating eip address %q, %w", d.Id(), err) } - return resourceVestackEipAddressRead(d, meta) + return resourceVolcengineEipAddressRead(d, meta) } -func resourceVestackEipAddressRead(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineEipAddressRead(d *schema.ResourceData, meta interface{}) error { eipAddressService := NewEipAddressService(meta.(*ve.SdkClient)) - if err := eipAddressService.Dispatcher.Read(eipAddressService, d, ResourceVestackEipAddress()); err != nil { + if err := eipAddressService.Dispatcher.Read(eipAddressService, d, ResourceVolcengineEipAddress()); err != nil { return fmt.Errorf("error on reading eip address %q, %w", d.Id(), err) } return nil } -func resourceVestackEipAddressUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineEipAddressUpdate(d *schema.ResourceData, meta interface{}) error { eipAddressService := NewEipAddressService(meta.(*ve.SdkClient)) - if err := eipAddressService.Dispatcher.Update(eipAddressService, d, ResourceVestackEipAddress()); err != nil { + if err := eipAddressService.Dispatcher.Update(eipAddressService, d, ResourceVolcengineEipAddress()); err != nil { return fmt.Errorf("error on updating eip address %q, %w", d.Id(), err) } - return resourceVestackEipAddressRead(d, meta) + return resourceVolcengineEipAddressRead(d, meta) } -func resourceVestackEipAddressDelete(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineEipAddressDelete(d *schema.ResourceData, meta interface{}) error { eipAddressService := NewEipAddressService(meta.(*ve.SdkClient)) - if err := eipAddressService.Dispatcher.Delete(eipAddressService, d, ResourceVestackEipAddress()); err != nil { + if err := eipAddressService.Dispatcher.Delete(eipAddressService, d, ResourceVolcengineEipAddress()); err != nil { return fmt.Errorf("error on deleting eip address %q, %w", d.Id(), err) } return nil diff --git a/vestack/eip/eip_address/service_vestack_eip_address.go b/volcengine/eip/eip_address/service_volcengine_eip_address.go similarity index 82% rename from vestack/eip/eip_address/service_vestack_eip_address.go rename to volcengine/eip/eip_address/service_volcengine_eip_address.go index 4d354b16..fdf4b02c 100644 --- a/vestack/eip/eip_address/service_vestack_eip_address.go +++ b/volcengine/eip/eip_address/service_volcengine_eip_address.go @@ -7,27 +7,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackEipAddressService struct { +type VolcengineEipAddressService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewEipAddressService(c *ve.SdkClient) *VestackEipAddressService { - return &VestackEipAddressService{ +func NewEipAddressService(c *ve.SdkClient) *VolcengineEipAddressService { + return &VolcengineEipAddressService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackEipAddressService) GetClient() *ve.SdkClient { +func (s *VolcengineEipAddressService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackEipAddressService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineEipAddressService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -63,7 +63,7 @@ func (s *VestackEipAddressService) ReadResources(m map[string]interface{}) (data }) } -func (s *VestackEipAddressService) ReadResource(resourceData *schema.ResourceData, allocationId string) (data map[string]interface{}, err error) { +func (s *VolcengineEipAddressService) ReadResource(resourceData *schema.ResourceData, allocationId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -92,7 +92,7 @@ func (s *VestackEipAddressService) ReadResource(resourceData *schema.ResourceDat return data, err } -func (s *VestackEipAddressService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineEipAddressService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -125,7 +125,7 @@ func (s *VestackEipAddressService) RefreshResourceState(resourceData *schema.Res } } -func (VestackEipAddressService) WithResourceResponseHandlers(eip map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineEipAddressService) WithResourceResponseHandlers(eip map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return eip, map[string]ve.ResponseConvert{ "BillingType": { @@ -138,7 +138,7 @@ func (VestackEipAddressService) WithResourceResponseHandlers(eip map[string]inte } -func (s *VestackEipAddressService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineEipAddressService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "AllocateEipAddress", @@ -170,7 +170,7 @@ func (s *VestackEipAddressService) CreateResource(resourceData *schema.ResourceD return []ve.Callback{callback} } -func (s *VestackEipAddressService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineEipAddressService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifyEipAddressAttributes", @@ -201,7 +201,7 @@ func (s *VestackEipAddressService) ModifyResource(resourceData *schema.ResourceD return []ve.Callback{callback} } -func (s *VestackEipAddressService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineEipAddressService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "ReleaseEipAddress", @@ -239,7 +239,7 @@ func (s *VestackEipAddressService) RemoveResource(resourceData *schema.ResourceD return []ve.Callback{callback} } -func (s *VestackEipAddressService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineEipAddressService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -273,6 +273,6 @@ func (s *VestackEipAddressService) DatasourceResources(*schema.ResourceData, *sc } } -func (s *VestackEipAddressService) ReadResourceId(id string) string { +func (s *VolcengineEipAddressService) ReadResourceId(id string) string { return id } diff --git a/vestack/eip/eip_associate/common_vestack_eip_associate.go b/volcengine/eip/eip_associate/common_volcengine_eip_associate.go similarity index 100% rename from vestack/eip/eip_associate/common_vestack_eip_associate.go rename to volcengine/eip/eip_associate/common_volcengine_eip_associate.go diff --git a/vestack/eip/eip_associate/resource_vestack_eip_associate.go b/volcengine/eip/eip_associate/resource_volcengine_eip_associate.go similarity index 66% rename from vestack/eip/eip_associate/resource_vestack_eip_associate.go rename to volcengine/eip/eip_associate/resource_volcengine_eip_associate.go index 515ada1b..64f2c884 100644 --- a/vestack/eip/eip_associate/resource_vestack_eip_associate.go +++ b/volcengine/eip/eip_associate/resource_volcengine_eip_associate.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -12,16 +12,16 @@ import ( Import Eip associate can be imported using the eip allocation_id:instance_id, e.g. ``` -$ terraform import vestack_eip_associate.default eip-274oj9a8rs9a87fap8sf9515b:i-cm9t9ug9lggu79yr5tcw +$ terraform import volcengine_eip_associate.default eip-274oj9a8rs9a87fap8sf9515b:i-cm9t9ug9lggu79yr5tcw ``` */ -func ResourceVestackEipAssociate() *schema.Resource { +func ResourceVolcengineEipAssociate() *schema.Resource { return &schema.Resource{ - Delete: resourceVestackEipAssociateDelete, - Create: resourceVestackEipAssociateCreate, - Read: resourceVestackEipAssociateRead, + Delete: resourceVolcengineEipAssociateDelete, + Create: resourceVolcengineEipAssociateCreate, + Read: resourceVolcengineEipAssociateRead, Importer: &schema.ResourceImporter{ State: eipAssociateImporter, }, @@ -55,25 +55,25 @@ func ResourceVestackEipAssociate() *schema.Resource { } } -func resourceVestackEipAssociateCreate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineEipAssociateCreate(d *schema.ResourceData, meta interface{}) error { eipAssociateService := NewEipAssociateService(meta.(*ve.SdkClient)) - if err := eipAssociateService.Dispatcher.Create(eipAssociateService, d, ResourceVestackEipAssociate()); err != nil { + if err := eipAssociateService.Dispatcher.Create(eipAssociateService, d, ResourceVolcengineEipAssociate()); err != nil { return fmt.Errorf("error on creating eip associate %q, %w", d.Id(), err) } - return resourceVestackEipAssociateRead(d, meta) + return resourceVolcengineEipAssociateRead(d, meta) } -func resourceVestackEipAssociateRead(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineEipAssociateRead(d *schema.ResourceData, meta interface{}) error { eipAssociateService := NewEipAssociateService(meta.(*ve.SdkClient)) - if err := eipAssociateService.Dispatcher.Read(eipAssociateService, d, ResourceVestackEipAssociate()); err != nil { + if err := eipAssociateService.Dispatcher.Read(eipAssociateService, d, ResourceVolcengineEipAssociate()); err != nil { return fmt.Errorf("error on reading eip associate %q, %w", d.Id(), err) } return nil } -func resourceVestackEipAssociateDelete(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineEipAssociateDelete(d *schema.ResourceData, meta interface{}) error { eipAssociateService := NewEipAssociateService(meta.(*ve.SdkClient)) - if err := eipAssociateService.Dispatcher.Delete(eipAssociateService, d, ResourceVestackEipAssociate()); err != nil { + if err := eipAssociateService.Dispatcher.Delete(eipAssociateService, d, ResourceVolcengineEipAssociate()); err != nil { return fmt.Errorf("error on deleting eip associate %q, %w", d.Id(), err) } return nil diff --git a/vestack/eip/eip_associate/service_vestack_eip_associate.go b/volcengine/eip/eip_associate/service_volcengine_eip_associate.go similarity index 76% rename from vestack/eip/eip_associate/service_vestack_eip_associate.go rename to volcengine/eip/eip_associate/service_volcengine_eip_associate.go index c18a6d9b..388458d0 100644 --- a/vestack/eip/eip_associate/service_vestack_eip_associate.go +++ b/volcengine/eip/eip_associate/service_volcengine_eip_associate.go @@ -8,31 +8,31 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackEipAssociateService struct { +type VolcengineEipAssociateService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewEipAssociateService(c *ve.SdkClient) *VestackEipAssociateService { - return &VestackEipAssociateService{ +func NewEipAssociateService(c *ve.SdkClient) *VolcengineEipAssociateService { + return &VolcengineEipAssociateService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackEipAssociateService) GetClient() *ve.SdkClient { +func (s *VolcengineEipAssociateService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackEipAssociateService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineEipAssociateService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { return nil, nil } -func (s *VestackEipAssociateService) ReadResource(resourceData *schema.ResourceData, tmpId string) (data map[string]interface{}, err error) { +func (s *VolcengineEipAssociateService) ReadResource(resourceData *schema.ResourceData, tmpId string) (data map[string]interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -85,7 +85,7 @@ func (s *VestackEipAssociateService) ReadResource(resourceData *schema.ResourceD return data, err } -func (s *VestackEipAssociateService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineEipAssociateService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -118,7 +118,7 @@ func (s *VestackEipAssociateService) RefreshResourceState(resourceData *schema.R } } -func (VestackEipAssociateService) WithResourceResponseHandlers(eip map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineEipAssociateService) WithResourceResponseHandlers(eip map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return eip, nil, nil } @@ -126,7 +126,7 @@ func (VestackEipAssociateService) WithResourceResponseHandlers(eip map[string]in } -func (s *VestackEipAssociateService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineEipAssociateService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "AssociateEipAddress", @@ -148,11 +148,11 @@ func (s *VestackEipAssociateService) CreateResource(resourceData *schema.Resourc return []ve.Callback{callback} } -func (s *VestackEipAssociateService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineEipAssociateService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { return nil } -func (s *VestackEipAssociateService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineEipAssociateService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { ids := strings.Split(s.ReadResourceId(resourceData.Id()), ":") callback := ve.Callback{ Call: ve.SdkCall{ @@ -193,10 +193,10 @@ func (s *VestackEipAssociateService) RemoveResource(resourceData *schema.Resourc return []ve.Callback{callback} } -func (s *VestackEipAssociateService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineEipAssociateService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{} } -func (s *VestackEipAssociateService) ReadResourceId(id string) string { +func (s *VolcengineEipAssociateService) ReadResourceId(id string) string { return id } diff --git a/vestack/nat/nat_gateway/data_source_vestack_nat_gateways.go b/volcengine/nat/nat_gateway/data_source_volcengine_nat_gateways.go similarity index 94% rename from vestack/nat/nat_gateway/data_source_vestack_nat_gateways.go rename to volcengine/nat/nat_gateway/data_source_volcengine_nat_gateways.go index b7a61430..36a04664 100644 --- a/vestack/nat/nat_gateway/data_source_vestack_nat_gateways.go +++ b/volcengine/nat/nat_gateway/data_source_volcengine_nat_gateways.go @@ -3,12 +3,12 @@ package nat_gateway import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackNatGateways() *schema.Resource { +func DataSourceVolcengineNatGateways() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackNatGatewaysRead, + Read: dataSourceVolcengineNatGatewaysRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -179,7 +179,7 @@ func DataSourceVestackNatGateways() *schema.Resource { } } -func dataSourceVestackNatGatewaysRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineNatGatewaysRead(d *schema.ResourceData, meta interface{}) error { natGatewayService := NewNatGatewayService(meta.(*ve.SdkClient)) - return natGatewayService.Dispatcher.Data(natGatewayService, d, DataSourceVestackNatGateways()) + return natGatewayService.Dispatcher.Data(natGatewayService, d, DataSourceVolcengineNatGateways()) } diff --git a/vestack/nat/nat_gateway/resource_vestack_nat_gateway.go b/volcengine/nat/nat_gateway/resource_volcengine_nat_gateway.go similarity index 75% rename from vestack/nat/nat_gateway/resource_vestack_nat_gateway.go rename to volcengine/nat/nat_gateway/resource_volcengine_nat_gateway.go index e42b888b..6a876257 100644 --- a/vestack/nat/nat_gateway/resource_vestack_nat_gateway.go +++ b/volcengine/nat/nat_gateway/resource_volcengine_nat_gateway.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -13,17 +13,17 @@ import ( Import NatGateway can be imported using the id, e.g. ``` -$ terraform import vestack_nat_gateway.default ngw-vv3t043k05sm**** +$ terraform import volcengine_nat_gateway.default ngw-vv3t043k05sm**** ``` */ -func ResourceVestackNatGateway() *schema.Resource { +func ResourceVolcengineNatGateway() *schema.Resource { return &schema.Resource{ - Create: resourceVestackNatGatewayCreate, - Read: resourceVestackNatGatewayRead, - Update: resourceVestackNatGatewayUpdate, - Delete: resourceVestackNatGatewayDelete, + Create: resourceVolcengineNatGatewayCreate, + Read: resourceVolcengineNatGatewayRead, + Update: resourceVolcengineNatGatewayUpdate, + Delete: resourceVolcengineNatGatewayDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -86,36 +86,36 @@ func ResourceVestackNatGateway() *schema.Resource { } } -func resourceVestackNatGatewayCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineNatGatewayCreate(d *schema.ResourceData, meta interface{}) (err error) { natGatewayService := NewNatGatewayService(meta.(*ve.SdkClient)) - err = natGatewayService.Dispatcher.Create(natGatewayService, d, ResourceVestackNatGateway()) + err = natGatewayService.Dispatcher.Create(natGatewayService, d, ResourceVolcengineNatGateway()) if err != nil { return fmt.Errorf("error on creating nat gateway %q, %w", d.Id(), err) } - return resourceVestackNatGatewayRead(d, meta) + return resourceVolcengineNatGatewayRead(d, meta) } -func resourceVestackNatGatewayRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineNatGatewayRead(d *schema.ResourceData, meta interface{}) (err error) { natGatewayService := NewNatGatewayService(meta.(*ve.SdkClient)) - err = natGatewayService.Dispatcher.Read(natGatewayService, d, ResourceVestackNatGateway()) + err = natGatewayService.Dispatcher.Read(natGatewayService, d, ResourceVolcengineNatGateway()) if err != nil { return fmt.Errorf("error on reading nat gateway %q, %w", d.Id(), err) } return err } -func resourceVestackNatGatewayUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineNatGatewayUpdate(d *schema.ResourceData, meta interface{}) (err error) { natGatewayService := NewNatGatewayService(meta.(*ve.SdkClient)) - err = natGatewayService.Dispatcher.Update(natGatewayService, d, ResourceVestackNatGateway()) + err = natGatewayService.Dispatcher.Update(natGatewayService, d, ResourceVolcengineNatGateway()) if err != nil { return fmt.Errorf("error on updating nat gateway %q, %w", d.Id(), err) } - return resourceVestackNatGatewayRead(d, meta) + return resourceVolcengineNatGatewayRead(d, meta) } -func resourceVestackNatGatewayDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineNatGatewayDelete(d *schema.ResourceData, meta interface{}) (err error) { natGatewayService := NewNatGatewayService(meta.(*ve.SdkClient)) - err = natGatewayService.Dispatcher.Delete(natGatewayService, d, ResourceVestackNatGateway()) + err = natGatewayService.Dispatcher.Delete(natGatewayService, d, ResourceVolcengineNatGateway()) if err != nil { return fmt.Errorf("error on deleting nat gateway %q, %w", d.Id(), err) } diff --git a/vestack/nat/nat_gateway/service_vestack_nat_gateway.go b/volcengine/nat/nat_gateway/service_volcengine_nat_gateway.go similarity index 84% rename from vestack/nat/nat_gateway/service_vestack_nat_gateway.go rename to volcengine/nat/nat_gateway/service_volcengine_nat_gateway.go index 0d58e7bb..52f4231d 100644 --- a/vestack/nat/nat_gateway/service_vestack_nat_gateway.go +++ b/volcengine/nat/nat_gateway/service_volcengine_nat_gateway.go @@ -7,27 +7,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackNatGatewayService struct { +type VolcengineNatGatewayService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewNatGatewayService(c *ve.SdkClient) *VestackNatGatewayService { - return &VestackNatGatewayService{ +func NewNatGatewayService(c *ve.SdkClient) *VolcengineNatGatewayService { + return &VolcengineNatGatewayService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackNatGatewayService) GetClient() *ve.SdkClient { +func (s *VolcengineNatGatewayService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackNatGatewayService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineNatGatewayService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -63,7 +63,7 @@ func (s *VestackNatGatewayService) ReadResources(condition map[string]interface{ }) } -func (s *VestackNatGatewayService) ReadResource(resourceData *schema.ResourceData, natGatewayId string) (data map[string]interface{}, err error) { +func (s *VolcengineNatGatewayService) ReadResource(resourceData *schema.ResourceData, natGatewayId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -105,7 +105,7 @@ func (s *VestackNatGatewayService) ReadResource(resourceData *schema.ResourceDat return data, err } -func (s *VestackNatGatewayService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineNatGatewayService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 3 * time.Second, @@ -133,7 +133,7 @@ func (s *VestackNatGatewayService) RefreshResourceState(resourceData *schema.Res } -func (VestackNatGatewayService) WithResourceResponseHandlers(natGateway map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineNatGatewayService) WithResourceResponseHandlers(natGateway map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return natGateway, map[string]ve.ResponseConvert{ "BillingType": { @@ -158,7 +158,7 @@ func (VestackNatGatewayService) WithResourceResponseHandlers(natGateway map[stri } -func (s *VestackNatGatewayService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineNatGatewayService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "CreateNatGateway", @@ -202,7 +202,7 @@ func (s *VestackNatGatewayService) CreateResource(resourceData *schema.ResourceD } -func (s *VestackNatGatewayService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineNatGatewayService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifyNatGatewayAttributes", @@ -243,7 +243,7 @@ func (s *VestackNatGatewayService) ModifyResource(resourceData *schema.ResourceD return []ve.Callback{callback} } -func (s *VestackNatGatewayService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineNatGatewayService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { id := resourceData.Id() callback := ve.Callback{ Call: ve.SdkCall{ @@ -296,7 +296,7 @@ func (s *VestackNatGatewayService) RemoveResource(resourceData *schema.ResourceD return []ve.Callback{callback} } -func (s *VestackNatGatewayService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineNatGatewayService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -332,6 +332,6 @@ func (s *VestackNatGatewayService) DatasourceResources(*schema.ResourceData, *sc } } -func (s *VestackNatGatewayService) ReadResourceId(id string) string { +func (s *VolcengineNatGatewayService) ReadResourceId(id string) string { return id } diff --git a/vestack/nat/snat_entry/data_source_vestack_snat_entries.go b/volcengine/nat/snat_entry/data_source_volcengine_snat_entries.go similarity index 90% rename from vestack/nat/snat_entry/data_source_vestack_snat_entries.go rename to volcengine/nat/snat_entry/data_source_volcengine_snat_entries.go index 58faef9e..530bb86f 100644 --- a/vestack/nat/snat_entry/data_source_vestack_snat_entries.go +++ b/volcengine/nat/snat_entry/data_source_volcengine_snat_entries.go @@ -2,12 +2,12 @@ package snat_entry import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackSnatEntries() *schema.Resource { +func DataSourceVolcengineSnatEntries() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackSnatEntriesRead, + Read: dataSourceVolcengineSnatEntriesRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -102,7 +102,7 @@ func DataSourceVestackSnatEntries() *schema.Resource { } } -func dataSourceVestackSnatEntriesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineSnatEntriesRead(d *schema.ResourceData, meta interface{}) error { snatEntryService := NewSnatEntryService(meta.(*ve.SdkClient)) - return snatEntryService.Dispatcher.Data(snatEntryService, d, DataSourceVestackSnatEntries()) + return snatEntryService.Dispatcher.Data(snatEntryService, d, DataSourceVolcengineSnatEntries()) } diff --git a/vestack/nat/snat_entry/resource_vestack_snat_entry.go b/volcengine/nat/snat_entry/resource_volcengine_snat_entry.go similarity index 66% rename from vestack/nat/snat_entry/resource_vestack_snat_entry.go rename to volcengine/nat/snat_entry/resource_volcengine_snat_entry.go index 18b48f49..7f9b1e66 100644 --- a/vestack/nat/snat_entry/resource_vestack_snat_entry.go +++ b/volcengine/nat/snat_entry/resource_volcengine_snat_entry.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -12,17 +12,17 @@ import ( Import Snat entry can be imported using the id, e.g. ``` -$ terraform import vestack_snat_entry.default snat-3fvhk47kf56**** +$ terraform import volcengine_snat_entry.default snat-3fvhk47kf56**** ``` */ -func ResourceVestackSnatEntry() *schema.Resource { +func ResourceVolcengineSnatEntry() *schema.Resource { return &schema.Resource{ - Delete: resourceVestackSnatEntryDelete, - Create: resourceVestackSnatEntryCreate, - Read: resourceVestackSnatEntryRead, - Update: resourceVestackSnatEntryUpdate, + Delete: resourceVolcengineSnatEntryDelete, + Create: resourceVolcengineSnatEntryCreate, + Read: resourceVolcengineSnatEntryRead, + Update: resourceVolcengineSnatEntryUpdate, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -59,33 +59,33 @@ func ResourceVestackSnatEntry() *schema.Resource { } } -func resourceVestackSnatEntryCreate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineSnatEntryCreate(d *schema.ResourceData, meta interface{}) error { snatEntryService := NewSnatEntryService(meta.(*ve.SdkClient)) - if err := snatEntryService.Dispatcher.Create(snatEntryService, d, ResourceVestackSnatEntry()); err != nil { + if err := snatEntryService.Dispatcher.Create(snatEntryService, d, ResourceVolcengineSnatEntry()); err != nil { return fmt.Errorf("error on creating snat entry %q, %w", d.Id(), err) } - return resourceVestackSnatEntryRead(d, meta) + return resourceVolcengineSnatEntryRead(d, meta) } -func resourceVestackSnatEntryRead(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineSnatEntryRead(d *schema.ResourceData, meta interface{}) error { snatEntryService := NewSnatEntryService(meta.(*ve.SdkClient)) - if err := snatEntryService.Dispatcher.Read(snatEntryService, d, ResourceVestackSnatEntry()); err != nil { + if err := snatEntryService.Dispatcher.Read(snatEntryService, d, ResourceVolcengineSnatEntry()); err != nil { return fmt.Errorf("error on reading snat entry %q, %w", d.Id(), err) } return nil } -func resourceVestackSnatEntryUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineSnatEntryUpdate(d *schema.ResourceData, meta interface{}) error { snatEntryService := NewSnatEntryService(meta.(*ve.SdkClient)) - if err := snatEntryService.Dispatcher.Update(snatEntryService, d, ResourceVestackSnatEntry()); err != nil { + if err := snatEntryService.Dispatcher.Update(snatEntryService, d, ResourceVolcengineSnatEntry()); err != nil { return fmt.Errorf("error on updating snat entry %q, %w", d.Id(), err) } - return resourceVestackSnatEntryRead(d, meta) + return resourceVolcengineSnatEntryRead(d, meta) } -func resourceVestackSnatEntryDelete(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineSnatEntryDelete(d *schema.ResourceData, meta interface{}) error { snatEntryService := NewSnatEntryService(meta.(*ve.SdkClient)) - if err := snatEntryService.Dispatcher.Delete(snatEntryService, d, ResourceVestackSnatEntry()); err != nil { + if err := snatEntryService.Dispatcher.Delete(snatEntryService, d, ResourceVolcengineSnatEntry()); err != nil { return fmt.Errorf("error on deleting snat entry %q, %w", d.Id(), err) } return nil diff --git a/vestack/nat/snat_entry/service_vestack_snat_entry.go b/volcengine/nat/snat_entry/service_volcengine_snat_entry.go similarity index 80% rename from vestack/nat/snat_entry/service_vestack_snat_entry.go rename to volcengine/nat/snat_entry/service_volcengine_snat_entry.go index be245da8..145bb2b7 100644 --- a/vestack/nat/snat_entry/service_vestack_snat_entry.go +++ b/volcengine/nat/snat_entry/service_volcengine_snat_entry.go @@ -7,27 +7,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackSnatEntryService struct { +type VolcengineSnatEntryService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewSnatEntryService(c *ve.SdkClient) *VestackSnatEntryService { - return &VestackSnatEntryService{ +func NewSnatEntryService(c *ve.SdkClient) *VolcengineSnatEntryService { + return &VolcengineSnatEntryService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackSnatEntryService) GetClient() *ve.SdkClient { +func (s *VolcengineSnatEntryService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackSnatEntryService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineSnatEntryService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -63,7 +63,7 @@ func (s *VestackSnatEntryService) ReadResources(m map[string]interface{}) (data }) } -func (s *VestackSnatEntryService) ReadResource(resourceData *schema.ResourceData, id string) (data map[string]interface{}, err error) { +func (s *VolcengineSnatEntryService) ReadResource(resourceData *schema.ResourceData, id string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -89,7 +89,7 @@ func (s *VestackSnatEntryService) ReadResource(resourceData *schema.ResourceData return data, err } -func (s *VestackSnatEntryService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineSnatEntryService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -122,7 +122,7 @@ func (s *VestackSnatEntryService) RefreshResourceState(resourceData *schema.Reso } } -func (VestackSnatEntryService) WithResourceResponseHandlers(snatEntry map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineSnatEntryService) WithResourceResponseHandlers(snatEntry map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return snatEntry, nil, nil } @@ -130,7 +130,7 @@ func (VestackSnatEntryService) WithResourceResponseHandlers(snatEntry map[string } -func (s *VestackSnatEntryService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineSnatEntryService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "CreateSnatEntry", @@ -153,7 +153,7 @@ func (s *VestackSnatEntryService) CreateResource(resourceData *schema.ResourceDa return []ve.Callback{callback} } -func (s *VestackSnatEntryService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineSnatEntryService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifySnatEntryAttributes", @@ -175,7 +175,7 @@ func (s *VestackSnatEntryService) ModifyResource(resourceData *schema.ResourceDa return []ve.Callback{callback} } -func (s *VestackSnatEntryService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineSnatEntryService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "DeleteSnatEntry", @@ -213,7 +213,7 @@ func (s *VestackSnatEntryService) RemoveResource(resourceData *schema.ResourceDa return []ve.Callback{callback} } -func (s *VestackSnatEntryService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineSnatEntryService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -233,6 +233,6 @@ func (s *VestackSnatEntryService) DatasourceResources(*schema.ResourceData, *sch } } -func (s *VestackSnatEntryService) ReadResourceId(id string) string { +func (s *VolcengineSnatEntryService) ReadResourceId(id string) string { return id } diff --git a/volcengine/provider.go b/volcengine/provider.go new file mode 100644 index 00000000..19a40286 --- /dev/null +++ b/volcengine/provider.go @@ -0,0 +1,169 @@ +package volcengine + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/terraform" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/acl" + "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/acl_entry" + "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/certificate" + "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/clb" + "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/listener" + "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/rule" + "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/server_group" + "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/server_group_server" + "github.com/volcengine/terraform-provider-volcengine/volcengine/ebs/volume" + "github.com/volcengine/terraform-provider-volcengine/volcengine/ebs/volume_attach" + "github.com/volcengine/terraform-provider-volcengine/volcengine/ecs/ecs_instance" + "github.com/volcengine/terraform-provider-volcengine/volcengine/ecs/ecs_instance_state" + "github.com/volcengine/terraform-provider-volcengine/volcengine/ecs/image" + "github.com/volcengine/terraform-provider-volcengine/volcengine/ecs/zone" + "github.com/volcengine/terraform-provider-volcengine/volcengine/eip/eip_address" + "github.com/volcengine/terraform-provider-volcengine/volcengine/eip/eip_associate" + "github.com/volcengine/terraform-provider-volcengine/volcengine/nat/nat_gateway" + "github.com/volcengine/terraform-provider-volcengine/volcengine/nat/snat_entry" + "github.com/volcengine/terraform-provider-volcengine/volcengine/tos/bucket" + "github.com/volcengine/terraform-provider-volcengine/volcengine/tos/object" + "github.com/volcengine/terraform-provider-volcengine/volcengine/vpc/network_interface" + "github.com/volcengine/terraform-provider-volcengine/volcengine/vpc/network_interface_attach" + "github.com/volcengine/terraform-provider-volcengine/volcengine/vpc/route_entry" + "github.com/volcengine/terraform-provider-volcengine/volcengine/vpc/route_table" + "github.com/volcengine/terraform-provider-volcengine/volcengine/vpc/route_table_associate" + "github.com/volcengine/terraform-provider-volcengine/volcengine/vpc/security_group" + "github.com/volcengine/terraform-provider-volcengine/volcengine/vpc/security_group_rule" + "github.com/volcengine/terraform-provider-volcengine/volcengine/vpc/subnet" + "github.com/volcengine/terraform-provider-volcengine/volcengine/vpc/vpc" +) + +func Provider() terraform.ResourceProvider { + return &schema.Provider{ + Schema: map[string]*schema.Schema{ + "access_key": { + Type: schema.TypeString, + Required: true, + DefaultFunc: schema.EnvDefaultFunc("VOLCENGINE_ACCESS_KEY", nil), + Description: "The Access Key for Volcengine Provider", + }, + "secret_key": { + Type: schema.TypeString, + Required: true, + DefaultFunc: schema.EnvDefaultFunc("VOLCENGINE_SECRET_KEY", nil), + Description: "The Secret Key for Volcengine Provider", + }, + "session_token": { + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("VOLCENGINE_SESSION_TOKEN", nil), + Description: "The Session Token for Volcengine Provider", + }, + "region": { + Type: schema.TypeString, + Required: true, + DefaultFunc: schema.EnvDefaultFunc("VOLCENGINE_REGION", nil), + Description: "The Region for Volcengine Provider", + }, + "endpoint": { + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("VOLCENGINE_ENDPOINT", nil), + Description: "The Customer Endpoint for Volcengine Provider", + }, + "disable_ssl": { + Type: schema.TypeBool, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("volcengine_DISABLE_SSL", nil), + Description: "Disable SSL for Volcengine Provider", + }, + }, + DataSourcesMap: map[string]*schema.Resource{ + "volcengine_vpcs": vpc.DataSourceVolcengineVpcs(), + "volcengine_subnets": subnet.DataSourceVolcengineSubnets(), + "volcengine_route_tables": route_table.DataSourceVolcengineRouteTables(), + "volcengine_route_entries": route_entry.DataSourceVolcengineRouteEntries(), + "volcengine_security_groups": security_group.DataSourceVolcengineSecurityGroups(), + "volcengine_network_interfaces": network_interface.DataSourceVolcengineNetworkInterfaces(), + + // ================ EIP ================ + "volcengine_eip_addresses": eip_address.DataSourceVolcengineEipAddresses(), + + // ================ CLB ================ + "volcengine_acls": acl.DataSourceVolcengineAcls(), + "volcengine_clbs": clb.DataSourceVolcengineClbs(), + "volcengine_listeners": listener.DataSourceVolcengineListeners(), + "volcengine_server_groups": server_group.DataSourceVolcengineServerGroups(), + "volcengine_certificates": certificate.DataSourceVolcengineCertificates(), + "volcengine_clb_rules": rule.DataSourceVolcengineRules(), + "volcengine_server_group_servers": server_group_server.DataSourceVolcengineServerGroupServers(), + + // ================ EBS ================ + "volcengine_volumes": volume.DataSourceVolcengineVolumes(), + + // ================ ECS ================ + "volcengine_ecs_instances": ecs_instance.DataSourceVolcengineEcsInstances(), + "volcengine_images": image.DataSourceVolcengineImages(), + "volcengine_zones": zone.DataSourceVolcengineZones(), + + // ================ NAT ================ + "volcengine_snat_entries": snat_entry.DataSourceVolcengineSnatEntries(), + "volcengine_nat_gateways": nat_gateway.DataSourceVolcengineNatGateways(), + + // ================ TOS ================ + "volcengine_tos_buckets": bucket.DataSourceVolcengineTosBuckets(), + }, + ResourcesMap: map[string]*schema.Resource{ + "volcengine_vpc": vpc.ResourceVolcengineVpc(), + "volcengine_subnet": subnet.ResourceVolcengineSubnet(), + "volcengine_route_table": route_table.ResourceVolcengineRouteTable(), + "volcengine_route_entry": route_entry.ResourceVolcengineRouteEntry(), + "volcengine_route_table_associate": route_table_associate.ResourceVolcengineRouteTableAssociate(), + "volcengine_security_group": security_group.ResourceVolcengineSecurityGroup(), + "volcengine_network_interface": network_interface.ResourceVolcengineNetworkInterface(), + "volcengine_network_interface_attach": network_interface_attach.ResourceVolcengineNetworkInterfaceAttach(), + "volcengine_security_group_rule": security_group_rule.ResourceVolcengineSecurityGroupRule(), + + // ================ EIP ================ + "volcengine_eip_address": eip_address.ResourceVolcengineEipAddress(), + "volcengine_eip_associate": eip_associate.ResourceVolcengineEipAssociate(), + + // ================ CLB ================ + "volcengine_acl": acl.ResourceVolcengineAcl(), + "volcengine_clb": clb.ResourceVolcengineClb(), + "volcengine_listener": listener.ResourceVolcengineListener(), + "volcengine_server_group": server_group.ResourceVolcengineServerGroup(), + "volcengine_certificate": certificate.ResourceVolcengineCertificate(), + "volcengine_clb_rule": rule.ResourceVolcengineRule(), + "volcengine_server_group_server": server_group_server.ResourceVolcengineServerGroupServer(), + "volcengine_acl_entry": acl_entry.ResourceVolcengineAclEntry(), + + // ================ EBS ================ + "volcengine_volume": volume.ResourceVolcengineVolume(), + "volcengine_volume_attach": volume_attach.ResourceVolcengineVolumeAttach(), + + // ================ ECS ================ + "volcengine_ecs_instance": ecs_instance.ResourceVolcengineEcsInstance(), + "volcengine_ecs_instance_state": ecs_instance_state.ResourceVolcengineEcsInstanceState(), + + // ================ NAT ================ + "volcengine_snat_entry": snat_entry.ResourceVolcengineSnatEntry(), + "volcengine_nat_gateway": nat_gateway.ResourceVolcengineNatGateway(), + + //================= TOS ================= + "volcengine_tos_bucket": bucket.ResourceVolcengineTosBucket(), + "volcengine_tos_object": object.ResourceVolcengineTosObject(), + }, + ConfigureFunc: ProviderConfigure, + } +} + +func ProviderConfigure(d *schema.ResourceData) (interface{}, error) { + config := ve.Config{ + AccessKey: d.Get("access_key").(string), + SecretKey: d.Get("secret_key").(string), + SessionToken: d.Get("session_token").(string), + Region: d.Get("region").(string), + Endpoint: d.Get("endpoint").(string), + DisableSSL: d.Get("disable_ssl").(bool), + } + client, err := config.Client() + return client, err +} diff --git a/vestack/tos/bucket/data_source_vestack_tos_buckets.go b/volcengine/tos/bucket/data_source_volcengine_tos_buckets.go similarity index 86% rename from vestack/tos/bucket/data_source_vestack_tos_buckets.go rename to volcengine/tos/bucket/data_source_volcengine_tos_buckets.go index 3b3f1517..7d7f81e9 100644 --- a/vestack/tos/bucket/data_source_vestack_tos_buckets.go +++ b/volcengine/tos/bucket/data_source_volcengine_tos_buckets.go @@ -3,12 +3,12 @@ package bucket import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackTosBuckets() *schema.Resource { +func DataSourceVolcengineTosBuckets() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackTosBucketsRead, + Read: dataSourceVolcengineTosBucketsRead, Schema: map[string]*schema.Schema{ "bucket_name": { Type: schema.TypeString, @@ -71,7 +71,7 @@ func DataSourceVestackTosBuckets() *schema.Resource { } } -func dataSourceVestackTosBucketsRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineTosBucketsRead(d *schema.ResourceData, meta interface{}) error { tosBucketService := NewTosBucketService(meta.(*ve.SdkClient)) - return tosBucketService.Dispatcher.Data(tosBucketService, d, DataSourceVestackTosBuckets()) + return tosBucketService.Dispatcher.Data(tosBucketService, d, DataSourceVolcengineTosBuckets()) } diff --git a/vestack/tos/bucket/resource_vestack_tos_bucket.go b/volcengine/tos/bucket/resource_volcengine_tos_bucket.go similarity index 80% rename from vestack/tos/bucket/resource_vestack_tos_bucket.go rename to volcengine/tos/bucket/resource_volcengine_tos_bucket.go index 3de70476..aeefd918 100644 --- a/vestack/tos/bucket/resource_vestack_tos_bucket.go +++ b/volcengine/tos/bucket/resource_volcengine_tos_bucket.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -15,17 +15,17 @@ import ( Import Tos Bucket can be imported using the id, e.g. ``` -$ terraform import vestack_tos_bucket.default region:bucketName +$ terraform import volcengine_tos_bucket.default region:bucketName ``` */ -func ResourceVestackTosBucket() *schema.Resource { +func ResourceVolcengineTosBucket() *schema.Resource { resource := &schema.Resource{ - Create: resourceVestackTosBucketCreate, - Read: resourceVestackTosBucketRead, - Update: resourceVestackTosBucketUpdate, - Delete: resourceVestackTosBucketDelete, + Create: resourceVolcengineTosBucketCreate, + Read: resourceVolcengineTosBucketRead, + Update: resourceVolcengineTosBucketUpdate, + Delete: resourceVolcengineTosBucketDelete, Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(2 * time.Minute), Update: schema.DefaultTimeout(2 * time.Minute), @@ -119,36 +119,36 @@ func ResourceVestackTosBucket() *schema.Resource { return resource } -func resourceVestackTosBucketCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineTosBucketCreate(d *schema.ResourceData, meta interface{}) (err error) { tosBucketService := NewTosBucketService(meta.(*ve.SdkClient)) - err = tosBucketService.Dispatcher.Create(tosBucketService, d, ResourceVestackTosBucket()) + err = tosBucketService.Dispatcher.Create(tosBucketService, d, ResourceVolcengineTosBucket()) if err != nil { return fmt.Errorf("error on creating tos bucket %q, %s", d.Id(), err) } - return resourceVestackTosBucketRead(d, meta) + return resourceVolcengineTosBucketRead(d, meta) } -func resourceVestackTosBucketRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineTosBucketRead(d *schema.ResourceData, meta interface{}) (err error) { tosBucketService := NewTosBucketService(meta.(*ve.SdkClient)) - err = tosBucketService.Dispatcher.Read(tosBucketService, d, ResourceVestackTosBucket()) + err = tosBucketService.Dispatcher.Read(tosBucketService, d, ResourceVolcengineTosBucket()) if err != nil { return fmt.Errorf("error on reading tos bucket %q, %s", d.Id(), err) } return err } -func resourceVestackTosBucketUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineTosBucketUpdate(d *schema.ResourceData, meta interface{}) (err error) { tosBucketService := NewTosBucketService(meta.(*ve.SdkClient)) - err = tosBucketService.Dispatcher.Update(tosBucketService, d, ResourceVestackTosBucket()) + err = tosBucketService.Dispatcher.Update(tosBucketService, d, ResourceVolcengineTosBucket()) if err != nil { return fmt.Errorf("error on updating tos bucket %q, %s", d.Id(), err) } - return resourceVestackTosBucketRead(d, meta) + return resourceVolcengineTosBucketRead(d, meta) } -func resourceVestackTosBucketDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineTosBucketDelete(d *schema.ResourceData, meta interface{}) (err error) { tosBucketService := NewTosBucketService(meta.(*ve.SdkClient)) - err = tosBucketService.Dispatcher.Delete(tosBucketService, d, ResourceVestackTosBucket()) + err = tosBucketService.Dispatcher.Delete(tosBucketService, d, ResourceVolcengineTosBucket()) if err != nil { return fmt.Errorf("error on deleting tos bucket %q, %s", d.Id(), err) } diff --git a/vestack/tos/bucket/service_vestack_tos_bucket.go b/volcengine/tos/bucket/service_volcengine_tos_bucket.go similarity index 87% rename from vestack/tos/bucket/service_vestack_tos_bucket.go rename to volcengine/tos/bucket/service_volcengine_tos_bucket.go index efb56175..1bb023f1 100644 --- a/vestack/tos/bucket/service_vestack_tos_bucket.go +++ b/volcengine/tos/bucket/service_volcengine_tos_bucket.go @@ -7,27 +7,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackTosBucketService struct { +type VolcengineTosBucketService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewTosBucketService(c *ve.SdkClient) *VestackTosBucketService { - return &VestackTosBucketService{ +func NewTosBucketService(c *ve.SdkClient) *VolcengineTosBucketService { + return &VolcengineTosBucketService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackTosBucketService) GetClient() *ve.SdkClient { +func (s *VolcengineTosBucketService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackTosBucketService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineTosBucketService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { tos := s.Client.TosClient var ( action string @@ -50,7 +50,7 @@ func (s *VestackTosBucketService) ReadResources(condition map[string]interface{} return data, err } -func (s *VestackTosBucketService) ReadResource(resourceData *schema.ResourceData, instanceId string) (data map[string]interface{}, err error) { +func (s *VolcengineTosBucketService) ReadResource(resourceData *schema.ResourceData, instanceId string) (data map[string]interface{}, err error) { tos := s.Client.TosClient var ( action string @@ -125,7 +125,7 @@ func (s *VestackTosBucketService) ReadResource(resourceData *schema.ResourceData return data, nil } -func (s *VestackTosBucketService) RefreshResourceState(data *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineTosBucketService) RefreshResourceState(data *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 60 * time.Second, @@ -138,7 +138,7 @@ func (s *VestackTosBucketService) RefreshResourceState(data *schema.ResourceData } } -func (s *VestackTosBucketService) getIdPermission(p string, grants []interface{}) []interface{} { +func (s *VolcengineTosBucketService) getIdPermission(p string, grants []interface{}) []interface{} { var result []interface{} for _, grant := range grants { permission, _ := ve.ObtainSdkValue("Permission", grant) @@ -151,7 +151,7 @@ func (s *VestackTosBucketService) getIdPermission(p string, grants []interface{} return result } -func (s *VestackTosBucketService) WithResourceResponseHandlers(m map[string]interface{}) []ve.ResourceResponseHandler { +func (s *VolcengineTosBucketService) WithResourceResponseHandlers(m map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return m, map[string]ve.ResponseConvert{ "EnableVersion": { @@ -174,7 +174,7 @@ func (s *VestackTosBucketService) WithResourceResponseHandlers(m map[string]inte return []ve.ResourceResponseHandler{handler} } -func (s *VestackTosBucketService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineTosBucketService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { //create bucket callback := ve.Callback{ Call: ve.SdkCall{ @@ -300,7 +300,7 @@ func (s *VestackTosBucketService) CreateResource(resourceData *schema.ResourceDa return []ve.Callback{callback, callbackVersion, callbackAcl} } -func (s *VestackTosBucketService) ModifyResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineTosBucketService) ModifyResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { var callbacks []ve.Callback if data.HasChange("enable_version") { //version @@ -395,7 +395,7 @@ func (s *VestackTosBucketService) ModifyResource(data *schema.ResourceData, reso return callbacks } -func (s *VestackTosBucketService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineTosBucketService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "DeleteBucket", @@ -433,7 +433,7 @@ func (s *VestackTosBucketService) RemoveResource(resourceData *schema.ResourceDa return []ve.Callback{callback} } -func (s *VestackTosBucketService) DatasourceResources(data *schema.ResourceData, resource *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineTosBucketService) DatasourceResources(data *schema.ResourceData, resource *schema.Resource) ve.DataSourceInfo { name, ok := data.GetOk("bucket_name") return ve.DataSourceInfo{ @@ -471,11 +471,11 @@ func (s *VestackTosBucketService) DatasourceResources(data *schema.ResourceData, } } -func (s *VestackTosBucketService) ReadResourceId(id string) string { +func (s *VolcengineTosBucketService) ReadResourceId(id string) string { return id } -func (s *VestackTosBucketService) beforePutBucketAcl() ve.BeforeCallFunc { +func (s *VolcengineTosBucketService) beforePutBucketAcl() ve.BeforeCallFunc { return func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { data, err := s.Client.TosClient.DoTosCall(ve.TosInfo{ @@ -489,7 +489,7 @@ func (s *VestackTosBucketService) beforePutBucketAcl() ve.BeforeCallFunc { } } -func (s *VestackTosBucketService) executePutBucketAcl() ve.ExecuteCallFunc { +func (s *VolcengineTosBucketService) executePutBucketAcl() ve.ExecuteCallFunc { return func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) //PutAcl @@ -506,7 +506,7 @@ func (s *VestackTosBucketService) executePutBucketAcl() ve.ExecuteCallFunc { } } -func (s *VestackTosBucketService) executePutBucketVersioning() ve.ExecuteCallFunc { +func (s *VolcengineTosBucketService) executePutBucketVersioning() ve.ExecuteCallFunc { return func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) //PutVersion diff --git a/vestack/tos/object/data_source_vestack_tos_objects.go b/volcengine/tos/object/data_source_volcengine_tos_objects.go similarity index 86% rename from vestack/tos/object/data_source_vestack_tos_objects.go rename to volcengine/tos/object/data_source_volcengine_tos_objects.go index 84c183b7..dbe2551d 100644 --- a/vestack/tos/object/data_source_vestack_tos_objects.go +++ b/volcengine/tos/object/data_source_volcengine_tos_objects.go @@ -3,12 +3,12 @@ package object import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackTosObject() *schema.Resource { +func DataSourceVolcengineTosObject() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackTosObjectRead, + Read: dataSourceVolcengineTosObjectRead, Schema: map[string]*schema.Schema{ "bucket_name": { Type: schema.TypeString, @@ -66,7 +66,7 @@ func DataSourceVestackTosObject() *schema.Resource { } } -func dataSourceVestackTosObjectRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineTosObjectRead(d *schema.ResourceData, meta interface{}) error { tosBucketService := NewTosObjectService(meta.(*ve.SdkClient)) - return tosBucketService.Dispatcher.Data(tosBucketService, d, DataSourceVestackTosObject()) + return tosBucketService.Dispatcher.Data(tosBucketService, d, DataSourceVolcengineTosObject()) } diff --git a/vestack/tos/object/resource_vestack_tos_object.go b/volcengine/tos/object/resource_volcengine_tos_object.go similarity index 84% rename from vestack/tos/object/resource_vestack_tos_object.go rename to volcengine/tos/object/resource_volcengine_tos_object.go index 6e916e20..f2f24979 100644 --- a/vestack/tos/object/resource_vestack_tos_object.go +++ b/volcengine/tos/object/resource_volcengine_tos_object.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -15,17 +15,17 @@ import ( Import TOS Object can be imported using the id, e.g. ``` -$ terraform import vestack_tos_object.default bucketName:objectName +$ terraform import volcengine_tos_object.default bucketName:objectName ``` */ -func ResourceVestackTosObject() *schema.Resource { +func ResourceVolcengineTosObject() *schema.Resource { resource := &schema.Resource{ - Create: resourceVestackTosObjectCreate, - Read: resourceVestackTosObjectRead, - Update: resourceVestackTosObjectUpdate, - Delete: resourceVestackTosObjectDelete, + Create: resourceVolcengineTosObjectCreate, + Read: resourceVolcengineTosObjectRead, + Update: resourceVolcengineTosObjectUpdate, + Delete: resourceVolcengineTosObjectDelete, Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(2 * time.Minute), Update: schema.DefaultTimeout(2 * time.Minute), @@ -162,36 +162,36 @@ func ResourceVestackTosObject() *schema.Resource { return resource } -func resourceVestackTosObjectCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineTosObjectCreate(d *schema.ResourceData, meta interface{}) (err error) { tosBucketService := NewTosObjectService(meta.(*ve.SdkClient)) - err = tosBucketService.Dispatcher.Create(tosBucketService, d, ResourceVestackTosObject()) + err = tosBucketService.Dispatcher.Create(tosBucketService, d, ResourceVolcengineTosObject()) if err != nil { return fmt.Errorf("error on creating tos bucket %q, %s", d.Id(), err) } - return resourceVestackTosObjectRead(d, meta) + return resourceVolcengineTosObjectRead(d, meta) } -func resourceVestackTosObjectRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineTosObjectRead(d *schema.ResourceData, meta interface{}) (err error) { tosBucketService := NewTosObjectService(meta.(*ve.SdkClient)) - err = tosBucketService.Dispatcher.Read(tosBucketService, d, ResourceVestackTosObject()) + err = tosBucketService.Dispatcher.Read(tosBucketService, d, ResourceVolcengineTosObject()) if err != nil { return fmt.Errorf("error on reading tos bucket %q, %s", d.Id(), err) } return err } -func resourceVestackTosObjectUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineTosObjectUpdate(d *schema.ResourceData, meta interface{}) (err error) { tosBucketService := NewTosObjectService(meta.(*ve.SdkClient)) - err = tosBucketService.Dispatcher.Update(tosBucketService, d, ResourceVestackTosObject()) + err = tosBucketService.Dispatcher.Update(tosBucketService, d, ResourceVolcengineTosObject()) if err != nil { return fmt.Errorf("error on updating tos bucket %q, %s", d.Id(), err) } - return resourceVestackTosObjectRead(d, meta) + return resourceVolcengineTosObjectRead(d, meta) } -func resourceVestackTosObjectDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineTosObjectDelete(d *schema.ResourceData, meta interface{}) (err error) { tosBucketService := NewTosObjectService(meta.(*ve.SdkClient)) - err = tosBucketService.Dispatcher.Delete(tosBucketService, d, ResourceVestackTosObject()) + err = tosBucketService.Dispatcher.Delete(tosBucketService, d, ResourceVolcengineTosObject()) if err != nil { return fmt.Errorf("error on deleting tos bucket %q, %s", d.Id(), err) } diff --git a/vestack/tos/object/service_vestack_tos_object.go b/volcengine/tos/object/service_volcengine_tos_object.go similarity index 87% rename from vestack/tos/object/service_vestack_tos_object.go rename to volcengine/tos/object/service_volcengine_tos_object.go index 9398ad06..57b5a7e5 100644 --- a/vestack/tos/object/service_vestack_tos_object.go +++ b/volcengine/tos/object/service_volcengine_tos_object.go @@ -8,27 +8,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackTosObjectService struct { +type VolcengineTosObjectService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewTosObjectService(c *ve.SdkClient) *VestackTosObjectService { - return &VestackTosObjectService{ +func NewTosObjectService(c *ve.SdkClient) *VolcengineTosObjectService { + return &VolcengineTosObjectService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackTosObjectService) GetClient() *ve.SdkClient { +func (s *VolcengineTosObjectService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackTosObjectService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineTosObjectService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { tos := s.Client.TosClient var ( action string @@ -52,7 +52,7 @@ func (s *VestackTosObjectService) ReadResources(condition map[string]interface{} return data, err } -func (s *VestackTosObjectService) ReadResource(resourceData *schema.ResourceData, instanceId string) (data map[string]interface{}, err error) { +func (s *VolcengineTosObjectService) ReadResource(resourceData *schema.ResourceData, instanceId string) (data map[string]interface{}, err error) { tos := s.Client.TosClient bucketName := resourceData.Get("bucket_name").(string) var ( @@ -189,7 +189,7 @@ func (s *VestackTosObjectService) ReadResource(resourceData *schema.ResourceData return data, nil } -func (s *VestackTosObjectService) RefreshResourceState(data *schema.ResourceData, target []string, timeout time.Duration, instanceId string) *resource.StateChangeConf { +func (s *VolcengineTosObjectService) RefreshResourceState(data *schema.ResourceData, target []string, timeout time.Duration, instanceId string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 60 * time.Second, @@ -202,7 +202,7 @@ func (s *VestackTosObjectService) RefreshResourceState(data *schema.ResourceData } } -func (VestackTosObjectService) WithResourceResponseHandlers(m map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineTosObjectService) WithResourceResponseHandlers(m map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return m, map[string]ve.ResponseConvert{ "EnableVersion": { @@ -225,7 +225,7 @@ func (VestackTosObjectService) WithResourceResponseHandlers(m map[string]interfa return []ve.ResourceResponseHandler{handler} } -func (s *VestackTosObjectService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineTosObjectService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { //create object callback := s.createOrReplaceObject(resourceData, resource, false) //acl @@ -233,7 +233,7 @@ func (s *VestackTosObjectService) CreateResource(resourceData *schema.ResourceDa return []ve.Callback{callback, callbackAcl} } -func (s *VestackTosObjectService) ModifyResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineTosObjectService) ModifyResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback { var callbacks []ve.Callback if data.HasChange("file_path") { @@ -256,7 +256,7 @@ func (s *VestackTosObjectService) ModifyResource(data *schema.ResourceData, reso return callbacks } -func (s *VestackTosObjectService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineTosObjectService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "DeleteObject", @@ -316,7 +316,7 @@ func (s *VestackTosObjectService) RemoveResource(resourceData *schema.ResourceDa return []ve.Callback{callback} } -func (s *VestackTosObjectService) DatasourceResources(data *schema.ResourceData, resource *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineTosObjectService) DatasourceResources(data *schema.ResourceData, resource *schema.Resource) ve.DataSourceInfo { name, ok := data.GetOk("object_name") bucketName, _ := data.GetOk("bucket_name") return ve.DataSourceInfo{ @@ -361,11 +361,11 @@ func (s *VestackTosObjectService) DatasourceResources(data *schema.ResourceData, } } -func (s *VestackTosObjectService) ReadResourceId(id string) string { +func (s *VolcengineTosObjectService) ReadResourceId(id string) string { return id[strings.Index(id, ":")+1:] } -func (s *VestackTosObjectService) beforePutObjectAcl() ve.BeforeCallFunc { +func (s *VolcengineTosObjectService) beforePutObjectAcl() ve.BeforeCallFunc { return func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) data, err := s.Client.TosClient.DoTosCall(ve.TosInfo{ @@ -380,7 +380,7 @@ func (s *VestackTosObjectService) beforePutObjectAcl() ve.BeforeCallFunc { } } -func (s *VestackTosObjectService) executePutObjectAcl() ve.ExecuteCallFunc { +func (s *VolcengineTosObjectService) executePutObjectAcl() ve.ExecuteCallFunc { return func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) //PutAcl @@ -397,7 +397,7 @@ func (s *VestackTosObjectService) executePutObjectAcl() ve.ExecuteCallFunc { } } -func (s *VestackTosObjectService) createOrUpdateObjectAcl(resourceData *schema.ResourceData, resource *schema.Resource, isUpdate bool) ve.Callback { +func (s *VolcengineTosObjectService) createOrUpdateObjectAcl(resourceData *schema.ResourceData, resource *schema.Resource, isUpdate bool) ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ ServiceCategory: ve.ServiceTos, @@ -461,7 +461,7 @@ func (s *VestackTosObjectService) createOrUpdateObjectAcl(resourceData *schema.R return callback } -func (s *VestackTosObjectService) createOrReplaceObject(resourceData *schema.ResourceData, resource *schema.Resource, isUpdate bool) ve.Callback { +func (s *VolcengineTosObjectService) createOrReplaceObject(resourceData *schema.ResourceData, resource *schema.Resource, isUpdate bool) ve.Callback { return ve.Callback{ Call: ve.SdkCall{ ServiceCategory: ve.ServiceTos, diff --git a/vestack/vpc/network_interface/data_source_vestack_network_interfaces.go b/volcengine/vpc/network_interface/data_source_volcengine_network_interfaces.go similarity index 94% rename from vestack/vpc/network_interface/data_source_vestack_network_interfaces.go rename to volcengine/vpc/network_interface/data_source_volcengine_network_interfaces.go index da81b314..a743318c 100644 --- a/vestack/vpc/network_interface/data_source_vestack_network_interfaces.go +++ b/volcengine/vpc/network_interface/data_source_volcengine_network_interfaces.go @@ -3,12 +3,12 @@ package network_interface import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackNetworkInterfaces() *schema.Resource { +func DataSourceVolcengineNetworkInterfaces() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackNetworkInterfacesRead, + Read: dataSourceVolcengineNetworkInterfacesRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -191,7 +191,7 @@ func DataSourceVestackNetworkInterfaces() *schema.Resource { } } -func dataSourceVestackNetworkInterfacesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineNetworkInterfacesRead(d *schema.ResourceData, meta interface{}) error { networkInterfaceService := NewNetworkInterfaceService(meta.(*ve.SdkClient)) - return networkInterfaceService.Dispatcher.Data(networkInterfaceService, d, DataSourceVestackNetworkInterfaces()) + return networkInterfaceService.Dispatcher.Data(networkInterfaceService, d, DataSourceVolcengineNetworkInterfaces()) } diff --git a/vestack/vpc/network_interface/resource_vestack_network_interface.go b/volcengine/vpc/network_interface/resource_volcengine_network_interface.go similarity index 68% rename from vestack/vpc/network_interface/resource_vestack_network_interface.go rename to volcengine/vpc/network_interface/resource_volcengine_network_interface.go index a31d25d2..998e7f55 100644 --- a/vestack/vpc/network_interface/resource_vestack_network_interface.go +++ b/volcengine/vpc/network_interface/resource_volcengine_network_interface.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -13,17 +13,17 @@ import ( Import Network interface can be imported using the id, e.g. ``` -$ terraform import vestack_network_interface.default eni-bp1fgnh68xyz9**** +$ terraform import volcengine_network_interface.default eni-bp1fgnh68xyz9**** ``` */ -func ResourceVestackNetworkInterface() *schema.Resource { +func ResourceVolcengineNetworkInterface() *schema.Resource { return &schema.Resource{ - Delete: resourceVestackNetworkInterfaceDelete, - Create: resourceVestackNetworkInterfaceCreate, - Read: resourceVestackNetworkInterfaceRead, - Update: resourceVestackNetworkInterfaceUpdate, + Delete: resourceVolcengineNetworkInterfaceDelete, + Create: resourceVolcengineNetworkInterfaceCreate, + Read: resourceVolcengineNetworkInterfaceRead, + Update: resourceVolcengineNetworkInterfaceUpdate, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -76,33 +76,33 @@ func ResourceVestackNetworkInterface() *schema.Resource { } } -func resourceVestackNetworkInterfaceCreate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineNetworkInterfaceCreate(d *schema.ResourceData, meta interface{}) error { networkInterfaceService := NewNetworkInterfaceService(meta.(*ve.SdkClient)) - if err := networkInterfaceService.Dispatcher.Create(networkInterfaceService, d, ResourceVestackNetworkInterface()); err != nil { + if err := networkInterfaceService.Dispatcher.Create(networkInterfaceService, d, ResourceVolcengineNetworkInterface()); err != nil { return fmt.Errorf("error on creating network interface %q, %w", d.Id(), err) } - return resourceVestackNetworkInterfaceRead(d, meta) + return resourceVolcengineNetworkInterfaceRead(d, meta) } -func resourceVestackNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) error { networkInterfaceService := NewNetworkInterfaceService(meta.(*ve.SdkClient)) - if err := networkInterfaceService.Dispatcher.Read(networkInterfaceService, d, ResourceVestackNetworkInterface()); err != nil { + if err := networkInterfaceService.Dispatcher.Read(networkInterfaceService, d, ResourceVolcengineNetworkInterface()); err != nil { return fmt.Errorf("error on reading network interface %q, %w", d.Id(), err) } return nil } -func resourceVestackNetworkInterfaceUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineNetworkInterfaceUpdate(d *schema.ResourceData, meta interface{}) error { networkInterfaceService := NewNetworkInterfaceService(meta.(*ve.SdkClient)) - if err := networkInterfaceService.Dispatcher.Update(networkInterfaceService, d, ResourceVestackNetworkInterface()); err != nil { + if err := networkInterfaceService.Dispatcher.Update(networkInterfaceService, d, ResourceVolcengineNetworkInterface()); err != nil { return fmt.Errorf("error on updating network interface %q, %w", d.Id(), err) } - return resourceVestackNetworkInterfaceRead(d, meta) + return resourceVolcengineNetworkInterfaceRead(d, meta) } -func resourceVestackNetworkInterfaceDelete(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineNetworkInterfaceDelete(d *schema.ResourceData, meta interface{}) error { networkInterfaceService := NewNetworkInterfaceService(meta.(*ve.SdkClient)) - if err := networkInterfaceService.Dispatcher.Delete(networkInterfaceService, d, ResourceVestackNetworkInterface()); err != nil { + if err := networkInterfaceService.Dispatcher.Delete(networkInterfaceService, d, ResourceVolcengineNetworkInterface()); err != nil { return fmt.Errorf("error on deleting network interface %q, %w", d.Id(), err) } return nil diff --git a/vestack/vpc/network_interface/service_vestack_network_interface.go b/volcengine/vpc/network_interface/service_volcengine_network_interface.go similarity index 80% rename from vestack/vpc/network_interface/service_vestack_network_interface.go rename to volcengine/vpc/network_interface/service_volcengine_network_interface.go index c10ace2c..8af70ae2 100644 --- a/vestack/vpc/network_interface/service_vestack_network_interface.go +++ b/volcengine/vpc/network_interface/service_volcengine_network_interface.go @@ -7,27 +7,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackNetworkInterfaceService struct { +type VolcengineNetworkInterfaceService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewNetworkInterfaceService(c *ve.SdkClient) *VestackNetworkInterfaceService { - return &VestackNetworkInterfaceService{ +func NewNetworkInterfaceService(c *ve.SdkClient) *VolcengineNetworkInterfaceService { + return &VolcengineNetworkInterfaceService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackNetworkInterfaceService) GetClient() *ve.SdkClient { +func (s *VolcengineNetworkInterfaceService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackNetworkInterfaceService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineNetworkInterfaceService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -63,7 +63,7 @@ func (s *VestackNetworkInterfaceService) ReadResources(m map[string]interface{}) }) } -func (s *VestackNetworkInterfaceService) ReadResource(resourceData *schema.ResourceData, id string) (data map[string]interface{}, err error) { +func (s *VolcengineNetworkInterfaceService) ReadResource(resourceData *schema.ResourceData, id string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -89,7 +89,7 @@ func (s *VestackNetworkInterfaceService) ReadResource(resourceData *schema.Resou return data, err } -func (s *VestackNetworkInterfaceService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineNetworkInterfaceService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -122,7 +122,7 @@ func (s *VestackNetworkInterfaceService) RefreshResourceState(resourceData *sche } } -func (VestackNetworkInterfaceService) WithResourceResponseHandlers(networkInterface map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineNetworkInterfaceService) WithResourceResponseHandlers(networkInterface map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return networkInterface, nil, nil } @@ -130,7 +130,7 @@ func (VestackNetworkInterfaceService) WithResourceResponseHandlers(networkInterf } -func (s *VestackNetworkInterfaceService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineNetworkInterfaceService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "CreateNetworkInterface", @@ -159,7 +159,7 @@ func (s *VestackNetworkInterfaceService) CreateResource(resourceData *schema.Res return []ve.Callback{callback} } -func (s *VestackNetworkInterfaceService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineNetworkInterfaceService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifyNetworkInterfaceAttributes", @@ -183,7 +183,7 @@ func (s *VestackNetworkInterfaceService) ModifyResource(resourceData *schema.Res return []ve.Callback{callback} } -func (s *VestackNetworkInterfaceService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineNetworkInterfaceService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "DeleteNetworkInterface", @@ -221,7 +221,7 @@ func (s *VestackNetworkInterfaceService) RemoveResource(resourceData *schema.Res return []ve.Callback{callback} } -func (s *VestackNetworkInterfaceService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineNetworkInterfaceService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -251,6 +251,6 @@ func (s *VestackNetworkInterfaceService) DatasourceResources(*schema.ResourceDat } } -func (s *VestackNetworkInterfaceService) ReadResourceId(id string) string { +func (s *VolcengineNetworkInterfaceService) ReadResourceId(id string) string { return id } diff --git a/vestack/vpc/network_interface_attach/common_vestack_network_interface_attach.go b/volcengine/vpc/network_interface_attach/common_volcengine_network_interface_attach.go similarity index 100% rename from vestack/vpc/network_interface_attach/common_vestack_network_interface_attach.go rename to volcengine/vpc/network_interface_attach/common_volcengine_network_interface_attach.go diff --git a/vestack/vpc/network_interface_attach/resource_vestack_network_interface_attach.go b/volcengine/vpc/network_interface_attach/resource_volcengine_network_interface_attach.go similarity index 58% rename from vestack/vpc/network_interface_attach/resource_vestack_network_interface_attach.go rename to volcengine/vpc/network_interface_attach/resource_volcengine_network_interface_attach.go index 2c89a476..349172f8 100644 --- a/vestack/vpc/network_interface_attach/resource_vestack_network_interface_attach.go +++ b/volcengine/vpc/network_interface_attach/resource_volcengine_network_interface_attach.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -12,16 +12,16 @@ import ( Import Network interface attach can be imported using the network_interface_id:instance_id. ``` -$ terraform import vestack_network_interface_attach.default eni-bp1fg655nh68xyz9***:i-wijfn35c**** +$ terraform import volcengine_network_interface_attach.default eni-bp1fg655nh68xyz9***:i-wijfn35c**** ``` */ -func ResourceVestackNetworkInterfaceAttach() *schema.Resource { +func ResourceVolcengineNetworkInterfaceAttach() *schema.Resource { return &schema.Resource{ - Delete: resourceVestackNetworkInterfaceAttachDelete, - Create: resourceVestackNetworkInterfaceAttachCreate, - Read: resourceVestackNetworkInterfaceAttachRead, + Delete: resourceVolcengineNetworkInterfaceAttachDelete, + Create: resourceVolcengineNetworkInterfaceAttachCreate, + Read: resourceVolcengineNetworkInterfaceAttachRead, Importer: &schema.ResourceImporter{ State: networkInterfaceAttachImporter, }, @@ -42,25 +42,25 @@ func ResourceVestackNetworkInterfaceAttach() *schema.Resource { } } -func resourceVestackNetworkInterfaceAttachCreate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineNetworkInterfaceAttachCreate(d *schema.ResourceData, meta interface{}) error { networkInterfaceAttachService := NewNetworkInterfaceAttachService(meta.(*ve.SdkClient)) - if err := networkInterfaceAttachService.Dispatcher.Create(networkInterfaceAttachService, d, ResourceVestackNetworkInterfaceAttach()); err != nil { + if err := networkInterfaceAttachService.Dispatcher.Create(networkInterfaceAttachService, d, ResourceVolcengineNetworkInterfaceAttach()); err != nil { return fmt.Errorf("error on creating network interface attach %q, %w", d.Id(), err) } - return resourceVestackNetworkInterfaceAttachRead(d, meta) + return resourceVolcengineNetworkInterfaceAttachRead(d, meta) } -func resourceVestackNetworkInterfaceAttachRead(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineNetworkInterfaceAttachRead(d *schema.ResourceData, meta interface{}) error { networkInterfaceAttachService := NewNetworkInterfaceAttachService(meta.(*ve.SdkClient)) - if err := networkInterfaceAttachService.Dispatcher.Read(networkInterfaceAttachService, d, ResourceVestackNetworkInterfaceAttach()); err != nil { + if err := networkInterfaceAttachService.Dispatcher.Read(networkInterfaceAttachService, d, ResourceVolcengineNetworkInterfaceAttach()); err != nil { return fmt.Errorf("error on reading network interface attach %q, %w", d.Id(), err) } return nil } -func resourceVestackNetworkInterfaceAttachDelete(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineNetworkInterfaceAttachDelete(d *schema.ResourceData, meta interface{}) error { networkInterfaceAttachService := NewNetworkInterfaceAttachService(meta.(*ve.SdkClient)) - if err := networkInterfaceAttachService.Dispatcher.Delete(networkInterfaceAttachService, d, ResourceVestackNetworkInterfaceAttach()); err != nil { + if err := networkInterfaceAttachService.Dispatcher.Delete(networkInterfaceAttachService, d, ResourceVolcengineNetworkInterfaceAttach()); err != nil { return fmt.Errorf("error on deleting network interface attach %q, %w", d.Id(), err) } return nil diff --git a/vestack/vpc/network_interface_attach/service_vestack_network_interface_attach.go b/volcengine/vpc/network_interface_attach/service_volcengine_network_interface_attach.go similarity index 76% rename from vestack/vpc/network_interface_attach/service_vestack_network_interface_attach.go rename to volcengine/vpc/network_interface_attach/service_volcengine_network_interface_attach.go index bd05dc38..fd4bb164 100644 --- a/vestack/vpc/network_interface_attach/service_vestack_network_interface_attach.go +++ b/volcengine/vpc/network_interface_attach/service_volcengine_network_interface_attach.go @@ -8,31 +8,31 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackNetworkInterfaceAttachService struct { +type VolcengineNetworkInterfaceAttachService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewNetworkInterfaceAttachService(c *ve.SdkClient) *VestackNetworkInterfaceAttachService { - return &VestackNetworkInterfaceAttachService{ +func NewNetworkInterfaceAttachService(c *ve.SdkClient) *VolcengineNetworkInterfaceAttachService { + return &VolcengineNetworkInterfaceAttachService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackNetworkInterfaceAttachService) GetClient() *ve.SdkClient { +func (s *VolcengineNetworkInterfaceAttachService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackNetworkInterfaceAttachService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineNetworkInterfaceAttachService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { return nil, nil } -func (s *VestackNetworkInterfaceAttachService) ReadResource(resourceData *schema.ResourceData, id string) (data map[string]interface{}, err error) { +func (s *VolcengineNetworkInterfaceAttachService) ReadResource(resourceData *schema.ResourceData, id string) (data map[string]interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -96,7 +96,7 @@ func (s *VestackNetworkInterfaceAttachService) ReadResource(resourceData *schema return data, err } -func (s *VestackNetworkInterfaceAttachService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineNetworkInterfaceAttachService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -129,7 +129,7 @@ func (s *VestackNetworkInterfaceAttachService) RefreshResourceState(resourceData } } -func (VestackNetworkInterfaceAttachService) WithResourceResponseHandlers(networkInterface map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineNetworkInterfaceAttachService) WithResourceResponseHandlers(networkInterface map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return networkInterface, nil, nil } @@ -137,7 +137,7 @@ func (VestackNetworkInterfaceAttachService) WithResourceResponseHandlers(network } -func (s *VestackNetworkInterfaceAttachService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineNetworkInterfaceAttachService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "AttachNetworkInterface", @@ -159,11 +159,11 @@ func (s *VestackNetworkInterfaceAttachService) CreateResource(resourceData *sche return []ve.Callback{callback} } -func (s *VestackNetworkInterfaceAttachService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineNetworkInterfaceAttachService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { return []ve.Callback{} } -func (s *VestackNetworkInterfaceAttachService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineNetworkInterfaceAttachService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { ids := strings.Split(resourceData.Id(), ":") callback := ve.Callback{ Call: ve.SdkCall{ @@ -200,11 +200,11 @@ func (s *VestackNetworkInterfaceAttachService) RemoveResource(resourceData *sche return []ve.Callback{callback} } -func (s *VestackNetworkInterfaceAttachService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineNetworkInterfaceAttachService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{} } -func (s *VestackNetworkInterfaceAttachService) ReadResourceId(id string) string { +func (s *VolcengineNetworkInterfaceAttachService) ReadResourceId(id string) string { items := strings.Split(id, ":") return items[0] } diff --git a/vestack/vpc/route_entry/data_source_vestack_route_entries.go b/volcengine/vpc/route_entry/data_source_volcengine_route_entries.go similarity index 92% rename from vestack/vpc/route_entry/data_source_vestack_route_entries.go rename to volcengine/vpc/route_entry/data_source_volcengine_route_entries.go index e1dbdddc..175b13cb 100644 --- a/vestack/vpc/route_entry/data_source_vestack_route_entries.go +++ b/volcengine/vpc/route_entry/data_source_volcengine_route_entries.go @@ -2,12 +2,12 @@ package route_entry import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackRouteEntries() *schema.Resource { +func DataSourceVolcengineRouteEntries() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackRouteEntriesRead, + Read: dataSourceVolcengineRouteEntriesRead, Schema: map[string]*schema.Schema{ "route_table_id": { Type: schema.TypeString, @@ -131,7 +131,7 @@ func DataSourceVestackRouteEntries() *schema.Resource { } } -func dataSourceVestackRouteEntriesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineRouteEntriesRead(d *schema.ResourceData, meta interface{}) error { routeEntryService := NewRouteEntryService(meta.(*ve.SdkClient)) - return routeEntryService.Dispatcher.Data(routeEntryService, d, DataSourceVestackRouteEntries()) + return routeEntryService.Dispatcher.Data(routeEntryService, d, DataSourceVolcengineRouteEntries()) } diff --git a/vestack/vpc/route_entry/resource_vestack_route_entry.go b/volcengine/vpc/route_entry/resource_volcengine_route_entry.go similarity index 70% rename from vestack/vpc/route_entry/resource_vestack_route_entry.go rename to volcengine/vpc/route_entry/resource_volcengine_route_entry.go index 0e7f9c65..94e41f75 100644 --- a/vestack/vpc/route_entry/resource_vestack_route_entry.go +++ b/volcengine/vpc/route_entry/resource_volcengine_route_entry.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -13,17 +13,17 @@ import ( Import Route entry can be imported using the route_table_id:route_entry_id, e.g. ``` -$ terraform import vestack_route_entry.default vtb-274e19skkuhog7fap8u4i8ird:rte-274e1g9ei4k5c7fap8sp974fq +$ terraform import volcengine_route_entry.default vtb-274e19skkuhog7fap8u4i8ird:rte-274e1g9ei4k5c7fap8sp974fq ``` */ -func ResourceVestackRouteEntry() *schema.Resource { +func ResourceVolcengineRouteEntry() *schema.Resource { return &schema.Resource{ - Delete: resourceVestackRouteEntryDelete, - Create: resourceVestackRouteEntryCreate, - Read: resourceVestackRouteEntryRead, - Update: resourceVestackRouteEntryUpdate, + Delete: resourceVolcengineRouteEntryDelete, + Create: resourceVolcengineRouteEntryCreate, + Read: resourceVolcengineRouteEntryRead, + Update: resourceVolcengineRouteEntryUpdate, Importer: &schema.ResourceImporter{ State: importRouteEntry, }, @@ -77,33 +77,33 @@ func ResourceVestackRouteEntry() *schema.Resource { } } -func resourceVestackRouteEntryCreate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineRouteEntryCreate(d *schema.ResourceData, meta interface{}) error { routeEntryService := NewRouteEntryService(meta.(*ve.SdkClient)) - if err := routeEntryService.Dispatcher.Create(routeEntryService, d, ResourceVestackRouteEntry()); err != nil { + if err := routeEntryService.Dispatcher.Create(routeEntryService, d, ResourceVolcengineRouteEntry()); err != nil { return fmt.Errorf("error on creating route entry %q, %w", d.Id(), err) } - return resourceVestackRouteEntryRead(d, meta) + return resourceVolcengineRouteEntryRead(d, meta) } -func resourceVestackRouteEntryRead(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineRouteEntryRead(d *schema.ResourceData, meta interface{}) error { routeEntryService := NewRouteEntryService(meta.(*ve.SdkClient)) - if err := routeEntryService.Dispatcher.Read(routeEntryService, d, ResourceVestackRouteEntry()); err != nil { + if err := routeEntryService.Dispatcher.Read(routeEntryService, d, ResourceVolcengineRouteEntry()); err != nil { return fmt.Errorf("error on reading route entry %q, %w", d.Id(), err) } return nil } -func resourceVestackRouteEntryUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineRouteEntryUpdate(d *schema.ResourceData, meta interface{}) error { routeEntryService := NewRouteEntryService(meta.(*ve.SdkClient)) - if err := routeEntryService.Dispatcher.Update(routeEntryService, d, ResourceVestackRouteEntry()); err != nil { + if err := routeEntryService.Dispatcher.Update(routeEntryService, d, ResourceVolcengineRouteEntry()); err != nil { return fmt.Errorf("error on updating route entry %q, %w", d.Id(), err) } - return resourceVestackRouteEntryRead(d, meta) + return resourceVolcengineRouteEntryRead(d, meta) } -func resourceVestackRouteEntryDelete(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineRouteEntryDelete(d *schema.ResourceData, meta interface{}) error { routeEntryService := NewRouteEntryService(meta.(*ve.SdkClient)) - if err := routeEntryService.Dispatcher.Delete(routeEntryService, d, ResourceVestackRouteEntry()); err != nil { + if err := routeEntryService.Dispatcher.Delete(routeEntryService, d, ResourceVolcengineRouteEntry()); err != nil { return fmt.Errorf("error on deleting route entry %q, %w", d.Id(), err) } return nil diff --git a/vestack/vpc/route_entry/service_vestack_route_entry.go b/volcengine/vpc/route_entry/service_volcengine_route_entry.go similarity index 83% rename from vestack/vpc/route_entry/service_vestack_route_entry.go rename to volcengine/vpc/route_entry/service_volcengine_route_entry.go index 4bcfe142..6fdfbb0d 100644 --- a/vestack/vpc/route_entry/service_vestack_route_entry.go +++ b/volcengine/vpc/route_entry/service_volcengine_route_entry.go @@ -8,27 +8,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackRouteEntryService struct { +type VolcengineRouteEntryService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewRouteEntryService(c *ve.SdkClient) *VestackRouteEntryService { - return &VestackRouteEntryService{ +func NewRouteEntryService(c *ve.SdkClient) *VolcengineRouteEntryService { + return &VolcengineRouteEntryService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackRouteEntryService) GetClient() *ve.SdkClient { +func (s *VolcengineRouteEntryService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackRouteEntryService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineRouteEntryService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -87,7 +87,7 @@ func (s *VestackRouteEntryService) ReadResources(m map[string]interface{}) (data return res, nil } -func (s *VestackRouteEntryService) ReadResource(resourceData *schema.ResourceData, tmpId string) (data map[string]interface{}, err error) { +func (s *VolcengineRouteEntryService) ReadResource(resourceData *schema.ResourceData, tmpId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -122,7 +122,7 @@ func (s *VestackRouteEntryService) ReadResource(resourceData *schema.ResourceDat return data, err } -func (s *VestackRouteEntryService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineRouteEntryService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -155,7 +155,7 @@ func (s *VestackRouteEntryService) RefreshResourceState(resourceData *schema.Res } } -func (VestackRouteEntryService) WithResourceResponseHandlers(entries map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineRouteEntryService) WithResourceResponseHandlers(entries map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return entries, nil, nil } @@ -163,7 +163,7 @@ func (VestackRouteEntryService) WithResourceResponseHandlers(entries map[string] } -func (s *VestackRouteEntryService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineRouteEntryService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "CreateRouteEntry", @@ -187,7 +187,7 @@ func (s *VestackRouteEntryService) CreateResource(resourceData *schema.ResourceD return []ve.Callback{callback} } -func (s *VestackRouteEntryService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineRouteEntryService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { ids := strings.Split(s.ReadResourceId(resourceData.Id()), ":") callback := ve.Callback{ Call: ve.SdkCall{ @@ -210,7 +210,7 @@ func (s *VestackRouteEntryService) ModifyResource(resourceData *schema.ResourceD return []ve.Callback{callback} } -func (s *VestackRouteEntryService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineRouteEntryService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { ids := strings.Split(resourceData.Id(), ":") callback := ve.Callback{ Call: ve.SdkCall{ @@ -249,7 +249,7 @@ func (s *VestackRouteEntryService) RemoveResource(resourceData *schema.ResourceD return []ve.Callback{callback} } -func (s *VestackRouteEntryService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineRouteEntryService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -286,6 +286,6 @@ func importRouteEntry(d *schema.ResourceData, meta interface{}) ([]*schema.Resou return []*schema.ResourceData{d}, nil } -func (s *VestackRouteEntryService) ReadResourceId(id string) string { +func (s *VolcengineRouteEntryService) ReadResourceId(id string) string { return id } diff --git a/vestack/vpc/route_table/data_source_vestack_route_tables.go b/volcengine/vpc/route_table/data_source_volcengine_route_tables.go similarity index 91% rename from vestack/vpc/route_table/data_source_vestack_route_tables.go rename to volcengine/vpc/route_table/data_source_volcengine_route_tables.go index b3845969..594fd89e 100644 --- a/vestack/vpc/route_table/data_source_vestack_route_tables.go +++ b/volcengine/vpc/route_table/data_source_volcengine_route_tables.go @@ -2,12 +2,12 @@ package route_table import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackRouteTables() *schema.Resource { +func DataSourceVolcengineRouteTables() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackRouteTablesRead, + Read: dataSourceVolcengineRouteTablesRead, Schema: map[string]*schema.Schema{ "vpc_id": { Type: schema.TypeString, @@ -109,7 +109,7 @@ func DataSourceVestackRouteTables() *schema.Resource { } } -func dataSourceVestackRouteTablesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineRouteTablesRead(d *schema.ResourceData, meta interface{}) error { routeTableService := NewRouteTableService(meta.(*ve.SdkClient)) - return routeTableService.Dispatcher.Data(routeTableService, d, DataSourceVestackRouteTables()) + return routeTableService.Dispatcher.Data(routeTableService, d, DataSourceVolcengineRouteTables()) } diff --git a/vestack/vpc/route_table/resource_vestack_route_table.go b/volcengine/vpc/route_table/resource_volcengine_route_table.go similarity index 60% rename from vestack/vpc/route_table/resource_vestack_route_table.go rename to volcengine/vpc/route_table/resource_volcengine_route_table.go index 37a30f18..58ec1d76 100644 --- a/vestack/vpc/route_table/resource_vestack_route_table.go +++ b/volcengine/vpc/route_table/resource_volcengine_route_table.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -12,17 +12,17 @@ import ( Import Route table can be imported using the id, e.g. ``` -$ terraform import vestack_route_table.default vtb-274e0syt9av407fap8tle16kb +$ terraform import volcengine_route_table.default vtb-274e0syt9av407fap8tle16kb ``` */ -func ResourceVestackRouteTable() *schema.Resource { +func ResourceVolcengineRouteTable() *schema.Resource { return &schema.Resource{ - Delete: resourceVestackRouteTableDelete, - Create: resourceVestackRouteTableCreate, - Read: resourceVestackRouteTableRead, - Update: resourceVestackRouteTableUpdate, + Delete: resourceVolcengineRouteTableDelete, + Create: resourceVolcengineRouteTableCreate, + Read: resourceVolcengineRouteTableRead, + Update: resourceVolcengineRouteTableUpdate, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -48,33 +48,33 @@ func ResourceVestackRouteTable() *schema.Resource { } } -func resourceVestackRouteTableCreate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineRouteTableCreate(d *schema.ResourceData, meta interface{}) error { routeTableService := NewRouteTableService(meta.(*ve.SdkClient)) - if err := routeTableService.Dispatcher.Create(routeTableService, d, ResourceVestackRouteTable()); err != nil { + if err := routeTableService.Dispatcher.Create(routeTableService, d, ResourceVolcengineRouteTable()); err != nil { return fmt.Errorf("error on creating route table %q, %w", d.Id(), err) } - return resourceVestackRouteTableRead(d, meta) + return resourceVolcengineRouteTableRead(d, meta) } -func resourceVestackRouteTableRead(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineRouteTableRead(d *schema.ResourceData, meta interface{}) error { routeTableService := NewRouteTableService(meta.(*ve.SdkClient)) - if err := routeTableService.Dispatcher.Read(routeTableService, d, ResourceVestackRouteTable()); err != nil { + if err := routeTableService.Dispatcher.Read(routeTableService, d, ResourceVolcengineRouteTable()); err != nil { return fmt.Errorf("error on reading route table %q, %w", d.Id(), err) } return nil } -func resourceVestackRouteTableUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineRouteTableUpdate(d *schema.ResourceData, meta interface{}) error { routeTableService := NewRouteTableService(meta.(*ve.SdkClient)) - if err := routeTableService.Dispatcher.Update(routeTableService, d, ResourceVestackRouteTable()); err != nil { + if err := routeTableService.Dispatcher.Update(routeTableService, d, ResourceVolcengineRouteTable()); err != nil { return fmt.Errorf("error on updating route table %q, %w", d.Id(), err) } - return resourceVestackRouteTableRead(d, meta) + return resourceVolcengineRouteTableRead(d, meta) } -func resourceVestackRouteTableDelete(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineRouteTableDelete(d *schema.ResourceData, meta interface{}) error { routeTableService := NewRouteTableService(meta.(*ve.SdkClient)) - if err := routeTableService.Dispatcher.Delete(routeTableService, d, ResourceVestackRouteTable()); err != nil { + if err := routeTableService.Dispatcher.Delete(routeTableService, d, ResourceVolcengineRouteTable()); err != nil { return fmt.Errorf("error on deleting route table %q, %w", d.Id(), err) } return nil diff --git a/vestack/vpc/route_table/service_vestack_route_table.go b/volcengine/vpc/route_table/service_volcengine_route_table.go similarity index 80% rename from vestack/vpc/route_table/service_vestack_route_table.go rename to volcengine/vpc/route_table/service_volcengine_route_table.go index 6fb58145..b1d92f70 100644 --- a/vestack/vpc/route_table/service_vestack_route_table.go +++ b/volcengine/vpc/route_table/service_volcengine_route_table.go @@ -8,27 +8,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackRouteTableService struct { +type VolcengineRouteTableService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewRouteTableService(c *ve.SdkClient) *VestackRouteTableService { - return &VestackRouteTableService{ +func NewRouteTableService(c *ve.SdkClient) *VolcengineRouteTableService { + return &VolcengineRouteTableService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackRouteTableService) GetClient() *ve.SdkClient { +func (s *VolcengineRouteTableService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackRouteTableService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineRouteTableService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -87,7 +87,7 @@ func (s *VestackRouteTableService) ReadResources(m map[string]interface{}) (data return res, nil } -func (s *VestackRouteTableService) ReadResource(resourceData *schema.ResourceData, tableId string) (data map[string]interface{}, err error) { +func (s *VolcengineRouteTableService) ReadResource(resourceData *schema.ResourceData, tableId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -113,7 +113,7 @@ func (s *VestackRouteTableService) ReadResource(resourceData *schema.ResourceDat return data, err } -func (s *VestackRouteTableService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineRouteTableService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -138,7 +138,7 @@ func (s *VestackRouteTableService) RefreshResourceState(resourceData *schema.Res } } -func (VestackRouteTableService) WithResourceResponseHandlers(tables map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineRouteTableService) WithResourceResponseHandlers(tables map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return tables, nil, nil } @@ -146,7 +146,7 @@ func (VestackRouteTableService) WithResourceResponseHandlers(tables map[string]i } -func (s *VestackRouteTableService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineRouteTableService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "CreateRouteTable", @@ -169,7 +169,7 @@ func (s *VestackRouteTableService) CreateResource(resourceData *schema.ResourceD return []ve.Callback{callback} } -func (s *VestackRouteTableService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineRouteTableService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifyRouteTableAttributes", @@ -191,7 +191,7 @@ func (s *VestackRouteTableService) ModifyResource(resourceData *schema.ResourceD return []ve.Callback{callback} } -func (s *VestackRouteTableService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineRouteTableService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "DeleteRouteTable", @@ -229,7 +229,7 @@ func (s *VestackRouteTableService) RemoveResource(resourceData *schema.ResourceD return []ve.Callback{callback} } -func (s *VestackRouteTableService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineRouteTableService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -248,6 +248,6 @@ func (s *VestackRouteTableService) DatasourceResources(*schema.ResourceData, *sc } } -func (s *VestackRouteTableService) ReadResourceId(id string) string { +func (s *VolcengineRouteTableService) ReadResourceId(id string) string { return id } diff --git a/vestack/vpc/route_table_associate/common_vestack_route_table_associate.go b/volcengine/vpc/route_table_associate/common_volcengine_route_table_associate.go similarity index 100% rename from vestack/vpc/route_table_associate/common_vestack_route_table_associate.go rename to volcengine/vpc/route_table_associate/common_volcengine_route_table_associate.go diff --git a/vestack/vpc/route_table_associate/resource_vestack_route_table_associate.go b/volcengine/vpc/route_table_associate/resource_volcengine_route_table_associate.go similarity index 58% rename from vestack/vpc/route_table_associate/resource_vestack_route_table_associate.go rename to volcengine/vpc/route_table_associate/resource_volcengine_route_table_associate.go index fd56d282..7a3def79 100644 --- a/vestack/vpc/route_table_associate/resource_vestack_route_table_associate.go +++ b/volcengine/vpc/route_table_associate/resource_volcengine_route_table_associate.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -12,16 +12,16 @@ import ( Import Route table associate address can be imported using the route_table_id:subnet_id, e.g. ``` -$ terraform import vestack_route_table_associate.default vtb-2fdzao4h726f45******:subnet-2fdzaou4liw3k5oxruv****** +$ terraform import volcengine_route_table_associate.default vtb-2fdzao4h726f45******:subnet-2fdzaou4liw3k5oxruv****** ``` */ -func ResourceVestackRouteTableAssociate() *schema.Resource { +func ResourceVolcengineRouteTableAssociate() *schema.Resource { return &schema.Resource{ - Delete: resourceVestackRouteTableAssociateDelete, - Create: resourceVestackRouteTableAssociateCreate, - Read: resourceVestackRouteTableAssociateRead, + Delete: resourceVolcengineRouteTableAssociateDelete, + Create: resourceVolcengineRouteTableAssociateCreate, + Read: resourceVolcengineRouteTableAssociateRead, Importer: &schema.ResourceImporter{ State: routeTableAssociateImporter, }, @@ -42,25 +42,25 @@ func ResourceVestackRouteTableAssociate() *schema.Resource { } } -func resourceVestackRouteTableAssociateCreate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineRouteTableAssociateCreate(d *schema.ResourceData, meta interface{}) error { routeTableAssociateService := NewRouteTableAssociateService(meta.(*ve.SdkClient)) - if err := routeTableAssociateService.Dispatcher.Create(routeTableAssociateService, d, ResourceVestackRouteTableAssociate()); err != nil { + if err := routeTableAssociateService.Dispatcher.Create(routeTableAssociateService, d, ResourceVolcengineRouteTableAssociate()); err != nil { return fmt.Errorf("error on creating route table associate %q, %w", d.Id(), err) } - return resourceVestackRouteTableAssociateRead(d, meta) + return resourceVolcengineRouteTableAssociateRead(d, meta) } -func resourceVestackRouteTableAssociateRead(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineRouteTableAssociateRead(d *schema.ResourceData, meta interface{}) error { routeTableAssociateService := NewRouteTableAssociateService(meta.(*ve.SdkClient)) - if err := routeTableAssociateService.Dispatcher.Read(routeTableAssociateService, d, ResourceVestackRouteTableAssociate()); err != nil { + if err := routeTableAssociateService.Dispatcher.Read(routeTableAssociateService, d, ResourceVolcengineRouteTableAssociate()); err != nil { return fmt.Errorf("error on reading route table associate %q, %w", d.Id(), err) } return nil } -func resourceVestackRouteTableAssociateDelete(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineRouteTableAssociateDelete(d *schema.ResourceData, meta interface{}) error { routeTableAssociateService := NewRouteTableAssociateService(meta.(*ve.SdkClient)) - if err := routeTableAssociateService.Dispatcher.Delete(routeTableAssociateService, d, ResourceVestackRouteTableAssociate()); err != nil { + if err := routeTableAssociateService.Dispatcher.Delete(routeTableAssociateService, d, ResourceVolcengineRouteTableAssociate()); err != nil { return fmt.Errorf("error on deleting route table associate %q, %w", d.Id(), err) } return nil diff --git a/vestack/vpc/route_table_associate/service_vestack_route_table_associate.go b/volcengine/vpc/route_table_associate/service_volcengine_route_table_associate.go similarity index 76% rename from vestack/vpc/route_table_associate/service_vestack_route_table_associate.go rename to volcengine/vpc/route_table_associate/service_volcengine_route_table_associate.go index 7afaacbe..c0a9d2bf 100644 --- a/vestack/vpc/route_table_associate/service_vestack_route_table_associate.go +++ b/volcengine/vpc/route_table_associate/service_volcengine_route_table_associate.go @@ -8,27 +8,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackRouteTableAssociateService struct { +type VolcengineRouteTableAssociateService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewRouteTableAssociateService(c *ve.SdkClient) *VestackRouteTableAssociateService { - return &VestackRouteTableAssociateService{ +func NewRouteTableAssociateService(c *ve.SdkClient) *VolcengineRouteTableAssociateService { + return &VolcengineRouteTableAssociateService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackRouteTableAssociateService) GetClient() *ve.SdkClient { +func (s *VolcengineRouteTableAssociateService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackRouteTableAssociateService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineRouteTableAssociateService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -64,7 +64,7 @@ func (s *VestackRouteTableAssociateService) ReadResources(m map[string]interface }) } -func (s *VestackRouteTableAssociateService) ReadResource(resourceData *schema.ResourceData, associateId string) (data map[string]interface{}, err error) { +func (s *VolcengineRouteTableAssociateService) ReadResource(resourceData *schema.ResourceData, associateId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -122,7 +122,7 @@ func (s *VestackRouteTableAssociateService) ReadResource(resourceData *schema.Re return data, err } -func (s *VestackRouteTableAssociateService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineRouteTableAssociateService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -147,7 +147,7 @@ func (s *VestackRouteTableAssociateService) RefreshResourceState(resourceData *s } } -func (VestackRouteTableAssociateService) WithResourceResponseHandlers(routeTables map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineRouteTableAssociateService) WithResourceResponseHandlers(routeTables map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return routeTables, nil, nil } @@ -155,7 +155,7 @@ func (VestackRouteTableAssociateService) WithResourceResponseHandlers(routeTable } -func (s *VestackRouteTableAssociateService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineRouteTableAssociateService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "AssociateRouteTable", @@ -177,11 +177,11 @@ func (s *VestackRouteTableAssociateService) CreateResource(resourceData *schema. return []ve.Callback{callback} } -func (s *VestackRouteTableAssociateService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineRouteTableAssociateService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { return nil } -func (s *VestackRouteTableAssociateService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineRouteTableAssociateService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { ids := strings.Split(s.ReadResourceId(resourceData.Id()), ":") callback := ve.Callback{ Call: ve.SdkCall{ @@ -218,10 +218,10 @@ func (s *VestackRouteTableAssociateService) RemoveResource(resourceData *schema. return []ve.Callback{callback} } -func (s *VestackRouteTableAssociateService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineRouteTableAssociateService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{} } -func (s *VestackRouteTableAssociateService) ReadResourceId(id string) string { +func (s *VolcengineRouteTableAssociateService) ReadResourceId(id string) string { return id } diff --git a/vestack/vpc/security_group/data_source_vestack_security_groups.go b/volcengine/vpc/security_group/data_source_volcengine_security_groups.go similarity index 88% rename from vestack/vpc/security_group/data_source_vestack_security_groups.go rename to volcengine/vpc/security_group/data_source_volcengine_security_groups.go index 76e89c17..983b725f 100644 --- a/vestack/vpc/security_group/data_source_vestack_security_groups.go +++ b/volcengine/vpc/security_group/data_source_volcengine_security_groups.go @@ -3,12 +3,12 @@ package security_group import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackSecurityGroups() *schema.Resource { +func DataSourceVolcengineSecurityGroups() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackSecurityGroupsRead, + Read: dataSourceVolcengineSecurityGroupsRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -88,7 +88,7 @@ func DataSourceVestackSecurityGroups() *schema.Resource { } } -func dataSourceVestackSecurityGroupsRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineSecurityGroupsRead(d *schema.ResourceData, meta interface{}) error { securityGroupService := NewSecurityGroupService(meta.(*ve.SdkClient)) - return securityGroupService.Dispatcher.Data(securityGroupService, d, DataSourceVestackSecurityGroups()) + return securityGroupService.Dispatcher.Data(securityGroupService, d, DataSourceVolcengineSecurityGroups()) } diff --git a/vestack/vpc/security_group/resource_vestack_security_group.go b/volcengine/vpc/security_group/resource_volcengine_security_group.go similarity index 65% rename from vestack/vpc/security_group/resource_vestack_security_group.go rename to volcengine/vpc/security_group/resource_volcengine_security_group.go index fb3c117b..241ec371 100644 --- a/vestack/vpc/security_group/resource_vestack_security_group.go +++ b/volcengine/vpc/security_group/resource_volcengine_security_group.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -12,17 +12,17 @@ import ( Import SecurityGroup can be imported using the id, e.g. ``` -$ terraform import vestack_security_group.default sg-273ycgql3ig3k7fap8t3dyvqx +$ terraform import volcengine_security_group.default sg-273ycgql3ig3k7fap8t3dyvqx ``` */ -func ResourceVestackSecurityGroup() *schema.Resource { +func ResourceVolcengineSecurityGroup() *schema.Resource { return &schema.Resource{ - Create: resourceVestackSecurityGroupCreate, - Read: resourceVestackSecurityGroupRead, - Update: resourceVestackSecurityGroupUpdate, - Delete: resourceVestackSecurityGroupDelete, + Create: resourceVolcengineSecurityGroupCreate, + Read: resourceVolcengineSecurityGroupRead, + Update: resourceVolcengineSecurityGroupUpdate, + Delete: resourceVolcengineSecurityGroupDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -58,36 +58,36 @@ func ResourceVestackSecurityGroup() *schema.Resource { } } -func resourceVestackSecurityGroupCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineSecurityGroupCreate(d *schema.ResourceData, meta interface{}) (err error) { securityGroupService := NewSecurityGroupService(meta.(*ve.SdkClient)) - err = securityGroupService.Dispatcher.Create(securityGroupService, d, ResourceVestackSecurityGroup()) + err = securityGroupService.Dispatcher.Create(securityGroupService, d, ResourceVolcengineSecurityGroup()) if err != nil { return fmt.Errorf("error on creating securityGroupService %q, %w", d.Id(), err) } - return resourceVestackSecurityGroupRead(d, meta) + return resourceVolcengineSecurityGroupRead(d, meta) } -func resourceVestackSecurityGroupRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineSecurityGroupRead(d *schema.ResourceData, meta interface{}) (err error) { securityGroupService := NewSecurityGroupService(meta.(*ve.SdkClient)) - err = securityGroupService.Dispatcher.Read(securityGroupService, d, ResourceVestackSecurityGroup()) + err = securityGroupService.Dispatcher.Read(securityGroupService, d, ResourceVolcengineSecurityGroup()) if err != nil { return fmt.Errorf("error on reading securityGroupService %q, %w", d.Id(), err) } return err } -func resourceVestackSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) (err error) { securityGroupService := NewSecurityGroupService(meta.(*ve.SdkClient)) - err = securityGroupService.Dispatcher.Update(securityGroupService, d, ResourceVestackSecurityGroup()) + err = securityGroupService.Dispatcher.Update(securityGroupService, d, ResourceVolcengineSecurityGroup()) if err != nil { return fmt.Errorf("error on updating securityGroupService %q, %w", d.Id(), err) } - return resourceVestackSecurityGroupRead(d, meta) + return resourceVolcengineSecurityGroupRead(d, meta) } -func resourceVestackSecurityGroupDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineSecurityGroupDelete(d *schema.ResourceData, meta interface{}) (err error) { securityGroupService := NewSecurityGroupService(meta.(*ve.SdkClient)) - err = securityGroupService.Dispatcher.Delete(securityGroupService, d, ResourceVestackSecurityGroup()) + err = securityGroupService.Dispatcher.Delete(securityGroupService, d, ResourceVolcengineSecurityGroup()) if err != nil { return fmt.Errorf("error on deleting securityGroupService %q, %w", d.Id(), err) } diff --git a/vestack/vpc/security_group/service_vestack_security_group.go b/volcengine/vpc/security_group/service_volcengine_security_group.go similarity index 81% rename from vestack/vpc/security_group/service_vestack_security_group.go rename to volcengine/vpc/security_group/service_volcengine_security_group.go index a8314473..c07381c3 100644 --- a/vestack/vpc/security_group/service_vestack_security_group.go +++ b/volcengine/vpc/security_group/service_volcengine_security_group.go @@ -7,28 +7,28 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" - "github.com/volcengine/terraform-provider-vestack/vestack/vpc/vpc" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" + "github.com/volcengine/terraform-provider-volcengine/volcengine/vpc/vpc" ) -type VestackSecurityGroupService struct { +type VolcengineSecurityGroupService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewSecurityGroupService(c *ve.SdkClient) *VestackSecurityGroupService { - return &VestackSecurityGroupService{ +func NewSecurityGroupService(c *ve.SdkClient) *VolcengineSecurityGroupService { + return &VolcengineSecurityGroupService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackSecurityGroupService) GetClient() *ve.SdkClient { +func (s *VolcengineSecurityGroupService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackSecurityGroupService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineSecurityGroupService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -67,7 +67,7 @@ func (s *VestackSecurityGroupService) ReadResources(m map[string]interface{}) (d }) } -func (s *VestackSecurityGroupService) ReadResource(resourceData *schema.ResourceData, securityGroupId string) (data map[string]interface{}, err error) { +func (s *VolcengineSecurityGroupService) ReadResource(resourceData *schema.ResourceData, securityGroupId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -93,7 +93,7 @@ func (s *VestackSecurityGroupService) ReadResource(resourceData *schema.Resource return data, err } -func (s *VestackSecurityGroupService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineSecurityGroupService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -127,7 +127,7 @@ func (s *VestackSecurityGroupService) RefreshResourceState(resourceData *schema. } -func (VestackSecurityGroupService) WithResourceResponseHandlers(subnet map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineSecurityGroupService) WithResourceResponseHandlers(subnet map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return subnet, nil, nil } @@ -135,7 +135,7 @@ func (VestackSecurityGroupService) WithResourceResponseHandlers(subnet map[strin } -func (s *VestackSecurityGroupService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineSecurityGroupService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "CreateSecurityGroup", @@ -170,7 +170,7 @@ func (s *VestackSecurityGroupService) CreateResource(resourceData *schema.Resour return []ve.Callback{callback} } -func (s *VestackSecurityGroupService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineSecurityGroupService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifySecurityGroupAttributes", @@ -202,7 +202,7 @@ func (s *VestackSecurityGroupService) ModifyResource(resourceData *schema.Resour return []ve.Callback{callback} } -func (s *VestackSecurityGroupService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineSecurityGroupService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "DeleteSecurityGroup", @@ -240,7 +240,7 @@ func (s *VestackSecurityGroupService) RemoveResource(resourceData *schema.Resour return []ve.Callback{callback} } -func (s *VestackSecurityGroupService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineSecurityGroupService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -264,6 +264,6 @@ func (s *VestackSecurityGroupService) DatasourceResources(*schema.ResourceData, } } -func (s *VestackSecurityGroupService) ReadResourceId(id string) string { +func (s *VolcengineSecurityGroupService) ReadResourceId(id string) string { return id } diff --git a/vestack/vpc/security_group_rule/resource_vestack_security_group_rule.go b/volcengine/vpc/security_group_rule/resource_volcengine_security_group_rule.go similarity index 74% rename from vestack/vpc/security_group_rule/resource_vestack_security_group_rule.go rename to volcengine/vpc/security_group_rule/resource_volcengine_security_group_rule.go index 0986b7f2..6e7a38c0 100644 --- a/vestack/vpc/security_group_rule/resource_vestack_security_group_rule.go +++ b/volcengine/vpc/security_group_rule/resource_volcengine_security_group_rule.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -13,17 +13,17 @@ import ( Import SecurityGroupRule can be imported using the id, e.g. ``` -$ terraform import vestack_security_group_rule.default ID is a string concatenated with colons(SecurityGroupId:Protocol:PortStart:PortEnd:CidrIp) +$ terraform import volcengine_security_group_rule.default ID is a string concatenated with colons(SecurityGroupId:Protocol:PortStart:PortEnd:CidrIp) ``` */ -func ResourceVestackSecurityGroupRule() *schema.Resource { +func ResourceVolcengineSecurityGroupRule() *schema.Resource { return &schema.Resource{ - Create: resourceVestackSecurityGroupRuleCreate, - Read: resourceVestackSecurityGroupRuleRead, - Update: resourceVestackSecurityGroupRuleUpdate, - Delete: resourceVestackSecurityGroupRuleDelete, + Create: resourceVolcengineSecurityGroupRuleCreate, + Read: resourceVolcengineSecurityGroupRuleRead, + Update: resourceVolcengineSecurityGroupRuleUpdate, + Delete: resourceVolcengineSecurityGroupRuleDelete, Importer: &schema.ResourceImporter{ State: importSecurityGroupRule, }, @@ -112,36 +112,36 @@ func ResourceVestackSecurityGroupRule() *schema.Resource { } } -func resourceVestackSecurityGroupRuleCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineSecurityGroupRuleCreate(d *schema.ResourceData, meta interface{}) (err error) { securityGroupRuleService := NewSecurityGroupRuleService(meta.(*ve.SdkClient)) - err = securityGroupRuleService.Dispatcher.Create(securityGroupRuleService, d, ResourceVestackSecurityGroupRule()) + err = securityGroupRuleService.Dispatcher.Create(securityGroupRuleService, d, ResourceVolcengineSecurityGroupRule()) if err != nil { return fmt.Errorf("error on creating securityGroupRuleService %q, %w", d.Id(), err) } - return resourceVestackSecurityGroupRuleRead(d, meta) + return resourceVolcengineSecurityGroupRuleRead(d, meta) } -func resourceVestackSecurityGroupRuleRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineSecurityGroupRuleRead(d *schema.ResourceData, meta interface{}) (err error) { securityGroupRuleService := NewSecurityGroupRuleService(meta.(*ve.SdkClient)) - err = securityGroupRuleService.Dispatcher.Read(securityGroupRuleService, d, ResourceVestackSecurityGroupRule()) + err = securityGroupRuleService.Dispatcher.Read(securityGroupRuleService, d, ResourceVolcengineSecurityGroupRule()) if err != nil { return fmt.Errorf("error on reading securityGroupRuleService %q, %w", d.Id(), err) } return err } -func resourceVestackSecurityGroupRuleUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineSecurityGroupRuleUpdate(d *schema.ResourceData, meta interface{}) (err error) { securityGroupRuleService := NewSecurityGroupRuleService(meta.(*ve.SdkClient)) - err = securityGroupRuleService.Dispatcher.Update(securityGroupRuleService, d, ResourceVestackSecurityGroupRule()) + err = securityGroupRuleService.Dispatcher.Update(securityGroupRuleService, d, ResourceVolcengineSecurityGroupRule()) if err != nil { return fmt.Errorf("error on updating securityGroupRuleService %q, %w", d.Id(), err) } - return resourceVestackSecurityGroupRuleRead(d, meta) + return resourceVolcengineSecurityGroupRuleRead(d, meta) } -func resourceVestackSecurityGroupRuleDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineSecurityGroupRuleDelete(d *schema.ResourceData, meta interface{}) (err error) { securityGroupRuleService := NewSecurityGroupRuleService(meta.(*ve.SdkClient)) - err = securityGroupRuleService.Dispatcher.Delete(securityGroupRuleService, d, ResourceVestackSecurityGroupRule()) + err = securityGroupRuleService.Dispatcher.Delete(securityGroupRuleService, d, ResourceVolcengineSecurityGroupRule()) if err != nil { return fmt.Errorf("error on deleting securityGroupRuleService %q, %w", d.Id(), err) } diff --git a/vestack/vpc/security_group_rule/service_vestack_security_group_rule.go b/volcengine/vpc/security_group_rule/service_volcengine_security_group_rule.go similarity index 82% rename from vestack/vpc/security_group_rule/service_vestack_security_group_rule.go rename to volcengine/vpc/security_group_rule/service_volcengine_security_group_rule.go index c3fb3234..0f14c495 100644 --- a/vestack/vpc/security_group_rule/service_vestack_security_group_rule.go +++ b/volcengine/vpc/security_group_rule/service_volcengine_security_group_rule.go @@ -8,11 +8,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackSecurityGroupRuleService struct { +type VolcengineSecurityGroupRuleService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } @@ -24,18 +24,18 @@ const ( DirectionEgress = Direction("egress") ) -func NewSecurityGroupRuleService(c *ve.SdkClient) *VestackSecurityGroupRuleService { - return &VestackSecurityGroupRuleService{ +func NewSecurityGroupRuleService(c *ve.SdkClient) *VolcengineSecurityGroupRuleService { + return &VolcengineSecurityGroupRuleService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackSecurityGroupRuleService) GetClient() *ve.SdkClient { +func (s *VolcengineSecurityGroupRuleService) GetClient() *ve.SdkClient { return s.Client } -func (VestackSecurityGroupRuleService) WithResourceResponseHandlers(rule map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineSecurityGroupRuleService) WithResourceResponseHandlers(rule map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return rule, nil, nil } @@ -43,7 +43,7 @@ func (VestackSecurityGroupRuleService) WithResourceResponseHandlers(rule map[str } -func (s *VestackSecurityGroupRuleService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineSecurityGroupRuleService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { var action string direction := resourceData.Get("direction").(string) if direction == string(DirectionEgress) { @@ -94,19 +94,19 @@ func (s *VestackSecurityGroupRuleService) CreateResource(resourceData *schema.Re return []ve.Callback{callback} } -func (s *VestackSecurityGroupRuleService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineSecurityGroupRuleService) ReadResources(condition map[string]interface{}) (data []interface{}, err error) { return nil, nil } -func (s *VestackSecurityGroupRuleService) ReadResource(resourceData *schema.ResourceData, tmpId string) (data map[string]interface{}, err error) { +func (s *VolcengineSecurityGroupRuleService) ReadResource(resourceData *schema.ResourceData, tmpId string) (data map[string]interface{}, err error) { return nil, nil } -func (s *VestackSecurityGroupRuleService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineSecurityGroupRuleService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return nil } -func (s *VestackSecurityGroupRuleService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineSecurityGroupRuleService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { var action string direction := resourceData.Get("direction").(string) if direction == string(DirectionEgress) { @@ -168,7 +168,7 @@ func (s *VestackSecurityGroupRuleService) ModifyResource(resourceData *schema.Re return []ve.Callback{callback} } -func (s *VestackSecurityGroupRuleService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineSecurityGroupRuleService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { var action string direction := resourceData.Get("direction").(string) if direction == string(DirectionEgress) { @@ -218,7 +218,7 @@ func (s *VestackSecurityGroupRuleService) RemoveResource(resourceData *schema.Re return []ve.Callback{callback} } -func (s *VestackSecurityGroupRuleService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineSecurityGroupRuleService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{} } @@ -255,7 +255,7 @@ func importSecurityGroupRule(d *schema.ResourceData, meta interface{}) ([]*schem return []*schema.ResourceData{d}, nil } -func (s *VestackSecurityGroupRuleService) ReadResourceId(id string) string { +func (s *VolcengineSecurityGroupRuleService) ReadResourceId(id string) string { items := strings.Split(id, ":") return items[0] } diff --git a/vestack/vpc/subnet/data_source_vestack_subnets.go b/volcengine/vpc/subnet/data_source_volcengine_subnets.go similarity index 91% rename from vestack/vpc/subnet/data_source_vestack_subnets.go rename to volcengine/vpc/subnet/data_source_volcengine_subnets.go index 3246bb6c..a87b6aa1 100644 --- a/vestack/vpc/subnet/data_source_vestack_subnets.go +++ b/volcengine/vpc/subnet/data_source_volcengine_subnets.go @@ -3,12 +3,12 @@ package subnet import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackSubnets() *schema.Resource { +func DataSourceVolcengineSubnets() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackSubnetsRead, + Read: dataSourceVolcengineSubnetsRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -113,7 +113,7 @@ func DataSourceVestackSubnets() *schema.Resource { } } -func dataSourceVestackSubnetsRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineSubnetsRead(d *schema.ResourceData, meta interface{}) error { subnetService := NewSubnetService(meta.(*ve.SdkClient)) - return subnetService.Dispatcher.Data(subnetService, d, DataSourceVestackSubnets()) + return subnetService.Dispatcher.Data(subnetService, d, DataSourceVolcengineSubnets()) } diff --git a/vestack/vpc/subnet/resource_vestack_subnet.go b/volcengine/vpc/subnet/resource_volcengine_subnet.go similarity index 70% rename from vestack/vpc/subnet/resource_vestack_subnet.go rename to volcengine/vpc/subnet/resource_volcengine_subnet.go index 315e4b48..c16203fc 100644 --- a/vestack/vpc/subnet/resource_vestack_subnet.go +++ b/volcengine/vpc/subnet/resource_volcengine_subnet.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -13,17 +13,17 @@ import ( Import Subnet can be imported using the id, e.g. ``` -$ terraform import vestack_subnet.default subnet-274oj9a8rs9a87fap8sf9515b +$ terraform import volcengine_subnet.default subnet-274oj9a8rs9a87fap8sf9515b ``` */ -func ResourceVestackSubnet() *schema.Resource { +func ResourceVolcengineSubnet() *schema.Resource { return &schema.Resource{ - Delete: resourceVestackSubnetDelete, - Create: resourceVestackSubnetCreate, - Read: resourceVestackSubnetRead, - Update: resourceVestackSubnetUpdate, + Delete: resourceVolcengineSubnetDelete, + Create: resourceVolcengineSubnetCreate, + Read: resourceVolcengineSubnetRead, + Update: resourceVolcengineSubnetUpdate, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -72,33 +72,33 @@ func ResourceVestackSubnet() *schema.Resource { } } -func resourceVestackSubnetCreate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineSubnetCreate(d *schema.ResourceData, meta interface{}) error { subnetService := NewSubnetService(meta.(*ve.SdkClient)) - if err := subnetService.Dispatcher.Create(subnetService, d, ResourceVestackSubnet()); err != nil { + if err := subnetService.Dispatcher.Create(subnetService, d, ResourceVolcengineSubnet()); err != nil { return fmt.Errorf("error on creating subnet %q, %w", d.Id(), err) } - return resourceVestackSubnetRead(d, meta) + return resourceVolcengineSubnetRead(d, meta) } -func resourceVestackSubnetRead(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineSubnetRead(d *schema.ResourceData, meta interface{}) error { subnetService := NewSubnetService(meta.(*ve.SdkClient)) - if err := subnetService.Dispatcher.Read(subnetService, d, ResourceVestackSubnet()); err != nil { + if err := subnetService.Dispatcher.Read(subnetService, d, ResourceVolcengineSubnet()); err != nil { return fmt.Errorf("error on reading subnet %q, %w", d.Id(), err) } return nil } -func resourceVestackSubnetUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineSubnetUpdate(d *schema.ResourceData, meta interface{}) error { subnetService := NewSubnetService(meta.(*ve.SdkClient)) - if err := subnetService.Dispatcher.Update(subnetService, d, ResourceVestackSubnet()); err != nil { + if err := subnetService.Dispatcher.Update(subnetService, d, ResourceVolcengineSubnet()); err != nil { return fmt.Errorf("error on updating subnet %q, %w", d.Id(), err) } - return resourceVestackSubnetRead(d, meta) + return resourceVolcengineSubnetRead(d, meta) } -func resourceVestackSubnetDelete(d *schema.ResourceData, meta interface{}) error { +func resourceVolcengineSubnetDelete(d *schema.ResourceData, meta interface{}) error { subnetService := NewSubnetService(meta.(*ve.SdkClient)) - if err := subnetService.Dispatcher.Delete(subnetService, d, ResourceVestackSubnet()); err != nil { + if err := subnetService.Dispatcher.Delete(subnetService, d, ResourceVolcengineSubnet()); err != nil { return fmt.Errorf("error on deleting subnet %q, %w", d.Id(), err) } return nil diff --git a/vestack/vpc/subnet/service_vestack_subnet.go b/volcengine/vpc/subnet/service_volcengine_subnet.go similarity index 81% rename from vestack/vpc/subnet/service_vestack_subnet.go rename to volcengine/vpc/subnet/service_volcengine_subnet.go index a78d2180..5f815824 100644 --- a/vestack/vpc/subnet/service_vestack_subnet.go +++ b/volcengine/vpc/subnet/service_volcengine_subnet.go @@ -7,28 +7,28 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" - "github.com/volcengine/terraform-provider-vestack/vestack/vpc/vpc" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" + "github.com/volcengine/terraform-provider-volcengine/volcengine/vpc/vpc" ) -type VestackSubnetService struct { +type VolcengineSubnetService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewSubnetService(c *ve.SdkClient) *VestackSubnetService { - return &VestackSubnetService{ +func NewSubnetService(c *ve.SdkClient) *VolcengineSubnetService { + return &VolcengineSubnetService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackSubnetService) GetClient() *ve.SdkClient { +func (s *VolcengineSubnetService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackSubnetService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineSubnetService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -66,7 +66,7 @@ func (s *VestackSubnetService) ReadResources(m map[string]interface{}) (data []i }) } -func (s *VestackSubnetService) ReadResource(resourceData *schema.ResourceData, subnetId string) (data map[string]interface{}, err error) { +func (s *VolcengineSubnetService) ReadResource(resourceData *schema.ResourceData, subnetId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -92,7 +92,7 @@ func (s *VestackSubnetService) ReadResource(resourceData *schema.ResourceData, s return data, err } -func (s *VestackSubnetService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineSubnetService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -126,7 +126,7 @@ func (s *VestackSubnetService) RefreshResourceState(resourceData *schema.Resourc } -func (VestackSubnetService) WithResourceResponseHandlers(subnet map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineSubnetService) WithResourceResponseHandlers(subnet map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return subnet, nil, nil } @@ -134,7 +134,7 @@ func (VestackSubnetService) WithResourceResponseHandlers(subnet map[string]inter } -func (s *VestackSubnetService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineSubnetService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "CreateSubnet", @@ -169,7 +169,7 @@ func (s *VestackSubnetService) CreateResource(resourceData *schema.ResourceData, return []ve.Callback{callback} } -func (s *VestackSubnetService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineSubnetService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifySubnetAttributes", @@ -194,7 +194,7 @@ func (s *VestackSubnetService) ModifyResource(resourceData *schema.ResourceData, return []ve.Callback{callback} } -func (s *VestackSubnetService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineSubnetService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { id := resourceData.Id() callback := ve.Callback{ Call: ve.SdkCall{ @@ -236,7 +236,7 @@ func (s *VestackSubnetService) RemoveResource(resourceData *schema.ResourceData, return []ve.Callback{callback} } -func (s *VestackSubnetService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineSubnetService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -261,6 +261,6 @@ func (s *VestackSubnetService) DatasourceResources(*schema.ResourceData, *schema } } -func (s *VestackSubnetService) ReadResourceId(id string) string { +func (s *VolcengineSubnetService) ReadResourceId(id string) string { return id } diff --git a/vestack/vpc/vpc/data_source_vestack_vpcs.go b/volcengine/vpc/vpc/data_source_volcengine_vpcs.go similarity index 93% rename from vestack/vpc/vpc/data_source_vestack_vpcs.go rename to volcengine/vpc/vpc/data_source_volcengine_vpcs.go index 1975696d..0ae4a50a 100644 --- a/vestack/vpc/vpc/data_source_vestack_vpcs.go +++ b/volcengine/vpc/vpc/data_source_volcengine_vpcs.go @@ -3,12 +3,12 @@ package vpc import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) -func DataSourceVestackVpcs() *schema.Resource { +func DataSourceVolcengineVpcs() *schema.Resource { return &schema.Resource{ - Read: dataSourceVestackVpcsRead, + Read: dataSourceVolcengineVpcsRead, Schema: map[string]*schema.Schema{ "ids": { Type: schema.TypeSet, @@ -171,7 +171,7 @@ func DataSourceVestackVpcs() *schema.Resource { } } -func dataSourceVestackVpcsRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceVolcengineVpcsRead(d *schema.ResourceData, meta interface{}) error { vpcService := NewVpcService(meta.(*ve.SdkClient)) - return vpcService.Dispatcher.Data(vpcService, d, DataSourceVestackVpcs()) + return vpcService.Dispatcher.Data(vpcService, d, DataSourceVolcengineVpcs()) } diff --git a/vestack/vpc/vpc/resource_vestack_vpc.go b/volcengine/vpc/vpc/resource_volcengine_vpc.go similarity index 63% rename from vestack/vpc/vpc/resource_vestack_vpc.go rename to volcengine/vpc/vpc/resource_volcengine_vpc.go index 71a2edad..28821a17 100644 --- a/vestack/vpc/vpc/resource_vestack_vpc.go +++ b/volcengine/vpc/vpc/resource_volcengine_vpc.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - ve "github.com/volcengine/terraform-provider-vestack/common" + ve "github.com/volcengine/terraform-provider-volcengine/common" ) /* @@ -13,17 +13,17 @@ import ( Import VPC can be imported using the id, e.g. ``` -$ terraform import vestack_vpc.default vpc-mizl7m1kqccg5smt1bdpijuj +$ terraform import volcengine_vpc.default vpc-mizl7m1kqccg5smt1bdpijuj ``` */ -func ResourceVestackVpc() *schema.Resource { +func ResourceVolcengineVpc() *schema.Resource { resource := &schema.Resource{ - Create: resourceVestackVpcCreate, - Read: resourceVestackVpcRead, - Update: resourceVestackVpcUpdate, - Delete: resourceVestackVpcDelete, + Create: resourceVolcengineVpcCreate, + Read: resourceVolcengineVpcRead, + Update: resourceVolcengineVpcUpdate, + Delete: resourceVolcengineVpcDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -68,40 +68,40 @@ func ResourceVestackVpc() *schema.Resource { }, }, } - ve.MergeDateSourceToResource(DataSourceVestackVpcs().Schema["vpcs"].Elem.(*schema.Resource).Schema, &resource.Schema) + ve.MergeDateSourceToResource(DataSourceVolcengineVpcs().Schema["vpcs"].Elem.(*schema.Resource).Schema, &resource.Schema) return resource } -func resourceVestackVpcCreate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineVpcCreate(d *schema.ResourceData, meta interface{}) (err error) { vpcService := NewVpcService(meta.(*ve.SdkClient)) - err = vpcService.Dispatcher.Create(vpcService, d, ResourceVestackVpc()) + err = vpcService.Dispatcher.Create(vpcService, d, ResourceVolcengineVpc()) if err != nil { return fmt.Errorf("error on creating vpc %q, %s", d.Id(), err) } - return resourceVestackVpcRead(d, meta) + return resourceVolcengineVpcRead(d, meta) } -func resourceVestackVpcRead(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineVpcRead(d *schema.ResourceData, meta interface{}) (err error) { vpcService := NewVpcService(meta.(*ve.SdkClient)) - err = vpcService.Dispatcher.Read(vpcService, d, ResourceVestackVpc()) + err = vpcService.Dispatcher.Read(vpcService, d, ResourceVolcengineVpc()) if err != nil { return fmt.Errorf("error on reading vpc %q, %s", d.Id(), err) } return err } -func resourceVestackVpcUpdate(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineVpcUpdate(d *schema.ResourceData, meta interface{}) (err error) { vpcService := NewVpcService(meta.(*ve.SdkClient)) - err = vpcService.Dispatcher.Update(vpcService, d, ResourceVestackVpc()) + err = vpcService.Dispatcher.Update(vpcService, d, ResourceVolcengineVpc()) if err != nil { return fmt.Errorf("error on updating vpc %q, %s", d.Id(), err) } - return resourceVestackVpcRead(d, meta) + return resourceVolcengineVpcRead(d, meta) } -func resourceVestackVpcDelete(d *schema.ResourceData, meta interface{}) (err error) { +func resourceVolcengineVpcDelete(d *schema.ResourceData, meta interface{}) (err error) { vpcService := NewVpcService(meta.(*ve.SdkClient)) - err = vpcService.Dispatcher.Delete(vpcService, d, ResourceVestackVpc()) + err = vpcService.Dispatcher.Delete(vpcService, d, ResourceVolcengineVpc()) if err != nil { return fmt.Errorf("error on deleting vpc %q, %s", d.Id(), err) } diff --git a/vestack/vpc/vpc/service_vestack_vpc.go b/volcengine/vpc/vpc/service_volcengine_vpc.go similarity index 81% rename from vestack/vpc/vpc/service_vestack_vpc.go rename to volcengine/vpc/vpc/service_volcengine_vpc.go index 9a3bf060..bd18f34e 100644 --- a/vestack/vpc/vpc/service_vestack_vpc.go +++ b/volcengine/vpc/vpc/service_volcengine_vpc.go @@ -7,27 +7,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - ve "github.com/volcengine/terraform-provider-vestack/common" - "github.com/volcengine/terraform-provider-vestack/logger" + ve "github.com/volcengine/terraform-provider-volcengine/common" + "github.com/volcengine/terraform-provider-volcengine/logger" ) -type VestackVpcService struct { +type VolcengineVpcService struct { Client *ve.SdkClient Dispatcher *ve.Dispatcher } -func NewVpcService(c *ve.SdkClient) *VestackVpcService { - return &VestackVpcService{ +func NewVpcService(c *ve.SdkClient) *VolcengineVpcService { + return &VolcengineVpcService{ Client: c, Dispatcher: &ve.Dispatcher{}, } } -func (s *VestackVpcService) GetClient() *ve.SdkClient { +func (s *VolcengineVpcService) GetClient() *ve.SdkClient { return s.Client } -func (s *VestackVpcService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { +func (s *VolcengineVpcService) ReadResources(m map[string]interface{}) (data []interface{}, err error) { var ( resp *map[string]interface{} results interface{} @@ -63,7 +63,7 @@ func (s *VestackVpcService) ReadResources(m map[string]interface{}) (data []inte }) } -func (s *VestackVpcService) ReadResource(resourceData *schema.ResourceData, vpcId string) (data map[string]interface{}, err error) { +func (s *VolcengineVpcService) ReadResource(resourceData *schema.ResourceData, vpcId string) (data map[string]interface{}, err error) { var ( results []interface{} ok bool @@ -89,7 +89,7 @@ func (s *VestackVpcService) ReadResource(resourceData *schema.ResourceData, vpcI return data, err } -func (s *VestackVpcService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { +func (s *VolcengineVpcService) RefreshResourceState(resourceData *schema.ResourceData, target []string, timeout time.Duration, id string) *resource.StateChangeConf { return &resource.StateChangeConf{ Pending: []string{}, Delay: 1 * time.Second, @@ -123,7 +123,7 @@ func (s *VestackVpcService) RefreshResourceState(resourceData *schema.ResourceDa } -func (VestackVpcService) WithResourceResponseHandlers(vpc map[string]interface{}) []ve.ResourceResponseHandler { +func (VolcengineVpcService) WithResourceResponseHandlers(vpc map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { return vpc, nil, nil } @@ -131,7 +131,7 @@ func (VestackVpcService) WithResourceResponseHandlers(vpc map[string]interface{} } -func (s *VestackVpcService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineVpcService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "CreateVpc", @@ -163,7 +163,7 @@ func (s *VestackVpcService) CreateResource(resourceData *schema.ResourceData, re } -func (s *VestackVpcService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { +func (s *VolcengineVpcService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifyVpcAttributes", @@ -192,7 +192,7 @@ func (s *VestackVpcService) ModifyResource(resourceData *schema.ResourceData, re return []ve.Callback{callback} } -func (s *VestackVpcService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { +func (s *VolcengineVpcService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ Action: "DeleteVpc", @@ -228,7 +228,7 @@ func (s *VestackVpcService) RemoveResource(resourceData *schema.ResourceData, r return []ve.Callback{callback} } -func (s *VestackVpcService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { +func (s *VolcengineVpcService) DatasourceResources(*schema.ResourceData, *schema.Resource) ve.DataSourceInfo { return ve.DataSourceInfo{ RequestConverts: map[string]ve.RequestConvert{ "ids": { @@ -248,6 +248,6 @@ func (s *VestackVpcService) DatasourceResources(*schema.ResourceData, *schema.Re } } -func (s *VestackVpcService) ReadResourceId(id string) string { +func (s *VolcengineVpcService) ReadResourceId(id string) string { return id } diff --git a/website/docs/d/acls.html.markdown b/website/docs/d/acls.html.markdown index 6f4e7803..ed617be2 100644 --- a/website/docs/d/acls.html.markdown +++ b/website/docs/d/acls.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "CLB" -layout: "vestack" -page_title: "Vestack: vestack_acls" -sidebar_current: "docs-vestack-datasource-acls" +layout: "volcengine" +page_title: "Volcengine: volcengine_acls" +sidebar_current: "docs-volcengine-datasource-acls" description: |- Use this data source to query detailed information of acls --- -# vestack_acls +# volcengine_acls Use this data source to query detailed information of acls ## Example Usage ```hcl -data "vestack_acls" "default" { +data "volcengine_acls" "default" { ids = ["acl-3ti8n0rurx4bwbh9jzdy"] } ``` diff --git a/website/docs/d/certificates.html.markdown b/website/docs/d/certificates.html.markdown index e5994dc0..008cb550 100644 --- a/website/docs/d/certificates.html.markdown +++ b/website/docs/d/certificates.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "CLB" -layout: "vestack" -page_title: "Vestack: vestack_certificates" -sidebar_current: "docs-vestack-datasource-certificates" +layout: "volcengine" +page_title: "Volcengine: volcengine_certificates" +sidebar_current: "docs-volcengine-datasource-certificates" description: |- Use this data source to query detailed information of certificates --- -# vestack_certificates +# volcengine_certificates Use this data source to query detailed information of certificates ## Example Usage ```hcl -data "vestack_certificates" "default" { +data "volcengine_certificates" "default" { ids = ["cert-274scdwqufwg07fap8u5fu8pi"] } ``` diff --git a/website/docs/d/clbs.html.markdown b/website/docs/d/clbs.html.markdown index dc77e4e7..4b97c3c0 100644 --- a/website/docs/d/clbs.html.markdown +++ b/website/docs/d/clbs.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "CLB" -layout: "vestack" -page_title: "Vestack: vestack_clbs" -sidebar_current: "docs-vestack-datasource-clbs" +layout: "volcengine" +page_title: "Volcengine: volcengine_clbs" +sidebar_current: "docs-volcengine-datasource-clbs" description: |- Use this data source to query detailed information of clbs --- -# vestack_clbs +# volcengine_clbs Use this data source to query detailed information of clbs ## Example Usage ```hcl -data "vestack_clbs" "default" { +data "volcengine_clbs" "default" { ids = ["clb-273y2ok6ets007fap8txvf6us"] } ``` diff --git a/website/docs/d/ecs_instances.html.markdown b/website/docs/d/ecs_instances.html.markdown index be76396b..6b4ab99d 100644 --- a/website/docs/d/ecs_instances.html.markdown +++ b/website/docs/d/ecs_instances.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "ECS" -layout: "vestack" -page_title: "Vestack: vestack_ecs_instances" -sidebar_current: "docs-vestack-datasource-ecs_instances" +layout: "volcengine" +page_title: "Volcengine: volcengine_ecs_instances" +sidebar_current: "docs-volcengine-datasource-ecs_instances" description: |- Use this data source to query detailed information of ecs instances --- -# vestack_ecs_instances +# volcengine_ecs_instances Use this data source to query detailed information of ecs instances ## Example Usage ```hcl -data "vestack_ecs_instances" "foo" { +data "volcengine_ecs_instances" "foo" { ids = ["i-ebgy6xmgjve0384ncgsc"] } ``` diff --git a/website/docs/d/eip_addresses.html.markdown b/website/docs/d/eip_addresses.html.markdown index 5a29c899..add2821a 100644 --- a/website/docs/d/eip_addresses.html.markdown +++ b/website/docs/d/eip_addresses.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "EIP" -layout: "vestack" -page_title: "Vestack: vestack_eip_addresses" -sidebar_current: "docs-vestack-datasource-eip_addresses" +layout: "volcengine" +page_title: "Volcengine: volcengine_eip_addresses" +sidebar_current: "docs-volcengine-datasource-eip_addresses" description: |- Use this data source to query detailed information of eip addresses --- -# vestack_eip_addresses +# volcengine_eip_addresses Use this data source to query detailed information of eip addresses ## Example Usage ```hcl -data "vestack_eip_addresses" "default" { +data "volcengine_eip_addresses" "default" { ids = ["eip-2748mbpjqzhfk7fap8teu0k1a"] } ``` diff --git a/website/docs/d/images.html.markdown b/website/docs/d/images.html.markdown index 2f1a58f5..b7fd4ee6 100644 --- a/website/docs/d/images.html.markdown +++ b/website/docs/d/images.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "ECS" -layout: "vestack" -page_title: "Vestack: vestack_images" -sidebar_current: "docs-vestack-datasource-images" +layout: "volcengine" +page_title: "Volcengine: volcengine_images" +sidebar_current: "docs-volcengine-datasource-images" description: |- Use this data source to query detailed information of images --- -# vestack_images +# volcengine_images Use this data source to query detailed information of images ## Example Usage ```hcl -data "vestack_images" "default" { +data "volcengine_images" "default" { ids = ["image-cm9ssb4eqmhdas306zlp", "image-ybkzct2rtj4ay5rmlfc3"] } ``` diff --git a/website/docs/d/listeners.html.markdown b/website/docs/d/listeners.html.markdown index 284015dd..f7e2bf06 100644 --- a/website/docs/d/listeners.html.markdown +++ b/website/docs/d/listeners.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "CLB" -layout: "vestack" -page_title: "Vestack: vestack_listeners" -sidebar_current: "docs-vestack-datasource-listeners" +layout: "volcengine" +page_title: "Volcengine: volcengine_listeners" +sidebar_current: "docs-volcengine-datasource-listeners" description: |- Use this data source to query detailed information of listeners --- -# vestack_listeners +# volcengine_listeners Use this data source to query detailed information of listeners ## Example Usage ```hcl -data "vestack_listeners" "default" { +data "volcengine_listeners" "default" { ids = ["lsn-273yv0mhs5xj47fap8sehiiso", "lsn-273yw6zps6pz47fap8swa0q2z"] } ``` diff --git a/website/docs/d/nat_gateways.html.markdown b/website/docs/d/nat_gateways.html.markdown index 5f05c257..77d1cfe1 100644 --- a/website/docs/d/nat_gateways.html.markdown +++ b/website/docs/d/nat_gateways.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "NAT" -layout: "vestack" -page_title: "Vestack: vestack_nat_gateways" -sidebar_current: "docs-vestack-datasource-nat_gateways" +layout: "volcengine" +page_title: "Volcengine: volcengine_nat_gateways" +sidebar_current: "docs-volcengine-datasource-nat_gateways" description: |- Use this data source to query detailed information of nat gateways --- -# vestack_nat_gateways +# volcengine_nat_gateways Use this data source to query detailed information of nat gateways ## Example Usage ```hcl -data "vestack_nat_gateways" "default" { +data "volcengine_nat_gateways" "default" { ids = ["ngw-2743w1f6iqby87fap8tvm9kop", "ngw-274gwbqe340zk7fap8spkzo7x"] } ``` diff --git a/website/docs/d/network_interfaces.html.markdown b/website/docs/d/network_interfaces.html.markdown index a027de3d..691382ce 100644 --- a/website/docs/d/network_interfaces.html.markdown +++ b/website/docs/d/network_interfaces.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_network_interfaces" -sidebar_current: "docs-vestack-datasource-network_interfaces" +layout: "volcengine" +page_title: "Volcengine: volcengine_network_interfaces" +sidebar_current: "docs-volcengine-datasource-network_interfaces" description: |- Use this data source to query detailed information of network interfaces --- -# vestack_network_interfaces +# volcengine_network_interfaces Use this data source to query detailed information of network interfaces ## Example Usage ```hcl -data "vestack_network_interfaces" "default" { +data "volcengine_network_interfaces" "default" { ids = ["eni-2744htx2w0j5s7fap8t3ivwze"] } ``` diff --git a/website/docs/d/route_entries.html.markdown b/website/docs/d/route_entries.html.markdown index 942dd843..5968540e 100644 --- a/website/docs/d/route_entries.html.markdown +++ b/website/docs/d/route_entries.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_route_entries" -sidebar_current: "docs-vestack-datasource-route_entries" +layout: "volcengine" +page_title: "Volcengine: volcengine_route_entries" +sidebar_current: "docs-volcengine-datasource-route_entries" description: |- Use this data source to query detailed information of route entries --- -# vestack_route_entries +# volcengine_route_entries Use this data source to query detailed information of route entries ## Example Usage ```hcl -data "vestack_route_entries" "default" { +data "volcengine_route_entries" "default" { ids = [] route_table_id = "vtb-274e19skkuhog7fap8u4i8ird" } diff --git a/website/docs/d/route_tables.html.markdown b/website/docs/d/route_tables.html.markdown index db19e0f5..a323c832 100644 --- a/website/docs/d/route_tables.html.markdown +++ b/website/docs/d/route_tables.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_route_tables" -sidebar_current: "docs-vestack-datasource-route_tables" +layout: "volcengine" +page_title: "Volcengine: volcengine_route_tables" +sidebar_current: "docs-volcengine-datasource-route_tables" description: |- Use this data source to query detailed information of route tables --- -# vestack_route_tables +# volcengine_route_tables Use this data source to query detailed information of route tables ## Example Usage ```hcl -data "vestack_route_tables" "default" { +data "volcengine_route_tables" "default" { ids = ["vtb-274e19skkuhog7fap8u4i8ird", "vtb-2744hslq5b7r47fap8tjomgnj"] route_table_name = "vpc-fast" } diff --git a/website/docs/d/security_groups.html.markdown b/website/docs/d/security_groups.html.markdown index 28c03f57..ad89dfe6 100644 --- a/website/docs/d/security_groups.html.markdown +++ b/website/docs/d/security_groups.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_security_groups" -sidebar_current: "docs-vestack-datasource-security_groups" +layout: "volcengine" +page_title: "Volcengine: volcengine_security_groups" +sidebar_current: "docs-volcengine-datasource-security_groups" description: |- Use this data source to query detailed information of security groups --- -# vestack_security_groups +# volcengine_security_groups Use this data source to query detailed information of security groups ## Example Usage ```hcl -data "vestack_security_groups" "default" { +data "volcengine_security_groups" "default" { ids = ["sg-273ycgql3ig3k7fap8t3dyvqx"] } ``` diff --git a/website/docs/d/server_groups.html.markdown b/website/docs/d/server_groups.html.markdown index fbfbb569..e5be73a4 100644 --- a/website/docs/d/server_groups.html.markdown +++ b/website/docs/d/server_groups.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "CLB" -layout: "vestack" -page_title: "Vestack: vestack_server_groups" -sidebar_current: "docs-vestack-datasource-server_groups" +layout: "volcengine" +page_title: "Volcengine: volcengine_server_groups" +sidebar_current: "docs-volcengine-datasource-server_groups" description: |- Use this data source to query detailed information of server groups --- -# vestack_server_groups +# volcengine_server_groups Use this data source to query detailed information of server groups ## Example Usage ```hcl -data "vestack_server_groups" "default" { +data "volcengine_server_groups" "default" { ids = ["rsp-273yv0kir1vk07fap8tt9jtwg", "rsp-273yxuqfova4g7fap8tyemn6t", "rsp-273z9pt9lpdds7fap8sqdvfrf"] } ``` diff --git a/website/docs/d/snat_entries.html.markdown b/website/docs/d/snat_entries.html.markdown index f4d57887..f65f1141 100644 --- a/website/docs/d/snat_entries.html.markdown +++ b/website/docs/d/snat_entries.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "NAT" -layout: "vestack" -page_title: "Vestack: vestack_snat_entries" -sidebar_current: "docs-vestack-datasource-snat_entries" +layout: "volcengine" +page_title: "Volcengine: volcengine_snat_entries" +sidebar_current: "docs-volcengine-datasource-snat_entries" description: |- Use this data source to query detailed information of snat entries --- -# vestack_snat_entries +# volcengine_snat_entries Use this data source to query detailed information of snat entries ## Example Usage ```hcl -data "vestack_snat_entries" "default" { +data "volcengine_snat_entries" "default" { ids = ["snat-274zl8b1kxzb47fap8u35uune"] } ``` diff --git a/website/docs/d/subnets.html.markdown b/website/docs/d/subnets.html.markdown index 7d8753d0..869aa5bd 100644 --- a/website/docs/d/subnets.html.markdown +++ b/website/docs/d/subnets.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_subnets" -sidebar_current: "docs-vestack-datasource-subnets" +layout: "volcengine" +page_title: "Volcengine: volcengine_subnets" +sidebar_current: "docs-volcengine-datasource-subnets" description: |- Use this data source to query detailed information of subnets --- -# vestack_subnets +# volcengine_subnets Use this data source to query detailed information of subnets ## Example Usage ```hcl -data "vestack_subnets" "default" { +data "volcengine_subnets" "default" { ids = ["subnet-274zsa5kfmj287fap8soo5e19"] } ``` diff --git a/website/docs/d/volumes.html.markdown b/website/docs/d/volumes.html.markdown index 7f60301a..3afb760c 100644 --- a/website/docs/d/volumes.html.markdown +++ b/website/docs/d/volumes.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "EBS" -layout: "vestack" -page_title: "Vestack: vestack_volumes" -sidebar_current: "docs-vestack-datasource-volumes" +layout: "volcengine" +page_title: "Volcengine: volcengine_volumes" +sidebar_current: "docs-volcengine-datasource-volumes" description: |- Use this data source to query detailed information of volumes --- -# vestack_volumes +# volcengine_volumes Use this data source to query detailed information of volumes ## Example Usage ```hcl -data "vestack_volumes" "default" { +data "volcengine_volumes" "default" { ids = ["vol-3tzg6y5imn3b9fchkedb"] } ``` diff --git a/website/docs/d/vpcs.html.markdown b/website/docs/d/vpcs.html.markdown index bbeb33b7..646ba6e6 100644 --- a/website/docs/d/vpcs.html.markdown +++ b/website/docs/d/vpcs.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_vpcs" -sidebar_current: "docs-vestack-datasource-vpcs" +layout: "volcengine" +page_title: "Volcengine: volcengine_vpcs" +sidebar_current: "docs-volcengine-datasource-vpcs" description: |- Use this data source to query detailed information of vpcs --- -# vestack_vpcs +# volcengine_vpcs Use this data source to query detailed information of vpcs ## Example Usage ```hcl -data "vestack_vpcs" "default" { +data "volcengine_vpcs" "default" { ids = ["vpc-mizl7m1kqccg5smt1bdpijuj"] } ``` diff --git a/website/docs/d/zones.html.markdown b/website/docs/d/zones.html.markdown index 4f4d8826..75d80ed5 100644 --- a/website/docs/d/zones.html.markdown +++ b/website/docs/d/zones.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "ECS" -layout: "vestack" -page_title: "Vestack: vestack_zones" -sidebar_current: "docs-vestack-datasource-zones" +layout: "volcengine" +page_title: "Volcengine: volcengine_zones" +sidebar_current: "docs-volcengine-datasource-zones" description: |- Use this data source to query detailed information of zones --- -# vestack_zones +# volcengine_zones Use this data source to query detailed information of zones ## Example Usage ```hcl -data "vestack_zones" "default" { +data "volcengine_zones" "default" { ids = ["cn-lingqiu-a"] } ``` diff --git a/website/docs/index.html.markdown b/website/docs/index.html.markdown index 27e3b14a..ecf552f3 100644 --- a/website/docs/index.html.markdown +++ b/website/docs/index.html.markdown @@ -1,24 +1,24 @@ --- -layout: "vestack" -page_title: "Provider: vestack" -sidebar_current: "docs-vestack-index" +layout: "volcengine" +page_title: "Provider: volcengine" +sidebar_current: "docs-volcengine-index" description: |- -The vestack provider is used to interact with many resources supported by Vestack. The provider needs to be configured with the proper credentials before it can be used. +The volcengine provider is used to interact with many resources supported by Volcengine. The provider needs to be configured with the proper credentials before it can be used. --- -# Vestack Provider +# Volcengine Provider -The Vestack provider is used to interact with many resources supported by [Vestack](https://www.volcengine.com/). +The Volcengine provider is used to interact with many resources supported by [Volcengine](https://www.volcengine.com/). The provider needs to be configured with the proper credentials before it can be used. Use the navigation on the left to read about the available resources. --> **Note:** This guide requires an available Vestack account or sub-account with project to create resources. +-> **Note:** This guide requires an available Volcengine account or sub-account with project to create resources. ## Example Usage ```hcl -# Configure the Vestack Provider -provider "vestack" { +# Configure the Volcengine Provider +provider "volcengine" { access_key = "your ak" secret_key = "your sk" session_token = "sts token" @@ -26,12 +26,12 @@ provider "vestack" { } # Query Vpc -data "vestack_vpcs" "default"{ +data "volcengine_vpcs" "default"{ ids = ["vpc-mizl7m1kqccg5smt1bdpijuj"] } #Create vpc -resource "vestack_vpc" "foo" { +resource "volcengine_vpc" "foo" { vpc_name = "tf-test-1" cidr_block = "172.16.0.0/16" dns_servers = ["8.8.8.8","114.114.114.114"] @@ -41,7 +41,7 @@ resource "vestack_vpc" "foo" { ## Authentication -The Vestack provider offers a flexible means of providing credentials for +The Volcengine provider offers a flexible means of providing credentials for authentication. The following methods are supported, in this order, and explained below: @@ -51,12 +51,12 @@ explained below: ### Static credentials Static credentials can be provided by adding an `public_key` and `private_key` in-line in the -vestack provider block: +volcengine provider block: Usage: ```hcl -provider "vestack" { +provider "volcengine" { access_key = "your ak" secret_key = "your sk" region = "cn-beijing" @@ -65,12 +65,12 @@ provider "vestack" { ### Environment variables -You can provide your credentials via `VESTACK_ACCESS_KEY` and `VESTACK_SECRET_KEY` -environment variables, representing your vestack public key and private key respectively. -`VESTACK_REGION` is also used, if applicable: +You can provide your credentials via `VOLCENGINE_ACCESS_KEY` and `VOLCENGINE_SECRET_KEY` +environment variables, representing your volcengine public key and private key respectively. +`VOLCENGINE_REGION` is also used, if applicable: ```hcl -provider "vestack" { +provider "volcengine" { } ``` @@ -78,9 +78,9 @@ provider "vestack" { Usage: ```hcl -$ export VESTACK_ACCESS_KEY="your_public_key" -$ export VESTACK_SECRET_KEY="your_private_key" -$ export VESTACK_REGION="cn-beijing" +$ export VOLCENGINE_ACCESS_KEY="your_public_key" +$ export VOLCENGINE_SECRET_KEY="your_private_key" +$ export VOLCENGINE_REGION="cn-beijing" $ terraform plan ``` diff --git a/website/docs/r/acl.html.markdown b/website/docs/r/acl.html.markdown index 2a2cf7cf..33a5dc73 100644 --- a/website/docs/r/acl.html.markdown +++ b/website/docs/r/acl.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "CLB" -layout: "vestack" -page_title: "Vestack: vestack_acl" -sidebar_current: "docs-vestack-resource-acl" +layout: "volcengine" +page_title: "Volcengine: volcengine_acl" +sidebar_current: "docs-volcengine-resource-acl" description: |- Provides a resource to manage acl --- -# vestack_acl +# volcengine_acl Provides a resource to manage acl ## Example Usage ```hcl -resource "vestack_acl" "foo" { +resource "volcengine_acl" "foo" { acl_name = "tf-test-2" acl_entries { entry = "172.20.1.0/24" @@ -43,6 +43,6 @@ In addition to all arguments above, the following attributes are exported: ## Import Acl can be imported using the id, e.g. ``` -$ terraform import vestack_acl.default acl-mizl7m1kqccg5smt1bdpijuj +$ terraform import volcengine_acl.default acl-mizl7m1kqccg5smt1bdpijuj ``` diff --git a/website/docs/r/acl_entry.html.markdown b/website/docs/r/acl_entry.html.markdown index 7edafb74..8372e37d 100644 --- a/website/docs/r/acl_entry.html.markdown +++ b/website/docs/r/acl_entry.html.markdown @@ -1,22 +1,22 @@ --- subcategory: "CLB" -layout: "vestack" -page_title: "Vestack: vestack_acl_entry" -sidebar_current: "docs-vestack-resource-acl_entry" +layout: "volcengine" +page_title: "Volcengine: volcengine_acl_entry" +sidebar_current: "docs-volcengine-resource-acl_entry" description: |- Provides a resource to manage acl entry --- -# vestack_acl_entry +# volcengine_acl_entry Provides a resource to manage acl entry ## Example Usage ```hcl -resource "vestack_acl" "foo" { +resource "volcengine_acl" "foo" { acl_name = "tf-test-3" description = "tf-test" } -resource "vestack_acl_entry" "foo" { - acl_id = vestack_acl.foo.id +resource "volcengine_acl_entry" "foo" { + acl_id = volcengine_acl.foo.id description = "tf acl entry desc demo" entry = "192.2.2.1/32" } @@ -36,6 +36,6 @@ In addition to all arguments above, the following attributes are exported: ## Import AclEntry can be imported using the id, e.g. ``` -$ terraform import vestack_acl_entry.default ID is a string concatenated with colons(AclId:Entry) +$ terraform import volcengine_acl_entry.default ID is a string concatenated with colons(AclId:Entry) ``` diff --git a/website/docs/r/certificate.html.markdown b/website/docs/r/certificate.html.markdown index fdd2d7cb..0be68bcd 100644 --- a/website/docs/r/certificate.html.markdown +++ b/website/docs/r/certificate.html.markdown @@ -1,12 +1,12 @@ --- subcategory: "CLB" -layout: "vestack" -page_title: "Vestack: vestack_certificate" -sidebar_current: "docs-vestack-resource-certificate" +layout: "volcengine" +page_title: "Volcengine: volcengine_certificate" +sidebar_current: "docs-volcengine-resource-certificate" description: |- Provides a resource to manage certificate --- -# vestack_certificate +# volcengine_certificate Provides a resource to manage certificate ## Example Usage ```hcl @@ -17,7 +17,7 @@ variable "certificate" { }) } -resource "vestack_certificate" "foo" { +resource "volcengine_certificate" "foo" { certificate_name = "demo-certificate" description = "This is a clb certificate" public_key = var.certificate.public_key @@ -40,6 +40,6 @@ In addition to all arguments above, the following attributes are exported: ## Import Certificate can be imported using the id, e.g. ``` -$ terraform import vestack_certificate.default cert-2fe5k****c16o5oxruvtk3qf5 +$ terraform import volcengine_certificate.default cert-2fe5k****c16o5oxruvtk3qf5 ``` diff --git a/website/docs/r/clb.html.markdown b/website/docs/r/clb.html.markdown index 18ef8a51..7f5a191e 100644 --- a/website/docs/r/clb.html.markdown +++ b/website/docs/r/clb.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "CLB" -layout: "vestack" -page_title: "Vestack: vestack_clb" -sidebar_current: "docs-vestack-resource-clb" +layout: "volcengine" +page_title: "Volcengine: volcengine_clb" +sidebar_current: "docs-volcengine-resource-clb" description: |- Provides a resource to manage clb --- -# vestack_clb +# volcengine_clb Provides a resource to manage clb ## Example Usage ```hcl -resource "vestack_clb" "foo" { +resource "volcengine_clb" "foo" { type = "public" subnet_id = "subnet-2744i7u9alnnk7fap8tkq8aft" load_balancer_spec = "small_1" @@ -41,6 +41,6 @@ In addition to all arguments above, the following attributes are exported: ## Import CLB can be imported using the id, e.g. ``` -$ terraform import vestack_clb.default clb-273y2ok6ets007fap8txvf6us +$ terraform import volcengine_clb.default clb-273y2ok6ets007fap8txvf6us ``` diff --git a/website/docs/r/ecs_instance.html.markdown b/website/docs/r/ecs_instance.html.markdown index b9a0dc3e..fc744f95 100644 --- a/website/docs/r/ecs_instance.html.markdown +++ b/website/docs/r/ecs_instance.html.markdown @@ -1,33 +1,33 @@ --- subcategory: "ECS" -layout: "vestack" -page_title: "Vestack: vestack_ecs_instance" -sidebar_current: "docs-vestack-resource-ecs_instance" +layout: "volcengine" +page_title: "Volcengine: volcengine_ecs_instance" +sidebar_current: "docs-volcengine-resource-ecs_instance" description: |- Provides a resource to manage ecs instance --- -# vestack_ecs_instance +# volcengine_ecs_instance Provides a resource to manage ecs instance ## Example Usage ```hcl -resource "vestack_vpc" "foo" { +resource "volcengine_vpc" "foo" { vpc_name = "tf-test-2" cidr_block = "172.16.0.0/16" } -resource "vestack_subnet" "foo1" { +resource "volcengine_subnet" "foo1" { subnet_name = "subnet-test-1" cidr_block = "172.16.1.0/24" zone_id = "cn-beijing-a" - vpc_id = vestack_vpc.foo.id + vpc_id = volcengine_vpc.foo.id } -resource "vestack_security_group" "foo1" { - depends_on = [vestack_subnet.foo1] - vpc_id = vestack_vpc.foo.id +resource "volcengine_security_group" "foo1" { + depends_on = [volcengine_subnet.foo1] + vpc_id = volcengine_vpc.foo.id } -resource "vestack_ecs_instance" "default" { +resource "volcengine_ecs_instance" "default" { zone_id = "cn-beijing-a" image_id = "image-aagd56zrw2jtdro3bnrl" instance_type = "ecs.g1.large" @@ -37,16 +37,16 @@ resource "vestack_ecs_instance" "default" { instance_charge_type = "PostPaid" system_volume_type = "PTSSD" system_volume_size = 60 - subnet_id = vestack_subnet.foo1.id - security_group_ids = [vestack_security_group.foo1.id] + subnet_id = volcengine_subnet.foo1.id + security_group_ids = [volcengine_security_group.foo1.id] data_volumes { volume_type = "PTSSD" size = 100 delete_with_instance = true } # secondary_network_interfaces { - # subnet_id = vestack_subnet.foo1.id - # security_group_ids = [vestack_security_group.foo1.id] + # subnet_id = volcengine_subnet.foo1.id + # security_group_ids = [volcengine_security_group.foo1.id] # } } ``` @@ -107,6 +107,6 @@ In addition to all arguments above, the following attributes are exported: ## Import ECS Instance can be imported using the id, e.g. ``` -$ terraform import vestack_ecs_instance.default i-mizl7m1kqccg5smt1bdpijuj +$ terraform import volcengine_ecs_instance.default i-mizl7m1kqccg5smt1bdpijuj ``` diff --git a/website/docs/r/ecs_instance_state.html.markdown b/website/docs/r/ecs_instance_state.html.markdown index f608a5a3..12cbd389 100644 --- a/website/docs/r/ecs_instance_state.html.markdown +++ b/website/docs/r/ecs_instance_state.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "ECS" -layout: "vestack" -page_title: "Vestack: vestack_ecs_instance_state" -sidebar_current: "docs-vestack-resource-ecs_instance_state" +layout: "volcengine" +page_title: "Volcengine: volcengine_ecs_instance_state" +sidebar_current: "docs-volcengine-resource-ecs_instance_state" description: |- Provides a resource to manage ecs instance state --- -# vestack_ecs_instance_state +# volcengine_ecs_instance_state Provides a resource to manage ecs instance state ## Example Usage ```hcl -resource "vestack_ecs_instance_state" "foo" { +resource "volcengine_ecs_instance_state" "foo" { instance_id = "i-l8u2ai4j0fauo6mrpgk8" action = "Start" } @@ -30,6 +30,6 @@ In addition to all arguments above, the following attributes are exported: ## Import State Instance can be imported using the id, e.g. ``` -$ terraform import vestack_ecs_instance_state.default state:i-mizl7m1kqccg5smt1bdpijuj +$ terraform import volcengine_ecs_instance_state.default state:i-mizl7m1kqccg5smt1bdpijuj ``` diff --git a/website/docs/r/eip_address.html.markdown b/website/docs/r/eip_address.html.markdown index 083abf7a..d15866af 100644 --- a/website/docs/r/eip_address.html.markdown +++ b/website/docs/r/eip_address.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "EIP" -layout: "vestack" -page_title: "Vestack: vestack_eip_address" -sidebar_current: "docs-vestack-resource-eip_address" +layout: "volcengine" +page_title: "Volcengine: volcengine_eip_address" +sidebar_current: "docs-volcengine-resource-eip_address" description: |- Provides a resource to manage eip address --- -# vestack_eip_address +# volcengine_eip_address Provides a resource to manage eip address ## Example Usage ```hcl -resource "vestack_eip_address" "foo" { +resource "volcengine_eip_address" "foo" { billing_type = "PostPaidByBandwidth" bandwidth = 1 isp = "BGP" @@ -36,6 +36,6 @@ In addition to all arguments above, the following attributes are exported: ## Import Eip address can be imported using the id, e.g. ``` -$ terraform import vestack_eip_address.default eip-274oj9a8rs9a87fap8sf9515b +$ terraform import volcengine_eip_address.default eip-274oj9a8rs9a87fap8sf9515b ``` diff --git a/website/docs/r/eip_associate.html.markdown b/website/docs/r/eip_associate.html.markdown index 4689f2ec..00747341 100644 --- a/website/docs/r/eip_associate.html.markdown +++ b/website/docs/r/eip_associate.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "EIP" -layout: "vestack" -page_title: "Vestack: vestack_eip_associate" -sidebar_current: "docs-vestack-resource-eip_associate" +layout: "volcengine" +page_title: "Volcengine: volcengine_eip_associate" +sidebar_current: "docs-volcengine-resource-eip_associate" description: |- Provides a resource to manage eip associate --- -# vestack_eip_associate +# volcengine_eip_associate Provides a resource to manage eip associate ## Example Usage ```hcl -resource "vestack_eip_associate" "foo" { +resource "volcengine_eip_associate" "foo" { allocation_id = "eip-273ybrd0oeo007fap8t0nggtx" instance_id = "i-cm9tjw9zp9j942mfkczp" instance_type = "EcsInstance" @@ -32,6 +32,6 @@ In addition to all arguments above, the following attributes are exported: ## Import Eip associate can be imported using the eip allocation_id:instance_id, e.g. ``` -$ terraform import vestack_eip_associate.default eip-274oj9a8rs9a87fap8sf9515b:i-cm9t9ug9lggu79yr5tcw +$ terraform import volcengine_eip_associate.default eip-274oj9a8rs9a87fap8sf9515b:i-cm9t9ug9lggu79yr5tcw ``` diff --git a/website/docs/r/listener.html.markdown b/website/docs/r/listener.html.markdown index c3617983..c36fab22 100644 --- a/website/docs/r/listener.html.markdown +++ b/website/docs/r/listener.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "CLB" -layout: "vestack" -page_title: "Vestack: vestack_listener" -sidebar_current: "docs-vestack-resource-listener" +layout: "volcengine" +page_title: "Volcengine: volcengine_listener" +sidebar_current: "docs-volcengine-resource-listener" description: |- Provides a resource to manage listener --- -# vestack_listener +# volcengine_listener Provides a resource to manage listener ## Example Usage ```hcl -resource "vestack_listener" "foo" { +resource "volcengine_listener" "foo" { load_balancer_id = "clb-273ylkl0a3i807fap8t4unbsq" listener_name = "Demo-HTTP-90" protocol = "HTTP" @@ -68,6 +68,6 @@ In addition to all arguments above, the following attributes are exported: ## Import Listener can be imported using the id, e.g. ``` -$ terraform import vestack_listener.default lsn-273yv0mhs5xj47fap8sehiiso +$ terraform import volcengine_listener.default lsn-273yv0mhs5xj47fap8sehiiso ``` diff --git a/website/docs/r/nat_gateway.html.markdown b/website/docs/r/nat_gateway.html.markdown index 51c510b5..858789e2 100644 --- a/website/docs/r/nat_gateway.html.markdown +++ b/website/docs/r/nat_gateway.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "NAT" -layout: "vestack" -page_title: "Vestack: vestack_nat_gateway" -sidebar_current: "docs-vestack-resource-nat_gateway" +layout: "volcengine" +page_title: "Volcengine: volcengine_nat_gateway" +sidebar_current: "docs-volcengine-resource-nat_gateway" description: |- Provides a resource to manage nat gateway --- -# vestack_nat_gateway +# volcengine_nat_gateway Provides a resource to manage nat gateway ## Example Usage ```hcl -resource "vestack_nat_gateway" "foo" { +resource "volcengine_nat_gateway" "foo" { vpc_id = "vpc-2740cxyk9im0w7fap8u013dfe" subnet_id = "subnet-2740cym8mv9q87fap8u3hfx4i" spec = "Medium" @@ -36,6 +36,6 @@ In addition to all arguments above, the following attributes are exported: ## Import NatGateway can be imported using the id, e.g. ``` -$ terraform import vestack_nat_gateway.default ngw-vv3t043k05sm**** +$ terraform import volcengine_nat_gateway.default ngw-vv3t043k05sm**** ``` diff --git a/website/docs/r/network_interface.html.markdown b/website/docs/r/network_interface.html.markdown index 1bf0a731..aaa9fd9f 100644 --- a/website/docs/r/network_interface.html.markdown +++ b/website/docs/r/network_interface.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_network_interface" -sidebar_current: "docs-vestack-resource-network_interface" +layout: "volcengine" +page_title: "Volcengine: volcengine_network_interface" +sidebar_current: "docs-volcengine-resource-network_interface" description: |- Provides a resource to manage network interface --- -# vestack_network_interface +# volcengine_network_interface Provides a resource to manage network interface ## Example Usage ```hcl -resource "vestack_network_interface" "foo" { +resource "volcengine_network_interface" "foo" { subnet_id = "subnet-2744ht7fhjthc7fap8tm10eqg" security_group_ids = ["sg-2744hspo7jbpc7fap8t7lef1p"] primary_ip_address = "192.168.0.253" @@ -37,6 +37,6 @@ In addition to all arguments above, the following attributes are exported: ## Import Network interface can be imported using the id, e.g. ``` -$ terraform import vestack_network_interface.default eni-bp1fgnh68xyz9**** +$ terraform import volcengine_network_interface.default eni-bp1fgnh68xyz9**** ``` diff --git a/website/docs/r/network_interface_attach.html.markdown b/website/docs/r/network_interface_attach.html.markdown index 46612916..f673243a 100644 --- a/website/docs/r/network_interface_attach.html.markdown +++ b/website/docs/r/network_interface_attach.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_network_interface_attach" -sidebar_current: "docs-vestack-resource-network_interface_attach" +layout: "volcengine" +page_title: "Volcengine: volcengine_network_interface_attach" +sidebar_current: "docs-volcengine-resource-network_interface_attach" description: |- Provides a resource to manage network interface attach --- -# vestack_network_interface_attach +# volcengine_network_interface_attach Provides a resource to manage network interface attach ## Example Usage ```hcl -resource "vestack_network_interface_attach" "foo" { +resource "volcengine_network_interface_attach" "foo" { network_interface_id = "eni-274ecj646ylts7fap8t6xbba1" instance_id = "i-72q20hi6s082wcafdem8" } @@ -29,6 +29,6 @@ In addition to all arguments above, the following attributes are exported: ## Import Network interface attach can be imported using the network_interface_id:instance_id. ``` -$ terraform import vestack_network_interface_attach.default eni-bp1fg655nh68xyz9***:i-wijfn35c**** +$ terraform import volcengine_network_interface_attach.default eni-bp1fg655nh68xyz9***:i-wijfn35c**** ``` diff --git a/website/docs/r/route_entry.html.markdown b/website/docs/r/route_entry.html.markdown index fd9599c8..d0f91fad 100644 --- a/website/docs/r/route_entry.html.markdown +++ b/website/docs/r/route_entry.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_route_entry" -sidebar_current: "docs-vestack-resource-route_entry" +layout: "volcengine" +page_title: "Volcengine: volcengine_route_entry" +sidebar_current: "docs-volcengine-resource-route_entry" description: |- Provides a resource to manage route entry --- -# vestack_route_entry +# volcengine_route_entry Provides a resource to manage route entry ## Example Usage ```hcl -resource "vestack_route_entry" "foo" { +resource "volcengine_route_entry" "foo" { route_table_id = "vtb-2744hslq5b7r47fap8tjomgnj" destination_cidr_block = "0.0.0.0/2" next_hop_type = "NatGW" @@ -38,6 +38,6 @@ In addition to all arguments above, the following attributes are exported: ## Import Route entry can be imported using the route_table_id:route_entry_id, e.g. ``` -$ terraform import vestack_route_entry.default vtb-274e19skkuhog7fap8u4i8ird:rte-274e1g9ei4k5c7fap8sp974fq +$ terraform import volcengine_route_entry.default vtb-274e19skkuhog7fap8u4i8ird:rte-274e1g9ei4k5c7fap8sp974fq ``` diff --git a/website/docs/r/route_table.html.markdown b/website/docs/r/route_table.html.markdown index 2fa16797..dab8ea5a 100644 --- a/website/docs/r/route_table.html.markdown +++ b/website/docs/r/route_table.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_route_table" -sidebar_current: "docs-vestack-resource-route_table" +layout: "volcengine" +page_title: "Volcengine: volcengine_route_table" +sidebar_current: "docs-volcengine-resource-route_table" description: |- Provides a resource to manage route table --- -# vestack_route_table +# volcengine_route_table Provides a resource to manage route table ## Example Usage ```hcl -resource "vestack_route_table" "foo" { +resource "volcengine_route_table" "foo" { vpc_id = "vpc-2744hsjr475s07fap8t4jbl1c" route_table_name = "tf-test1" description = "tf-test1" @@ -31,6 +31,6 @@ In addition to all arguments above, the following attributes are exported: ## Import Route table can be imported using the id, e.g. ``` -$ terraform import vestack_route_table.default vtb-274e0syt9av407fap8tle16kb +$ terraform import volcengine_route_table.default vtb-274e0syt9av407fap8tle16kb ``` diff --git a/website/docs/r/route_table_associate.html.markdown b/website/docs/r/route_table_associate.html.markdown index 7981f4aa..8b3f0135 100644 --- a/website/docs/r/route_table_associate.html.markdown +++ b/website/docs/r/route_table_associate.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_route_table_associate" -sidebar_current: "docs-vestack-resource-route_table_associate" +layout: "volcengine" +page_title: "Volcengine: volcengine_route_table_associate" +sidebar_current: "docs-volcengine-resource-route_table_associate" description: |- Provides a resource to manage route table associate --- -# vestack_route_table_associate +# volcengine_route_table_associate Provides a resource to manage route table associate ## Example Usage ```hcl -resource "vestack_route_table_associate" "foo" { +resource "volcengine_route_table_associate" "foo" { route_table_id = "vtb-274e19skkuhog7fap8u4i8ird" subnet_id = "subnet-2744ht7fhjthc7fap8tm10eqg" } @@ -29,6 +29,6 @@ In addition to all arguments above, the following attributes are exported: ## Import Route table associate address can be imported using the route_table_id:subnet_id, e.g. ``` -$ terraform import vestack_route_table_associate.default vtb-2fdzao4h726f45******:subnet-2fdzaou4liw3k5oxruv****** +$ terraform import volcengine_route_table_associate.default vtb-2fdzao4h726f45******:subnet-2fdzaou4liw3k5oxruv****** ``` diff --git a/website/docs/r/security_group.html.markdown b/website/docs/r/security_group.html.markdown index 195e1543..824550af 100644 --- a/website/docs/r/security_group.html.markdown +++ b/website/docs/r/security_group.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_security_group" -sidebar_current: "docs-vestack-resource-security_group" +layout: "volcengine" +page_title: "Volcengine: volcengine_security_group" +sidebar_current: "docs-volcengine-resource-security_group" description: |- Provides a resource to manage security group --- -# vestack_security_group +# volcengine_security_group Provides a resource to manage security group ## Example Usage ```hcl -resource "vestack_security_group" "g1test1" { +resource "volcengine_security_group" "g1test1" { vpc_id = "sg-273ycgql3ig3k7fap8t3dyvqx" } ``` @@ -30,6 +30,6 @@ In addition to all arguments above, the following attributes are exported: ## Import SecurityGroup can be imported using the id, e.g. ``` -$ terraform import vestack_security_group.default sg-273ycgql3ig3k7fap8t3dyvqx +$ terraform import volcengine_security_group.default sg-273ycgql3ig3k7fap8t3dyvqx ``` diff --git a/website/docs/r/security_group_rule.html.markdown b/website/docs/r/security_group_rule.html.markdown index 7582ae28..21c59f9e 100644 --- a/website/docs/r/security_group_rule.html.markdown +++ b/website/docs/r/security_group_rule.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_security_group_rule" -sidebar_current: "docs-vestack-resource-security_group_rule" +layout: "volcengine" +page_title: "Volcengine: volcengine_security_group_rule" +sidebar_current: "docs-volcengine-resource-security_group_rule" description: |- Provides a resource to manage security group rule --- -# vestack_security_group_rule +# volcengine_security_group_rule Provides a resource to manage security group rule ## Example Usage ```hcl -resource "vestack_security_group_rule" "g1test3" { +resource "volcengine_security_group_rule" "g1test3" { direction = "egress" security_group_id = "sg-273ycgql3ig3k7fap8t3dyvqx" protocol = "tcp" @@ -41,6 +41,6 @@ In addition to all arguments above, the following attributes are exported: ## Import SecurityGroupRule can be imported using the id, e.g. ``` -$ terraform import vestack_security_group_rule.default ID is a string concatenated with colons(SecurityGroupId:Protocol:PortStart:PortEnd:CidrIp) +$ terraform import volcengine_security_group_rule.default ID is a string concatenated with colons(SecurityGroupId:Protocol:PortStart:PortEnd:CidrIp) ``` diff --git a/website/docs/r/server_group.html.markdown b/website/docs/r/server_group.html.markdown index 76d7cd61..06ce51d9 100644 --- a/website/docs/r/server_group.html.markdown +++ b/website/docs/r/server_group.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "CLB" -layout: "vestack" -page_title: "Vestack: vestack_server_group" -sidebar_current: "docs-vestack-resource-server_group" +layout: "volcengine" +page_title: "Volcengine: volcengine_server_group" +sidebar_current: "docs-volcengine-resource-server_group" description: |- Provides a resource to manage server group --- -# vestack_server_group +# volcengine_server_group Provides a resource to manage server group ## Example Usage ```hcl -resource "vestack_server_group" "foo" { +resource "volcengine_server_group" "foo" { load_balancer_id = "clb-273z7d4r8tvk07fap8tsniyfe" server_group_name = "demo-demo11" description = "hello demo11" @@ -32,6 +32,6 @@ In addition to all arguments above, the following attributes are exported: ## Import ServerGroupServer can be imported using the id, e.g. ``` -$ terraform import vestack_server_group_server.default rs-3ciynux6i1x4w****rszh49sj +$ terraform import volcengine_server_group_server.default rs-3ciynux6i1x4w****rszh49sj ``` diff --git a/website/docs/r/snat_entry.html.markdown b/website/docs/r/snat_entry.html.markdown index 852b14ca..211407c8 100644 --- a/website/docs/r/snat_entry.html.markdown +++ b/website/docs/r/snat_entry.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "NAT" -layout: "vestack" -page_title: "Vestack: vestack_snat_entry" -sidebar_current: "docs-vestack-resource-snat_entry" +layout: "volcengine" +page_title: "Volcengine: volcengine_snat_entry" +sidebar_current: "docs-volcengine-resource-snat_entry" description: |- Provides a resource to manage snat entry --- -# vestack_snat_entry +# volcengine_snat_entry Provides a resource to manage snat entry ## Example Usage ```hcl -resource "vestack_snat_entry" "foo" { +resource "volcengine_snat_entry" "foo" { nat_gateway_id = "ngw-2743w1f6iqby87fap8tvm9kop" subnet_id = "subnet-2744i7u9alnnk7fap8tkq8aft" eip_id = "eip-274zlae117nr47fap8tzl24v4" @@ -33,6 +33,6 @@ In addition to all arguments above, the following attributes are exported: ## Import Snat entry can be imported using the id, e.g. ``` -$ terraform import vestack_snat_entry.default snat-3fvhk47kf56**** +$ terraform import volcengine_snat_entry.default snat-3fvhk47kf56**** ``` diff --git a/website/docs/r/subnet.html.markdown b/website/docs/r/subnet.html.markdown index 459e8f4c..8b44b448 100644 --- a/website/docs/r/subnet.html.markdown +++ b/website/docs/r/subnet.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_subnet" -sidebar_current: "docs-vestack-resource-subnet" +layout: "volcengine" +page_title: "Volcengine: volcengine_subnet" +sidebar_current: "docs-volcengine-resource-subnet" description: |- Provides a resource to manage subnet --- -# vestack_subnet +# volcengine_subnet Provides a resource to manage subnet ## Example Usage ```hcl -resource "vestack_subnet" "foo" { +resource "volcengine_subnet" "foo" { subnet_name = "subnet-test-2" cidr_block = "192.168.1.0/24" zone_id = "cn-beijing" @@ -35,6 +35,6 @@ In addition to all arguments above, the following attributes are exported: ## Import Subnet can be imported using the id, e.g. ``` -$ terraform import vestack_subnet.default subnet-274oj9a8rs9a87fap8sf9515b +$ terraform import volcengine_subnet.default subnet-274oj9a8rs9a87fap8sf9515b ``` diff --git a/website/docs/r/volume.html.markdown b/website/docs/r/volume.html.markdown index 16ac8cfb..8036655f 100644 --- a/website/docs/r/volume.html.markdown +++ b/website/docs/r/volume.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "EBS" -layout: "vestack" -page_title: "Vestack: vestack_volume" -sidebar_current: "docs-vestack-resource-volume" +layout: "volcengine" +page_title: "Volcengine: volcengine_volume" +sidebar_current: "docs-volcengine-resource-volume" description: |- Provides a resource to manage volume --- -# vestack_volume +# volcengine_volume Provides a resource to manage volume ## Example Usage ```hcl -resource "vestack_volume" "foo" { +resource "volcengine_volume" "foo" { volume_name = "terraform-test" zone_id = "cn-lingqiu-a" volume_type = "PTSSD" @@ -42,6 +42,6 @@ In addition to all arguments above, the following attributes are exported: ## Import Volume can be imported using the id, e.g. ``` -$ terraform import vestack_volume.default vol-mizl7m1kqccg5smt1bdpijuj +$ terraform import volcengine_volume.default vol-mizl7m1kqccg5smt1bdpijuj ``` diff --git a/website/docs/r/volume_attach.html.markdown b/website/docs/r/volume_attach.html.markdown index 07a4df98..6cfccfc4 100644 --- a/website/docs/r/volume_attach.html.markdown +++ b/website/docs/r/volume_attach.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "EBS" -layout: "vestack" -page_title: "Vestack: vestack_volume_attach" -sidebar_current: "docs-vestack-resource-volume_attach" +layout: "volcengine" +page_title: "Volcengine: volcengine_volume_attach" +sidebar_current: "docs-volcengine-resource-volume_attach" description: |- Provides a resource to manage volume attach --- -# vestack_volume_attach +# volcengine_volume_attach Provides a resource to manage volume attach ## Example Usage ```hcl -resource "vestack_volume_attach" "foo" { +resource "volcengine_volume_attach" "foo" { volume_id = "vol-3tzl52wubz3b9fciw7ev" instance_id = "i-4ay59ww7dq8dt9c29hd4" } @@ -32,6 +32,6 @@ In addition to all arguments above, the following attributes are exported: ## Import VolumeAttach can be imported using the id, e.g. ``` -$ terraform import vestack_volume_attach.default vol-abc12345:i-abc12345 +$ terraform import volcengine_volume_attach.default vol-abc12345:i-abc12345 ``` diff --git a/website/docs/r/vpc.html.markdown b/website/docs/r/vpc.html.markdown index 109582b9..108d964b 100644 --- a/website/docs/r/vpc.html.markdown +++ b/website/docs/r/vpc.html.markdown @@ -1,16 +1,16 @@ --- subcategory: "VPC" -layout: "vestack" -page_title: "Vestack: vestack_vpc" -sidebar_current: "docs-vestack-resource-vpc" +layout: "volcengine" +page_title: "Volcengine: volcengine_vpc" +sidebar_current: "docs-volcengine-resource-vpc" description: |- Provides a resource to manage vpc --- -# vestack_vpc +# volcengine_vpc Provides a resource to manage vpc ## Example Usage ```hcl -resource "vestack_vpc" "foo" { +resource "volcengine_vpc" "foo" { vpc_name = "tf-test-2" cidr_block = "172.16.0.0/16" dns_servers = ["8.8.8.8", "114.114.114.114"] @@ -45,6 +45,6 @@ In addition to all arguments above, the following attributes are exported: ## Import VPC can be imported using the id, e.g. ``` -$ terraform import vestack_vpc.default vpc-mizl7m1kqccg5smt1bdpijuj +$ terraform import volcengine_vpc.default vpc-mizl7m1kqccg5smt1bdpijuj ``` diff --git a/website/vestack.erb b/website/volcengine.erb similarity index 60% rename from website/vestack.erb rename to website/volcengine.erb index 35df17e1..32ed4cd5 100644 --- a/website/vestack.erb +++ b/website/volcengine.erb @@ -7,7 +7,7 @@ All Providers
  • - Vestack Provider + Volcengine Provider
  • @@ -17,19 +17,19 @@ Data Sources
  • @@ -37,25 +37,25 @@ Resources @@ -68,7 +68,7 @@ Data Sources @@ -76,10 +76,10 @@ Resources @@ -92,13 +92,13 @@ Data Sources @@ -106,10 +106,10 @@ Resources @@ -122,7 +122,7 @@ Data Sources @@ -130,10 +130,10 @@ Resources @@ -146,10 +146,10 @@ Data Sources @@ -157,10 +157,10 @@ Resources @@ -173,22 +173,22 @@ Data Sources @@ -196,31 +196,31 @@ Resources From 8d71f9358fc43b8d21e21ace23f10b4264ec08f0 Mon Sep 17 00:00:00 2001 From: zhangpeihua Date: Fri, 16 Sep 2022 12:54:08 +0800 Subject: [PATCH 14/21] feat: support hash index --- common/common_volcengine_convert.go | 34 +++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/common/common_volcengine_convert.go b/common/common_volcengine_convert.go index d3b87dab..2f7f571b 100644 --- a/common/common_volcengine_convert.go +++ b/common/common_volcengine_convert.go @@ -237,7 +237,7 @@ func ResourceDateToRequest(d *schema.ResourceData, resource *schema.Resource, is return req, err } -func Convert(d *schema.ResourceData, k string, v interface{}, t RequestConvert, index int, req *map[string]interface{}, chain string, forceGet bool, contentType RequestContentType, schemaChain string) (err error) { +func Convert(d *schema.ResourceData, k string, v interface{}, t RequestConvert, index int, req *map[string]interface{}, chain string, forceGet bool, contentType RequestContentType, schemaChain string, setIndex []int) (err error) { if !checkRequestConvertTypeSupport(contentType, t.ConvertType) { return fmt.Errorf("Can not support the RequestContentType [%v] when RequestContentType is [%v] ", t.ConvertType, contentType) } @@ -253,19 +253,19 @@ func Convert(d *schema.ResourceData, k string, v interface{}, t RequestConvert, err = RequestConvertWithN(v, k, t, req, chain) break case ConvertListN: - err = RequestConvertListN(v, k, t, req, chain, d, forceGet, false, contentType, schemaChain) + err = RequestConvertListN(v, k, t, req, chain, d, forceGet, false, contentType, schemaChain, setIndex) break case ConvertListUnique: - err = RequestConvertListN(v, k, t, req, chain, d, forceGet, true, contentType, schemaChain) + err = RequestConvertListN(v, k, t, req, chain, d, forceGet, true, contentType, schemaChain, setIndex) break case ConvertJsonObject: //equal ConvertListUnique - err = RequestConvertListN(v, k, t, req, chain, d, forceGet, true, contentType, schemaChain) + err = RequestConvertListN(v, k, t, req, chain, d, forceGet, true, contentType, schemaChain, setIndex) break case ConvertJsonArray: //equal ConvertWithN err = RequestConvertWithN(v, k, t, req, chain) break case ConvertJsonObjectArray: //equal ConvertListN - err = RequestConvertListN(v, k, t, req, chain, d, forceGet, false, contentType, schemaChain) + err = RequestConvertListN(v, k, t, req, chain, d, forceGet, false, contentType, schemaChain, setIndex) break //case ConvertWithFilter: // index, err = RequestConvertWithFilter(v, k, t, index, req) @@ -302,7 +302,7 @@ func RequestCreateConvert(d *schema.ResourceData, k string, t RequestConvert, in } } if ok { - err = Convert(d, k, v, t, index, req, "", forceGet, contentType, "") + err = Convert(d, k, v, t, index, req, "", forceGet, contentType, "", nil) } return index, err } @@ -365,7 +365,7 @@ func RequestConvertWithN(v interface{}, k string, t RequestConvert, req *map[str return nil } -func RequestConvertListN(v interface{}, k string, t RequestConvert, req *map[string]interface{}, chain string, d *schema.ResourceData, forceGet bool, single bool, contentType RequestContentType, schemaChain string) error { +func RequestConvertListN(v interface{}, k string, t RequestConvert, req *map[string]interface{}, chain string, d *schema.ResourceData, forceGet bool, single bool, contentType RequestContentType, schemaChain string, indexes []int) error { var ( err error isSet bool @@ -389,7 +389,13 @@ func RequestConvertListN(v interface{}, k string, t RequestConvert, req *map[str if t.NextLevelConvert != nil && t.NextLevelConvert[k2].ForceGet { flag = true } else { - schemaKey := fmt.Sprintf("%s.%d.%s", schemaChain+k, index, k2) + var schemaKey string + if len(indexes) > 0 { + schemaKey = fmt.Sprintf("%s.%d.%s", schemaChain+k, indexes[index], k2) + } else { + schemaKey = fmt.Sprintf("%s.%d.%s", schemaChain+k, index, k2) + } + if forceGet { if t.ForceGet || (d.HasChange(schemaKey) && !d.IsNewResource()) { flag = true @@ -411,9 +417,9 @@ func RequestConvertListN(v interface{}, k string, t RequestConvert, req *map[str switch reflect.TypeOf(v2).Kind() { case reflect.Slice: if t.NextLevelConvert[k2].Convert != nil { - err = Convert(d, k2, t.NextLevelConvert[k2].Convert(d, v2), t.NextLevelConvert[k2], 0, req, k3, t.NextLevelConvert[k2].ForceGet, contentType, k4) + err = Convert(d, k2, t.NextLevelConvert[k2].Convert(d, v2), t.NextLevelConvert[k2], 0, req, k3, t.NextLevelConvert[k2].ForceGet, contentType, k4, nil) } else { - err = Convert(d, k2, v2, t.NextLevelConvert[k2], 0, req, k3, t.NextLevelConvert[k2].ForceGet, contentType, k4) + err = Convert(d, k2, v2, t.NextLevelConvert[k2], 0, req, k3, t.NextLevelConvert[k2].ForceGet, contentType, k4, nil) } if err != nil { @@ -422,10 +428,14 @@ func RequestConvertListN(v interface{}, k string, t RequestConvert, req *map[str break case reflect.Ptr: if _v2, ok2 := v2.(*schema.Set); ok2 { + var setIndex []int + for _, mmm := range _v2.List() { + setIndex = append(setIndex, _v2.F(mmm)) + } if t.NextLevelConvert[k2].Convert != nil { - err = Convert(d, k2, t.NextLevelConvert[k2].Convert(d, _v2.List()), t.NextLevelConvert[k2], 0, req, k3, t.NextLevelConvert[k2].ForceGet, contentType, k4) + err = Convert(d, k2, t.NextLevelConvert[k2].Convert(d, _v2.List()), t.NextLevelConvert[k2], 0, req, k3, t.NextLevelConvert[k2].ForceGet, contentType, k4, setIndex) } else { - err = Convert(d, k2, _v2.List(), t.NextLevelConvert[k2], 0, req, k3, t.NextLevelConvert[k2].ForceGet, contentType, k4) + err = Convert(d, k2, _v2.List(), t.NextLevelConvert[k2], 0, req, k3, t.NextLevelConvert[k2].ForceGet, contentType, k4, setIndex) } if err != nil { return err From 1966e501f8cc78b4b8f045e18b8d991686d353e4 Mon Sep 17 00:00:00 2001 From: zhangpeihua Date: Fri, 16 Sep 2022 12:59:15 +0800 Subject: [PATCH 15/21] feat: support vke node pool --- .../data_source_volcengine_vke_node_pools.go | 5 ++ .../resource_volcengine_vke_node_pool.go | 14 +++-- .../service_volcengine_vke_node_pool.go | 59 +++---------------- 3 files changed, 23 insertions(+), 55 deletions(-) diff --git a/volcengine/vke/node_pool/data_source_volcengine_vke_node_pools.go b/volcengine/vke/node_pool/data_source_volcengine_vke_node_pools.go index fae32e1d..a5c9d3fb 100644 --- a/volcengine/vke/node_pool/data_source_volcengine_vke_node_pools.go +++ b/volcengine/vke/node_pool/data_source_volcengine_vke_node_pools.go @@ -332,6 +332,11 @@ func DataSourceVolcengineNodePools() *schema.Resource { Computed: true, Description: "The Size of DataVolume.", }, + "mount_point": { + Type: schema.TypeString, + Computed: true, + Description: "The target mount directory of the disk.", + }, }, }, Description: "The DataVolume of NodeConfig.", diff --git a/volcengine/vke/node_pool/resource_volcengine_vke_node_pool.go b/volcengine/vke/node_pool/resource_volcengine_vke_node_pool.go index 2edc6cb0..98a13c33 100644 --- a/volcengine/vke/node_pool/resource_volcengine_vke_node_pool.go +++ b/volcengine/vke/node_pool/resource_volcengine_vke_node_pool.go @@ -170,8 +170,8 @@ func ResourceVolcengineNodePool() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{"PTSSD", "ESSD_PL0"}, false), - Description: "The Type of SystemVolume, the value can be `PTSSD` or `ESSD_PL0`.", + ValidateFunc: validation.StringInSlice([]string{"PTSSD", "ESSD_PL0", "ESSD_FlexPL"}, false), + Description: "The Type of SystemVolume, the value can be `PTSSD` or `ESSD_PL0` or `ESSD_FlexPL`.", }, "size": { Type: schema.TypeInt, @@ -194,8 +194,8 @@ func ResourceVolcengineNodePool() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{"PTSSD", "ESSD_PL0"}, false), - Description: "The Type of DataVolumes, the value can be `PTSSD` or `ESSD_PL0`.", + ValidateFunc: validation.StringInSlice([]string{"PTSSD", "ESSD_PL0", "ESSD_FlexPL"}, false), + Description: "The Type of DataVolumes, the value can be `PTSSD` or `ESSD_PL0` or `ESSD_FlexPL`.", }, "size": { Type: schema.TypeInt, @@ -204,6 +204,12 @@ func ResourceVolcengineNodePool() *schema.Resource { ValidateFunc: validation.IntBetween(20, 32768), Description: "The Size of DataVolumes, the value range in 20~32768.", }, + "mount_point": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The target mount directory of the disk. Must start with `/`.", + }, }, }, Description: "The DataVolumes of NodeConfig.", diff --git a/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go b/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go index 972a9d57..3d899c61 100644 --- a/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go +++ b/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go @@ -306,15 +306,7 @@ func (s *VolcengineNodePoolService) CreateResource(resourceData *schema.Resource }, }, "data_volumes": { - ConvertType: ve.ConvertJsonArray, - NextLevelConvert: map[string]ve.RequestConvert{ - "type": { - ConvertType: ve.ConvertJsonObject, - }, - "size": { - ConvertType: ve.ConvertJsonObject, - }, - }, + ConvertType: ve.ConvertJsonObjectArray, }, "initialize_script": { ConvertType: ve.ConvertJsonObject, @@ -344,29 +336,10 @@ func (s *VolcengineNodePoolService) CreateResource(resourceData *schema.Resource ConvertType: ve.ConvertJsonObject, NextLevelConvert: map[string]ve.RequestConvert{ "labels": { - ConvertType: ve.ConvertJsonArray, - NextLevelConvert: map[string]ve.RequestConvert{ - "key": { - ConvertType: ve.ConvertJsonObject, - }, - "value": { - ConvertType: ve.ConvertJsonObject, - }, - }, + ConvertType: ve.ConvertJsonObjectArray, }, "taints": { - ConvertType: ve.ConvertJsonArray, - NextLevelConvert: map[string]ve.RequestConvert{ - "key": { - ConvertType: ve.ConvertJsonObject, - }, - "value": { - ConvertType: ve.ConvertJsonObject, - }, - "effect": { - ConvertType: ve.ConvertJsonObject, - }, - }, + ConvertType: ve.ConvertJsonObjectArray, }, "cordon": { ConvertType: ve.ConvertJsonObject, @@ -469,29 +442,10 @@ func (s *VolcengineNodePoolService) ModifyResource(resourceData *schema.Resource ConvertType: ve.ConvertJsonObject, NextLevelConvert: map[string]ve.RequestConvert{ "labels": { - ConvertType: ve.ConvertJsonArray, - NextLevelConvert: map[string]ve.RequestConvert{ - "key": { - ConvertType: ve.ConvertJsonObject, - }, - "value": { - ConvertType: ve.ConvertJsonObject, - }, - }, + ConvertType: ve.ConvertJsonObjectArray, }, "taints": { - ConvertType: ve.ConvertJsonArray, - NextLevelConvert: map[string]ve.RequestConvert{ - "key": { - ConvertType: ve.ConvertJsonObject, - }, - "value": { - ConvertType: ve.ConvertJsonObject, - }, - "effect": { - ConvertType: ve.ConvertJsonObject, - }, - }, + ConvertType: ve.ConvertJsonObjectArray, }, "cordon": { ConvertType: ve.ConvertJsonObject, @@ -732,6 +686,9 @@ func (s *VolcengineNodePoolService) DatasourceResources(*schema.ResourceData, *s volume := make(map[string]interface{}, 0) volume["size"] = strconv.FormatFloat(_data.(map[string]interface{})["Size"].(float64), 'g', 5, 32) volume["type"] = _data.(map[string]interface{})["Type"].(string) + if p, ok := _data.(map[string]interface{})["MountPoint"]; ok { // 可能不存在 + volume["mount_point"] = p.(string) + } results = append(results, volume) } } From ee8f06cf2a0dd003e876b22eb0fd894bcec3cfa9 Mon Sep 17 00:00:00 2001 From: zhangpeihua Date: Sat, 17 Sep 2022 16:00:46 +0800 Subject: [PATCH 16/21] fix: for vke node pool k8s_config --- .../service_volcengine_vke_node_pool.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go b/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go index 3d899c61..ad82d775 100644 --- a/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go +++ b/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go @@ -481,6 +481,20 @@ func (s *VolcengineNodePoolService) ModifyResource(resourceData *schema.Resource BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { (*call.SdkParam)["Id"] = d.Id() (*call.SdkParam)["ClusterId"] = d.Get("cluster_id") + + if _, ok := (*call.SdkParam)["KubernetesConfig"]; !ok { + (*call.SdkParam)["KubernetesConfig"] = map[string]interface{}{ + "Labels": []interface{}{}, + "Taints": []interface{}{}, + } + } else { + if _, ok = (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Labels"]; !ok { + (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Labels"] = []interface{}{} + } + if _, ok = (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Taints"]; !ok { + (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Taints"] = []interface{}{} + } + } return true, nil }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { @@ -495,7 +509,7 @@ func (s *VolcengineNodePoolService) ModifyResource(resourceData *schema.Resource } } } - logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + logger.Debug(logger.ReqFormat, call.Action, call.SdkParam) resp, err := s.Client.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) logger.Debug(logger.RespFormat, call.Action, resp, err) return resp, err From a2bf86a8b6e5ccd1003bfda4d0038680b35058c1 Mon Sep 17 00:00:00 2001 From: zhangpeihua Date: Sat, 17 Sep 2022 16:22:12 +0800 Subject: [PATCH 17/21] fix: vke additional_container_storage_enabled forceNew support --- volcengine/vke/node_pool/resource_volcengine_vke_node_pool.go | 1 + 1 file changed, 1 insertion(+) diff --git a/volcengine/vke/node_pool/resource_volcengine_vke_node_pool.go b/volcengine/vke/node_pool/resource_volcengine_vke_node_pool.go index 98a13c33..0b3dbca0 100644 --- a/volcengine/vke/node_pool/resource_volcengine_vke_node_pool.go +++ b/volcengine/vke/node_pool/resource_volcengine_vke_node_pool.go @@ -222,6 +222,7 @@ func ResourceVolcengineNodePool() *schema.Resource { "additional_container_storage_enabled": { Type: schema.TypeBool, Optional: true, + ForceNew: true, Description: "The AdditionalContainerStorageEnabled of NodeConfig.", }, "image_id": { From bb7e1ac7ad7a49b83e569d7271665f4394fd1193 Mon Sep 17 00:00:00 2001 From: zhangpeihua Date: Sat, 17 Sep 2022 19:09:02 +0800 Subject: [PATCH 18/21] feat: update vke node pool --- .../service_volcengine_vke_node_pool.go | 71 +++++++++++++++---- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go b/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go index ad82d775..0349ffea 100644 --- a/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go +++ b/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go @@ -481,20 +481,6 @@ func (s *VolcengineNodePoolService) ModifyResource(resourceData *schema.Resource BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { (*call.SdkParam)["Id"] = d.Id() (*call.SdkParam)["ClusterId"] = d.Get("cluster_id") - - if _, ok := (*call.SdkParam)["KubernetesConfig"]; !ok { - (*call.SdkParam)["KubernetesConfig"] = map[string]interface{}{ - "Labels": []interface{}{}, - "Taints": []interface{}{}, - } - } else { - if _, ok = (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Labels"]; !ok { - (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Labels"] = []interface{}{} - } - if _, ok = (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Taints"]; !ok { - (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Taints"] = []interface{}{} - } - } return true, nil }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { @@ -509,6 +495,63 @@ func (s *VolcengineNodePoolService) ModifyResource(resourceData *schema.Resource } } } + + if d.HasChange("kubernetes_config") { + if _, ok := (*call.SdkParam)["KubernetesConfig"]; !ok { // 列表被删除 + (*call.SdkParam)["KubernetesConfig"] = map[string]interface{}{ + "Labels": []interface{}{}, + "Taints": []interface{}{}, + } + } + } + + labelsChange := false + taintsChange := false + if d.HasChange("kubernetes_config.0.taints") { + taintsChange = true + } + if d.HasChange("kubernetes_config.0.labels") { + labelsChange = true + } + if labelsChange || taintsChange { + if _, ok := (*call.SdkParam)["KubernetesConfig"]; !ok { + (*call.SdkParam)["KubernetesConfig"] = map[string]interface{}{} + } + } + if labelsChange { + if _, ok := (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Labels"]; !ok { // 被清空了 + (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Labels"] = []interface{}{} + } + } + if taintsChange { + if _, ok := (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Taints"]; !ok { + (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Taints"] = []interface{}{} + } + } + + if labelsChange && (!taintsChange) { + var taints []interface{} + for _, taint := range d.Get("kubernetes_config.0.taints").([]interface{}) { + t := taint.(map[string]interface{}) + taints = append(taints, map[string]interface{}{ + "Key": t["key"], + "Value": t["value"], + "Effect": t["effect"], + }) + } + (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Taints"] = taints + } else if taintsChange && (!labelsChange) { + var labels []interface{} + for _, label := range d.Get("kubernetes_config.0.labels").(*schema.Set).List() { // for set + t := label.(map[string]interface{}) + labels = append(labels, map[string]interface{}{ + "Key": t["key"], + "Value": t["value"], + }) + } + (*call.SdkParam)["KubernetesConfig"].(map[string]interface{})["Labels"] = labels + } + logger.Debug(logger.ReqFormat, call.Action, call.SdkParam) resp, err := s.Client.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) logger.Debug(logger.RespFormat, call.Action, resp, err) From cb6cbd88c57ace9d2b86fa5ebceee6b765685a34 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Tue, 20 Sep 2022 10:02:16 +0800 Subject: [PATCH 19/21] Merge branch 'master' into for_tos # Conflicts: # docgen/main.go # volcengine/provider.go # website/volcengine.erb --- common/common_volcengine_version.go | 2 +- website/docs/d/vke_node_pools.html.markdown | 1 + website/docs/r/vke_node_pool.html.markdown | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common/common_volcengine_version.go b/common/common_volcengine_version.go index 7d8d8730..be99564f 100644 --- a/common/common_volcengine_version.go +++ b/common/common_volcengine_version.go @@ -2,5 +2,5 @@ package common const ( TerraformProviderName = "terraform-provider-volcengine" - TerraformProviderVersion = "0.0.21" + TerraformProviderVersion = "0.0.22" ) diff --git a/website/docs/d/vke_node_pools.html.markdown b/website/docs/d/vke_node_pools.html.markdown index 323acc0c..c0e27969 100644 --- a/website/docs/d/vke_node_pools.html.markdown +++ b/website/docs/d/vke_node_pools.html.markdown @@ -45,6 +45,7 @@ In addition to all arguments above, the following attributes are exported: * `create_client_token` - The ClientToken when successfully created. * `create_time` - The CreateTime of NodePool. * `data_volumes` - The DataVolume of NodeConfig. + * `mount_point` - The target mount directory of the disk. * `size` - The Size of DataVolume. * `type` - The Type of DataVolume. * `desired_replicas` - The DesiredReplicas of AutoScaling. diff --git a/website/docs/r/vke_node_pool.html.markdown b/website/docs/r/vke_node_pool.html.markdown index b7c540ec..7262a314 100644 --- a/website/docs/r/vke_node_pool.html.markdown +++ b/website/docs/r/vke_node_pool.html.markdown @@ -61,8 +61,9 @@ The `auto_scaling` object supports the following: The `data_volumes` object supports the following: +* `mount_point` - (Optional, ForceNew) The target mount directory of the disk. Must start with `/`. * `size` - (Optional, ForceNew) The Size of DataVolumes, the value range in 20~32768. -* `type` - (Optional, ForceNew) The Type of DataVolumes, the value can be `PTSSD` or `ESSD_PL0`. +* `type` - (Optional, ForceNew) The Type of DataVolumes, the value can be `PTSSD` or `ESSD_PL0` or `ESSD_FlexPL`. The `kubernetes_config` object supports the following: @@ -85,7 +86,7 @@ The `node_config` object supports the following: * `instance_type_ids` - (Required, ForceNew) The InstanceTypeIds of NodeConfig. * `security` - (Required) The Security of NodeConfig. * `subnet_ids` - (Required, ForceNew) The SubnetIds of NodeConfig. -* `additional_container_storage_enabled` - (Optional) The AdditionalContainerStorageEnabled of NodeConfig. +* `additional_container_storage_enabled` - (Optional, ForceNew) The AdditionalContainerStorageEnabled of NodeConfig. * `auto_renew_period` - (Optional, ForceNew) The AutoRenewPeriod of PrePaid instance of NodeConfig. Valid values: 1, 2, 3, 6, 12. Unit: month. when InstanceChargeType is PrePaid and AutoRenew enable, default value is 1. * `auto_renew` - (Optional, ForceNew) Is AutoRenew of PrePaid instance of NodeConfig. Valid values: true, false. when InstanceChargeType is PrePaid, default value is true. * `data_volumes` - (Optional, ForceNew) The DataVolumes of NodeConfig. @@ -104,7 +105,7 @@ The `security` object supports the following: The `system_volume` object supports the following: * `size` - (Optional, ForceNew) The Size of SystemVolume, the value range in 20~2048. -* `type` - (Optional, ForceNew) The Type of SystemVolume, the value can be `PTSSD` or `ESSD_PL0`. +* `type` - (Optional, ForceNew) The Type of SystemVolume, the value can be `PTSSD` or `ESSD_PL0` or `ESSD_FlexPL`. The `taints` object supports the following: From 1374cdc67b9ecb4b3b18c95cf105cef82653edc4 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Tue, 20 Sep 2022 10:03:51 +0800 Subject: [PATCH 20/21] Merge branch 'master' into for_tos # Conflicts: # docgen/main.go # volcengine/provider.go # website/volcengine.erb --- website/docs/d/tos_objects.html.markdown | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 website/docs/d/tos_objects.html.markdown diff --git a/website/docs/d/tos_objects.html.markdown b/website/docs/d/tos_objects.html.markdown new file mode 100644 index 00000000..83617772 --- /dev/null +++ b/website/docs/d/tos_objects.html.markdown @@ -0,0 +1,32 @@ +--- +subcategory: "TOS(BETA)" +layout: "volcengine" +page_title: "Volcengine: volcengine_tos_objects" +sidebar_current: "docs-volcengine-datasource-tos_objects" +description: |- + Use this data source to query detailed information of tos objects +--- +# volcengine_tos_objects +Use this data source to query detailed information of tos objects +## Example Usage +```hcl +data "volcengine_tos_objects" "default" { + bucket_name = "test" +} +``` +## Argument Reference +The following arguments are supported: +* `bucket_name` - (Required) The name the TOS bucket. +* `name_regex` - (Optional) A Name Regex of TOS Object. +* `object_name` - (Optional) The name the TOS Object. +* `output_file` - (Optional) File name where to save data source results. + +## Attributes Reference +In addition to all arguments above, the following attributes are exported: +* `objects` - The collection of TOS Object query. + * `name` - The name the TOS Object. + * `size` - The name the TOS Object size. + * `storage_class` - The name the TOS Object storage class. +* `total_count` - The total count of TOS Object query. + + From c117dd845485b7064a3f50e2b01baeff51cc13f0 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Tue, 20 Sep 2022 10:17:31 +0800 Subject: [PATCH 21/21] Merge branch 'master' into for_tos # Conflicts: # docgen/main.go # volcengine/provider.go # website/volcengine.erb --- common/common_volcengine_dispatcher.go | 1 - common/common_volcengine_tos_handler.go | 12 ++++++------ .../tos/object/service_volcengine_tos_object.go | 5 +---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/common/common_volcengine_dispatcher.go b/common/common_volcengine_dispatcher.go index aa4fe69f..4a827e09 100644 --- a/common/common_volcengine_dispatcher.go +++ b/common/common_volcengine_dispatcher.go @@ -102,7 +102,6 @@ func (d *Dispatcher) Data(resourceService ResourceService, resourceDate *schema. if err != nil { return err } - break default: break } diff --git a/common/common_volcengine_tos_handler.go b/common/common_volcengine_tos_handler.go index 772ea402..c77e8766 100644 --- a/common/common_volcengine_tos_handler.go +++ b/common/common_volcengine_tos_handler.go @@ -29,18 +29,18 @@ var tosUnmarshalHandler = request.NamedHandler{Name: "TosUnmarshalHandler", Fn: var tosUnmarshalErrorHandler = request.NamedHandler{Name: "TosUnmarshalErrorHandler", Fn: tosUnmarshalError} func tosSign(req *request.Request) { - region := req.ClientInfo.SigningRegion + //region := req.ClientInfo.SigningRegion var ( c Credentials ) - region = volcengine.StringValue(req.Config.Region) + region := volcengine.StringValue(req.Config.Region) - name := req.ClientInfo.SigningName - if name == "" { - name = req.ClientInfo.ServiceID - } + //name := req.ClientInfo.SigningName + //if name == "" { + // name = req.ClientInfo.ServiceID + //} value, _ := req.Config.Credentials.Get() diff --git a/volcengine/tos/object/service_volcengine_tos_object.go b/volcengine/tos/object/service_volcengine_tos_object.go index 57b5a7e5..8e194e56 100644 --- a/volcengine/tos/object/service_volcengine_tos_object.go +++ b/volcengine/tos/object/service_volcengine_tos_object.go @@ -208,10 +208,7 @@ func (VolcengineTosObjectService) WithResourceResponseHandlers(m map[string]inte "EnableVersion": { Convert: func(i interface{}) interface{} { status, _ := ve.ObtainSdkValue("Status", i) - if status.(string) != "Enabled" { - return false - } - return true + return status.(string) == "Enabled" }, }, "AccountAcl": {