mirror of https://github.com/kubernetes/kops.git
Merge pull request #65 from justinsb/upup_fi_comparison
upup: Add back in CompareWithID functions
This commit is contained in:
commit
fd554601a8
|
|
@ -10,14 +10,8 @@ import (
|
|||
"k8s.io/kube-deploy/upup/pkg/fi"
|
||||
"k8s.io/kube-deploy/upup/pkg/fi/cloudup/awsup"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func buildTimestampString() string {
|
||||
now := time.Now()
|
||||
return now.UTC().Format("20060102T150405Z")
|
||||
}
|
||||
|
||||
// This one is a little weird because we can't update a launch configuration
|
||||
// So we have to create the launch configuration as part of the group
|
||||
//go:generate fitask -type=AutoscalingGroup
|
||||
|
|
@ -157,7 +151,7 @@ func (e *AutoscalingGroup) buildTags(cloud fi.Cloud) map[string]string {
|
|||
|
||||
func (_ *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *AutoscalingGroup) error {
|
||||
if a == nil {
|
||||
launchConfigurationName := *e.Name + "-" + buildTimestampString()
|
||||
launchConfigurationName := *e.Name + "-" + fi.BuildTimestampString()
|
||||
glog.V(2).Infof("Creating autoscaling LaunchConfiguration with Name:%q", launchConfigurationName)
|
||||
|
||||
err := renderAutoscalingLaunchConfigurationAWS(t, launchConfigurationName, e)
|
||||
|
|
@ -196,7 +190,7 @@ func (_ *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
}
|
||||
} else {
|
||||
if changes.UserData != nil {
|
||||
launchConfigurationName := *e.Name + "-" + buildTimestampString()
|
||||
launchConfigurationName := *e.Name + "-" + fi.BuildTimestampString()
|
||||
glog.V(2).Infof("Creating autoscaling LaunchConfiguration with Name:%q", launchConfigurationName)
|
||||
|
||||
err := renderAutoscalingLaunchConfigurationAWS(t, launchConfigurationName, e)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,12 @@ type DHCPOptions struct {
|
|||
DomainNameServers *string
|
||||
}
|
||||
|
||||
var _ fi.CompareWithID = &DHCPOptions{}
|
||||
|
||||
func (e *DHCPOptions) CompareWithID() *string {
|
||||
return e.ID
|
||||
}
|
||||
|
||||
func (e *DHCPOptions) Find(c *fi.Context) (*DHCPOptions, error) {
|
||||
cloud := c.Cloud.(*awsup.AWSCloud)
|
||||
|
||||
|
|
|
|||
|
|
@ -41,12 +41,14 @@ func (e *DNSName) Find(c *fi.Context) (*DNSName, error) {
|
|||
err := cloud.Route53.ListResourceRecordSetsPages(request, func(p *route53.ListResourceRecordSetsOutput, lastPage bool) (shouldContinue bool) {
|
||||
for _, rr := range p.ResourceRecordSets {
|
||||
resourceType := aws.StringValue(rr.Type)
|
||||
name := aws.StringValue(rr.Name)
|
||||
|
||||
glog.V(4).Infof("Found DNS resource %q %q", resourceType, name)
|
||||
|
||||
if findType != resourceType {
|
||||
continue
|
||||
}
|
||||
|
||||
name := aws.StringValue(rr.Name)
|
||||
name = strings.TrimSuffix(name, ".")
|
||||
|
||||
if name == findName {
|
||||
|
|
@ -92,6 +94,7 @@ func (s *DNSName) CheckChanges(a, e, changes *DNSName) error {
|
|||
func (_ *DNSName) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *DNSName) error {
|
||||
rrs := &route53.ResourceRecordSet{
|
||||
Name: e.Name,
|
||||
Type: aws.String(e.ResourceType),
|
||||
}
|
||||
|
||||
if e.TargetLoadBalancer != nil {
|
||||
|
|
@ -100,7 +103,6 @@ func (_ *DNSName) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *DNSName) error
|
|||
EvaluateTargetHealth: aws.Bool(false),
|
||||
HostedZoneId: e.TargetLoadBalancer.HostedZoneId,
|
||||
}
|
||||
rrs.Type = aws.String("A")
|
||||
}
|
||||
|
||||
change := &route53.Change{
|
||||
|
|
|
|||
|
|
@ -17,6 +17,12 @@ type DNSZone struct {
|
|||
ID *string
|
||||
}
|
||||
|
||||
var _ fi.CompareWithID = &DNSZone{}
|
||||
|
||||
func (e *DNSZone) CompareWithID() *string {
|
||||
return e.Name
|
||||
}
|
||||
|
||||
func (e *DNSZone) Find(c *fi.Context) (*DNSZone, error) {
|
||||
cloud := c.Cloud.(*awsup.AWSCloud)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,14 +11,20 @@ import (
|
|||
|
||||
//go:generate fitask -type=EBSVolume
|
||||
type EBSVolume struct {
|
||||
Name *string
|
||||
ID *string
|
||||
AvailabilityZone *string
|
||||
VolumeType *string
|
||||
SizeGB *int64
|
||||
Name *string
|
||||
Tags map[string]string
|
||||
}
|
||||
|
||||
var _ fi.CompareWithID = &EBSVolume{}
|
||||
|
||||
func (e *EBSVolume) CompareWithID() *string {
|
||||
return e.ID
|
||||
}
|
||||
|
||||
type TaggableResource interface {
|
||||
FindResourceID(c fi.Cloud) (*string, error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,14 @@ import (
|
|||
|
||||
//go:generate fitask -type=IAMInstanceProfile
|
||||
type IAMInstanceProfile struct {
|
||||
ID *string
|
||||
Name *string
|
||||
ID *string
|
||||
}
|
||||
|
||||
var _ fi.CompareWithID = &IAMInstanceProfile{}
|
||||
|
||||
func (e *IAMInstanceProfile) CompareWithID() *string {
|
||||
return e.Name
|
||||
}
|
||||
|
||||
func (e *IAMInstanceProfile) Find(c *fi.Context) (*IAMInstanceProfile, error) {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,12 @@ type IAMRole struct {
|
|||
RolePolicyDocument *fi.ResourceHolder // "inline" IAM policy
|
||||
}
|
||||
|
||||
var _ fi.CompareWithID = &IAMRole{}
|
||||
|
||||
func (e *IAMRole) CompareWithID() *string {
|
||||
return e.ID
|
||||
}
|
||||
|
||||
func (e *IAMRole) Find(c *fi.Context) (*IAMRole, error) {
|
||||
cloud := c.Cloud.(*awsup.AWSCloud)
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,12 @@ type InternetGateway struct {
|
|||
ID *string
|
||||
}
|
||||
|
||||
var _ fi.CompareWithID = &InternetGateway{}
|
||||
|
||||
func (e *InternetGateway) CompareWithID() *string {
|
||||
return e.ID
|
||||
}
|
||||
|
||||
func (e *InternetGateway) Find(c *fi.Context) (*InternetGateway, error) {
|
||||
cloud := c.Cloud.(*awsup.AWSCloud)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,12 @@ type RouteTable struct {
|
|||
VPC *VPC
|
||||
}
|
||||
|
||||
var _ fi.CompareWithID = &RouteTable{}
|
||||
|
||||
func (e *RouteTable) CompareWithID() *string {
|
||||
return e.ID
|
||||
}
|
||||
|
||||
func (e *RouteTable) Find(c *fi.Context) (*RouteTable, error) {
|
||||
cloud := c.Cloud.(*awsup.AWSCloud)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,11 +27,15 @@ type SSHKey struct {
|
|||
|
||||
PublicKey *fi.ResourceHolder
|
||||
|
||||
ID *string
|
||||
|
||||
KeyFingerprint *string
|
||||
}
|
||||
|
||||
var _ fi.CompareWithID = &SSHKey{}
|
||||
|
||||
func (e *SSHKey) CompareWithID() *string {
|
||||
return e.Name
|
||||
}
|
||||
|
||||
func (e *SSHKey) Find(c *fi.Context) (*SSHKey, error) {
|
||||
cloud := c.Cloud.(*awsup.AWSCloud)
|
||||
|
||||
|
|
@ -61,7 +65,6 @@ func (e *SSHKey) Find(c *fi.Context) (*SSHKey, error) {
|
|||
|
||||
actual := &SSHKey{
|
||||
Name: k.KeyName,
|
||||
ID: k.KeyName,
|
||||
KeyFingerprint: k.KeyFingerprint,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
package fi
|
||||
|
||||
import "time"
|
||||
|
||||
func BuildTimestampString() string {
|
||||
now := time.Now()
|
||||
return now.UTC().Format("20060102150405")
|
||||
}
|
||||
Loading…
Reference in New Issue