This change fixes a few things: * Most importantly, we need to place a leading "." in the paths to Gometalinter, otherwise some sub-linters just silently skip the directory altogether. errcheck is one such linter, which is a very important one! * Use an explicit Gometalinter.json file to configure the various settings. This flips on a few additional linters that aren't on by default (line line length checking). Sadly, a few that I'd like to enable take waaaay too much time, so in the future we may consider a nightly job (this includes code similarity, unused parameters, unused functions, and others that generally require global analysis). * Now that we're running more, however, linting takes a while! The core Lumi project now takes 26 seconds to lint on my laptop. That's not terrible, but it's long enough that we don't want to do the silly "run them twice" thing our Makefiles were previously doing. Instead, we shall deploy some $$($${PIPESTATUS[1]}-1))-fu to rely on the fact that grep returns 1 on "zero lines". * Finally, fix the many issues that this turned up. I think(?) we are done, except, of course, for needing to drive down some of the cyclomatic complexity issues (which I'm possibly going to punt on; see pulumi/lumi#259 for more details).
64 lines
3.6 KiB
Go
64 lines
3.6 KiB
Go
// Licensed to Pulumi Corporation ("Pulumi") under one or more
|
|
// contributor license agreements. See the NOTICE file distributed with
|
|
// this work for additional information regarding copyright ownership.
|
|
// Pulumi licenses this file to You 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 plugin
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/pulumi/lumi/pkg/resource"
|
|
"github.com/pulumi/lumi/pkg/tokens"
|
|
)
|
|
|
|
// Provider presents a simple interface for orchestrating resource create, reead, update, and delete operations. Each
|
|
// provider understands how to handle all of the resource types within a single package.
|
|
//
|
|
// This interface hides some of the messiness of the underlying machinery, since providers are behind an RPC boundary.
|
|
//
|
|
// It is important to note that provider operations are not transactional. (Some providers might decide to offer
|
|
// transactional semantics, but such a provider is a rare treat.) As a result, failures in the operations below can
|
|
// range from benign to catastrophic (possibly leaving behind a corrupt resource). It is up to the provider to make a
|
|
// best effort to ensure catastrophes do not occur. The errors returned from mutating operations indicate both the
|
|
// underlying error condition in addition to a bit indicating whether the operation was successfully rolled back.
|
|
type Provider interface {
|
|
// Closer closes any underlying OS resources associated with this provider (like processes, RPC channels, etc).
|
|
io.Closer
|
|
// Pkg fetches this provider's package.
|
|
Pkg() tokens.Package
|
|
// Check validates that the given property bag is valid for a resource of the given type.
|
|
Check(t tokens.Type, props resource.PropertyMap) ([]CheckFailure, error)
|
|
// Name names a given resource. Sometimes this will be assigned by a developer, and so the provider
|
|
// simply fetches it from the property bag; other times, the provider will assign this based on its own algorithm.
|
|
// In any case, resources with the same name must be safe to use interchangeably with one another.
|
|
Name(t tokens.Type, props resource.PropertyMap) (tokens.QName, error)
|
|
// Create allocates a new instance of the provided resource and returns its unique resource.ID.
|
|
Create(t tokens.Type, props resource.PropertyMap) (resource.ID, resource.Status, error)
|
|
// Get reads the instance state identified by res and returns it.
|
|
Get(t tokens.Type, id resource.ID) (resource.PropertyMap, error)
|
|
// InspectChange checks what impacts a hypothetical update will have on the resource's properties.
|
|
InspectChange(t tokens.Type, id resource.ID,
|
|
olds resource.PropertyMap, news resource.PropertyMap) ([]resource.PropertyKey, resource.PropertyMap, error)
|
|
// Update updates an existing resource with new values.
|
|
Update(t tokens.Type, id resource.ID,
|
|
olds resource.PropertyMap, news resource.PropertyMap) (resource.Status, error)
|
|
// Delete tears down an existing resource.
|
|
Delete(t tokens.Type, id resource.ID) (resource.Status, error)
|
|
}
|
|
|
|
// CheckFailure indicates that a call to check failed; it contains the property and reason for the failure.
|
|
type CheckFailure struct {
|
|
Property resource.PropertyKey // the property that failed checking.
|
|
Reason string // the reason the property failed to check.
|
|
}
|