mirror of https://github.com/pulumi/pulumi.git
63 lines
1.9 KiB
Go
63 lines
1.9 KiB
Go
// Copyright 2016-2021, Pulumi Corporation.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
rpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
|
|
|
|
pbempty "github.com/golang/protobuf/ptypes/empty"
|
|
)
|
|
|
|
const creationDelay = 15 * time.Second
|
|
|
|
type slowResourceProvider struct {
|
|
id int
|
|
}
|
|
|
|
func (p *slowResourceProvider) Check(ctx context.Context, req *rpc.CheckRequest) (*rpc.CheckResponse, error) {
|
|
return &rpc.CheckResponse{Inputs: req.News, Failures: nil}, nil
|
|
}
|
|
|
|
func (p *slowResourceProvider) Diff(ctx context.Context, req *rpc.DiffRequest) (*rpc.DiffResponse, error) {
|
|
return &rpc.DiffResponse{Changes: rpc.DiffResponse_DIFF_NONE}, nil
|
|
}
|
|
|
|
func (p *slowResourceProvider) Create(ctx context.Context, req *rpc.CreateRequest) (*rpc.CreateResponse, error) {
|
|
// Intentional delay creating the resource.
|
|
time.Sleep(creationDelay)
|
|
|
|
p.id++
|
|
return &rpc.CreateResponse{Id: fmt.Sprintf("%v", p.id)}, nil
|
|
}
|
|
|
|
func (p *slowResourceProvider) Read(ctx context.Context, req *rpc.ReadRequest) (*rpc.ReadResponse, error) {
|
|
return &rpc.ReadResponse{
|
|
Id: req.Id,
|
|
Properties: req.Properties,
|
|
}, nil
|
|
}
|
|
|
|
func (p *slowResourceProvider) Update(ctx context.Context, req *rpc.UpdateRequest) (*rpc.UpdateResponse, error) {
|
|
panic("Update not implemented")
|
|
}
|
|
|
|
func (p *slowResourceProvider) Delete(ctx context.Context, req *rpc.DeleteRequest) (*pbempty.Empty, error) {
|
|
return &pbempty.Empty{}, nil
|
|
}
|