2018-05-22 21:43:36 +02:00
|
|
|
// Copyright 2016-2018, 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.
|
2017-06-10 03:34:37 +02:00
|
|
|
|
Make more progress on the new deployment model
This change restructures a lot more pertaining to deployments, snapshots,
environments, and the like.
The most notable change is that the notion of a deploy.Source is introduced,
which splits the responsibility between the deploy.Plan -- which simply
understands how to compute and carry out deployment plans -- and the idea
of something that can produce new objects on-demand during deployment.
The primary such implementation is evalSource, which encapsulates an
interpreter and takes a package, args, and config map, and proceeds to run
the interpreter in a distinct goroutine. It synchronizes as needed to
poke and prod the interpreter along its path to create new resource objects.
There are two other sources, however. First, a nullSource, which simply
refuses to create new objects. This can be handy when writing isolated
tests but is also used to simulate the "empty" environment as necessary to
do a complete teardown of the target environment. Second, a fixedSource,
which takes a pre-computed array of objects, and hands those, in order, to
the planning engine; this is mostly useful as a testing technique.
Boatloads of code is now changed and updated in the various CLI commands.
This further chugs along towards pulumi/lumi#90. The end is in sight.
2017-06-10 20:50:47 +02:00
|
|
|
package deploy
|
2017-06-10 03:34:37 +02:00
|
|
|
|
|
|
|
import (
|
2017-12-05 02:10:40 +01:00
|
|
|
"github.com/pulumi/pulumi/pkg/resource/config"
|
2017-09-22 04:18:21 +02:00
|
|
|
"github.com/pulumi/pulumi/pkg/tokens"
|
2017-06-10 03:34:37 +02:00
|
|
|
)
|
|
|
|
|
Make more progress on the new deployment model
This change restructures a lot more pertaining to deployments, snapshots,
environments, and the like.
The most notable change is that the notion of a deploy.Source is introduced,
which splits the responsibility between the deploy.Plan -- which simply
understands how to compute and carry out deployment plans -- and the idea
of something that can produce new objects on-demand during deployment.
The primary such implementation is evalSource, which encapsulates an
interpreter and takes a package, args, and config map, and proceeds to run
the interpreter in a distinct goroutine. It synchronizes as needed to
poke and prod the interpreter along its path to create new resource objects.
There are two other sources, however. First, a nullSource, which simply
refuses to create new objects. This can be handy when writing isolated
tests but is also used to simulate the "empty" environment as necessary to
do a complete teardown of the target environment. Second, a fixedSource,
which takes a pre-computed array of objects, and hands those, in order, to
the planning engine; this is mostly useful as a testing technique.
Boatloads of code is now changed and updated in the various CLI commands.
This further chugs along towards pulumi/lumi#90. The end is in sight.
2017-06-10 20:50:47 +02:00
|
|
|
// Target represents information about a deployment target.
|
|
|
|
type Target struct {
|
2017-12-05 02:10:40 +01:00
|
|
|
Name tokens.QName // the target stack name.
|
|
|
|
Config config.Map // optional configuration key/value pairs.
|
|
|
|
Decrypter config.Decrypter // decrypter for secret configuration values.
|
2018-01-08 22:01:40 +01:00
|
|
|
Snapshot *Snapshot // the last snapshot deployed to the target.
|
2017-06-10 03:34:37 +02:00
|
|
|
}
|
2018-03-07 01:09:42 +01:00
|
|
|
|
|
|
|
// GetPackageConfig returns the set of configuration parameters for the indicated package, if any.
|
2018-03-02 01:51:09 +01:00
|
|
|
func (t *Target) GetPackageConfig(pkg tokens.Package) (map[config.Key]string, error) {
|
|
|
|
var result map[config.Key]string
|
2018-03-07 01:09:42 +01:00
|
|
|
for k, c := range t.Config {
|
2018-03-03 00:23:59 +01:00
|
|
|
if tokens.Package(k.Namespace()) != pkg {
|
2018-03-07 01:09:42 +01:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
v, err := c.Value(t.Decrypter)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if result == nil {
|
2018-03-02 01:51:09 +01:00
|
|
|
result = make(map[config.Key]string)
|
2018-03-07 01:09:42 +01:00
|
|
|
}
|
|
|
|
result[k] = v
|
|
|
|
}
|
|
|
|
return result, nil
|
|
|
|
}
|