diff --git a/cmd/kops/update_cluster.go b/cmd/kops/update_cluster.go index 7d3af48eebe0a..f5358a3a1f9c4 100644 --- a/cmd/kops/update_cluster.go +++ b/cmd/kops/update_cluster.go @@ -66,6 +66,10 @@ type UpdateClusterOptions struct { CreateKubecfg bool Phase string + + // LifecycleOverrides is a slice of taskName=lifecycle name values. This slice is used + // to populate the LifecycleOverrides struct member in ApplyClusterCmd struct. + LifecycleOverrides []string } func (o *UpdateClusterOptions) InitDefaults() { @@ -109,6 +113,8 @@ func NewCmdUpdateCluster(f *util.Factory, out io.Writer) *cobra.Command { cmd.Flags().StringVar(&options.OutDir, "out", options.OutDir, "Path to write any local output") cmd.Flags().BoolVar(&options.CreateKubecfg, "create-kube-config", options.CreateKubecfg, "Will control automatically creating the kube config file on your local filesystem") cmd.Flags().StringVar(&options.Phase, "phase", options.Phase, "Subset of tasks to run: "+strings.Join(cloudup.Phases.List(), ", ")) + cmd.Flags().StringSliceVar(&options.LifecycleOverrides, "lifecycle-overrides", options.LifecycleOverrides, "comma separated list of phase overrides, example: SecurityGroups=Ignore,InternetGateway=ExistsAndWarnIfChanges") + return cmd } @@ -195,6 +201,25 @@ func RunUpdateCluster(f *util.Factory, clusterName string, out io.Writer, c *Upd } } + lifecycleOverrideMap := make(map[string]fi.Lifecycle) + + for _, override := range c.LifecycleOverrides { + values := strings.Split(override, "=") + if len(values) != 2 { + return fmt.Errorf("Incorrect syntax for lifecyle-overrides, correct syntax is TaskName=lifecycleName, override provided: %q", override) + } + + taskName := values[0] + lifecycleName := values[1] + + lifecycleOverride, err := parseLifecycle(lifecycleName) + if err != nil { + return err + } + + lifecycleOverrideMap[taskName] = lifecycleOverride + } + var instanceGroups []*kops.InstanceGroup { list, err := clientset.InstanceGroupsFor(cluster).List(metav1.ListOptions{}) @@ -207,15 +232,16 @@ func RunUpdateCluster(f *util.Factory, clusterName string, out io.Writer, c *Upd } applyCmd := &cloudup.ApplyClusterCmd{ - Clientset: clientset, - Cluster: cluster, - DryRun: isDryrun, - InstanceGroups: instanceGroups, - MaxTaskDuration: c.MaxTaskDuration, - Models: strings.Split(c.Models, ","), - OutDir: c.OutDir, - Phase: phase, - TargetName: targetName, + Clientset: clientset, + Cluster: cluster, + DryRun: isDryrun, + InstanceGroups: instanceGroups, + MaxTaskDuration: c.MaxTaskDuration, + Models: strings.Split(c.Models, ","), + OutDir: c.OutDir, + Phase: phase, + TargetName: targetName, + LifecycleOverrides: lifecycleOverrideMap, } if err := applyCmd.Run(); err != nil { @@ -335,6 +361,13 @@ func RunUpdateCluster(f *util.Factory, clusterName string, out io.Writer, c *Upd return nil } +func parseLifecycle(lifecycle string) (fi.Lifecycle, error) { + if v, ok := fi.LifecycleNameMap[lifecycle]; ok { + return v, nil + } + return "", fmt.Errorf("unknown lifecycle %q, available lifecycle: %s", lifecycle, strings.Join(fi.Lifecycles.List(), ",")) +} + func usesBastion(instanceGroups []*kops.InstanceGroup) bool { for _, ig := range instanceGroups { if ig.Spec.Role == kops.InstanceGroupRoleBastion { diff --git a/docs/cli/kops_update_cluster.md b/docs/cli/kops_update_cluster.md index 92ceaf1156ab6..3eac123b74d35 100644 --- a/docs/cli/kops_update_cluster.md +++ b/docs/cli/kops_update_cluster.md @@ -26,13 +26,14 @@ kops update cluster ### Options ``` - --create-kube-config Will control automatically creating the kube config file on your local filesystem (default true) - --model string Models to apply (separate multiple models with commas) (default "config,proto,cloudup") - --out string Path to write any local output - --phase string Subset of tasks to run: assets, cluster, network, security - --ssh-public-key string SSH public key to use (deprecated: use kops create secret instead) - --target string Target - direct, terraform, cloudformation (default "direct") - -y, --yes Create cloud resources, without --yes update is in dry run mode + --create-kube-config Will control automatically creating the kube config file on your local filesystem (default true) + --lifecycle-overrides stringSlice comma separated list of phase overrides, example: SecurityGroups=Ignore,InternetGateway=ExistsAndWarnIfChanges + --model string Models to apply (separate multiple models with commas) (default "config,proto,cloudup") + --out string Path to write any local output + --phase string Subset of tasks to run: assets, cluster, network, security + --ssh-public-key string SSH public key to use (deprecated: use kops create secret instead) + --target string Target - direct, terraform, cloudformation (default "direct") + -y, --yes Create cloud resources, without --yes update is in dry run mode ``` ### Options inherited from parent commands diff --git a/upup/pkg/fi/assettasks/copydockerimage_fitask.go b/upup/pkg/fi/assettasks/copydockerimage_fitask.go index c2cd6031ee83e..7bdecfe24c2b6 100644 --- a/upup/pkg/fi/assettasks/copydockerimage_fitask.go +++ b/upup/pkg/fi/assettasks/copydockerimage_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *CopyDockerImage) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *CopyDockerImage) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &CopyDockerImage{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/assettasks/copyfile_fitask.go b/upup/pkg/fi/assettasks/copyfile_fitask.go index 609cc1614736d..53a0e3437dd14 100644 --- a/upup/pkg/fi/assettasks/copyfile_fitask.go +++ b/upup/pkg/fi/assettasks/copyfile_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *CopyFile) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *CopyFile) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &CopyFile{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/apply_cluster.go b/upup/pkg/fi/cloudup/apply_cluster.go index efd2fd4e07b77..5142cb5bd201f 100644 --- a/upup/pkg/fi/cloudup/apply_cluster.go +++ b/upup/pkg/fi/cloudup/apply_cluster.go @@ -123,6 +123,11 @@ type ApplyClusterCmd struct { // Phase can be set to a Phase to run the specific subset of tasks, if we don't want to run everything Phase Phase + + // LifecycleOverrides is passed in to override the lifecycle for one of more tasks. + // The key value is the task name such as InternetGateway and the value is the fi.Lifecycle + // that is re-mapped. + LifecycleOverrides map[string]fi.Lifecycle } func (c *ApplyClusterCmd) Run() error { @@ -628,7 +633,7 @@ func (c *ApplyClusterCmd) Run() error { tf.AddTo(l.TemplateFunctions) - taskMap, err := l.BuildTasks(modelStore, fileModels, assetBuilder, &stageAssetsLifecycle) + taskMap, err := l.BuildTasks(modelStore, fileModels, assetBuilder, &stageAssetsLifecycle, c.LifecycleOverrides) if err != nil { return fmt.Errorf("error building tasks: %v", err) } diff --git a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup_fitask.go b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup_fitask.go index 784a5c22fd506..a71a0c5661612 100644 --- a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *AutoscalingGroup) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *AutoscalingGroup) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &AutoscalingGroup{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/dhcpoptions_fitask.go b/upup/pkg/fi/cloudup/awstasks/dhcpoptions_fitask.go index f37e098818001..04f2b49cc8861 100644 --- a/upup/pkg/fi/cloudup/awstasks/dhcpoptions_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/dhcpoptions_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *DHCPOptions) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *DHCPOptions) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &DHCPOptions{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/dnsname_fitask.go b/upup/pkg/fi/cloudup/awstasks/dnsname_fitask.go index 22cd9621d259c..9733dc545ad98 100644 --- a/upup/pkg/fi/cloudup/awstasks/dnsname_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/dnsname_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *DNSName) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *DNSName) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &DNSName{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/dnszone_fitask.go b/upup/pkg/fi/cloudup/awstasks/dnszone_fitask.go index f17137d7a347c..baf2a3564aed1 100644 --- a/upup/pkg/fi/cloudup/awstasks/dnszone_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/dnszone_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *DNSZone) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *DNSZone) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &DNSZone{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/ebsvolume_fitask.go b/upup/pkg/fi/cloudup/awstasks/ebsvolume_fitask.go index 5cff3395f97f0..84b1bdfd2df39 100644 --- a/upup/pkg/fi/cloudup/awstasks/ebsvolume_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/ebsvolume_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *EBSVolume) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *EBSVolume) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &EBSVolume{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/elasticip_fitask.go b/upup/pkg/fi/cloudup/awstasks/elasticip_fitask.go index 680ddbb04c023..de9db63b3115b 100644 --- a/upup/pkg/fi/cloudup/awstasks/elasticip_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/elasticip_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *ElasticIP) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *ElasticIP) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &ElasticIP{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/iaminstanceprofile_fitask.go b/upup/pkg/fi/cloudup/awstasks/iaminstanceprofile_fitask.go index ebbfb14266a91..ecb8afaae30ad 100644 --- a/upup/pkg/fi/cloudup/awstasks/iaminstanceprofile_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/iaminstanceprofile_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *IAMInstanceProfile) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *IAMInstanceProfile) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &IAMInstanceProfile{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/iaminstanceprofilerole_fitask.go b/upup/pkg/fi/cloudup/awstasks/iaminstanceprofilerole_fitask.go index d31aa22df186e..896b3dc9e7715 100644 --- a/upup/pkg/fi/cloudup/awstasks/iaminstanceprofilerole_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/iaminstanceprofilerole_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *IAMInstanceProfileRole) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *IAMInstanceProfileRole) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &IAMInstanceProfileRole{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/iamrole_fitask.go b/upup/pkg/fi/cloudup/awstasks/iamrole_fitask.go index 75e8fa16a534a..8f112a3a34d4b 100644 --- a/upup/pkg/fi/cloudup/awstasks/iamrole_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/iamrole_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *IAMRole) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *IAMRole) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &IAMRole{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/iamrolepolicy_fitask.go b/upup/pkg/fi/cloudup/awstasks/iamrolepolicy_fitask.go index 4ed84a332515d..acb391864373e 100644 --- a/upup/pkg/fi/cloudup/awstasks/iamrolepolicy_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/iamrolepolicy_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *IAMRolePolicy) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *IAMRolePolicy) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &IAMRolePolicy{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/internetgateway_fitask.go b/upup/pkg/fi/cloudup/awstasks/internetgateway_fitask.go index af8b7706a1a27..f4eaa12f27f5a 100644 --- a/upup/pkg/fi/cloudup/awstasks/internetgateway_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/internetgateway_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *InternetGateway) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *InternetGateway) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &InternetGateway{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/launchconfiguration_fitask.go b/upup/pkg/fi/cloudup/awstasks/launchconfiguration_fitask.go index 2af64fbc13fff..b1c4e677aaff3 100644 --- a/upup/pkg/fi/cloudup/awstasks/launchconfiguration_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/launchconfiguration_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *LaunchConfiguration) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *LaunchConfiguration) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &LaunchConfiguration{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/loadbalancer_fitask.go b/upup/pkg/fi/cloudup/awstasks/loadbalancer_fitask.go index 335d0081903c5..4335601116ec8 100644 --- a/upup/pkg/fi/cloudup/awstasks/loadbalancer_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/loadbalancer_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *LoadBalancer) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *LoadBalancer) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &LoadBalancer{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/loadbalancerattachment_fitask.go b/upup/pkg/fi/cloudup/awstasks/loadbalancerattachment_fitask.go index d5075a765692a..1618f903fc9cb 100644 --- a/upup/pkg/fi/cloudup/awstasks/loadbalancerattachment_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/loadbalancerattachment_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *LoadBalancerAttachment) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *LoadBalancerAttachment) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &LoadBalancerAttachment{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/natgateway_fitask.go b/upup/pkg/fi/cloudup/awstasks/natgateway_fitask.go index 3b9c437642b7e..bf93d83239c11 100644 --- a/upup/pkg/fi/cloudup/awstasks/natgateway_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/natgateway_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *NatGateway) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *NatGateway) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &NatGateway{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/route_fitask.go b/upup/pkg/fi/cloudup/awstasks/route_fitask.go index c6f8e3bbc1a82..2592fa82e9896 100644 --- a/upup/pkg/fi/cloudup/awstasks/route_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/route_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *Route) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *Route) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &Route{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/routetable_fitask.go b/upup/pkg/fi/cloudup/awstasks/routetable_fitask.go index 3f71ad470b586..a00626edc9cbc 100644 --- a/upup/pkg/fi/cloudup/awstasks/routetable_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/routetable_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *RouteTable) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *RouteTable) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &RouteTable{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/routetableassociation_fitask.go b/upup/pkg/fi/cloudup/awstasks/routetableassociation_fitask.go index 8fbecec613f25..e91913350c78f 100644 --- a/upup/pkg/fi/cloudup/awstasks/routetableassociation_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/routetableassociation_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *RouteTableAssociation) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *RouteTableAssociation) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &RouteTableAssociation{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/securitygroup_fitask.go b/upup/pkg/fi/cloudup/awstasks/securitygroup_fitask.go index 386f46f4bb59e..4a1c10170ba2f 100644 --- a/upup/pkg/fi/cloudup/awstasks/securitygroup_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/securitygroup_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *SecurityGroup) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *SecurityGroup) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &SecurityGroup{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/securitygrouprule_fitask.go b/upup/pkg/fi/cloudup/awstasks/securitygrouprule_fitask.go index 099406ec9a200..2eb759716a609 100644 --- a/upup/pkg/fi/cloudup/awstasks/securitygrouprule_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/securitygrouprule_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *SecurityGroupRule) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *SecurityGroupRule) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &SecurityGroupRule{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/sshkey_fitask.go b/upup/pkg/fi/cloudup/awstasks/sshkey_fitask.go index ea123f67cc941..0bd4ebf6aa891 100644 --- a/upup/pkg/fi/cloudup/awstasks/sshkey_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/sshkey_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *SSHKey) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *SSHKey) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &SSHKey{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/subnet_fitask.go b/upup/pkg/fi/cloudup/awstasks/subnet_fitask.go index 356dcd563f56d..e48027a232614 100644 --- a/upup/pkg/fi/cloudup/awstasks/subnet_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/subnet_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *Subnet) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *Subnet) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &Subnet{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/vpc_fitask.go b/upup/pkg/fi/cloudup/awstasks/vpc_fitask.go index 3608967199fd5..34730aa7e4792 100644 --- a/upup/pkg/fi/cloudup/awstasks/vpc_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/vpc_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *VPC) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *VPC) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &VPC{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/awstasks/vpcdhcpoptionsassociation_fitask.go b/upup/pkg/fi/cloudup/awstasks/vpcdhcpoptionsassociation_fitask.go index 8ac7b81e2c2a9..d1bcaa7fcdacb 100644 --- a/upup/pkg/fi/cloudup/awstasks/vpcdhcpoptionsassociation_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/vpcdhcpoptionsassociation_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *VPCDHCPOptionsAssociation) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *VPCDHCPOptionsAssociation) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &VPCDHCPOptionsAssociation{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/dotasks/droplet_fitask.go b/upup/pkg/fi/cloudup/dotasks/droplet_fitask.go index b16937688940a..6aadbf1c62dd9 100644 --- a/upup/pkg/fi/cloudup/dotasks/droplet_fitask.go +++ b/upup/pkg/fi/cloudup/dotasks/droplet_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *Droplet) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *Droplet) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &Droplet{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/dotasks/volume_fitask.go b/upup/pkg/fi/cloudup/dotasks/volume_fitask.go index a1ca7d88ca32d..2189b279642a9 100644 --- a/upup/pkg/fi/cloudup/dotasks/volume_fitask.go +++ b/upup/pkg/fi/cloudup/dotasks/volume_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *Volume) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *Volume) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &Volume{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/gcetasks/address_fitask.go b/upup/pkg/fi/cloudup/gcetasks/address_fitask.go index a7ee0ba12eba7..5a7bba745854b 100644 --- a/upup/pkg/fi/cloudup/gcetasks/address_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/address_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *Address) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *Address) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &Address{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/gcetasks/disk_fitask.go b/upup/pkg/fi/cloudup/gcetasks/disk_fitask.go index 639e11e3ba2f4..9981adf3b0b2a 100644 --- a/upup/pkg/fi/cloudup/gcetasks/disk_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/disk_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *Disk) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *Disk) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &Disk{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/gcetasks/firewallrule_fitask.go b/upup/pkg/fi/cloudup/gcetasks/firewallrule_fitask.go index 1c09213a2d195..81fee91ffcc6b 100644 --- a/upup/pkg/fi/cloudup/gcetasks/firewallrule_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/firewallrule_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *FirewallRule) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *FirewallRule) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &FirewallRule{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/gcetasks/forwardingrule_fitask.go b/upup/pkg/fi/cloudup/gcetasks/forwardingrule_fitask.go index c6dcff263332a..548fd2224282e 100644 --- a/upup/pkg/fi/cloudup/gcetasks/forwardingrule_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/forwardingrule_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *ForwardingRule) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *ForwardingRule) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &ForwardingRule{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/gcetasks/instance_fitask.go b/upup/pkg/fi/cloudup/gcetasks/instance_fitask.go index 4d3993241d32e..4166e36fadf13 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instance_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/instance_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *Instance) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *Instance) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &Instance{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager_fitask.go b/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager_fitask.go index 900ecd672fb91..ed43eb6402e74 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *InstanceGroupManager) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *InstanceGroupManager) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &InstanceGroupManager{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/gcetasks/instancetemplate_fitask.go b/upup/pkg/fi/cloudup/gcetasks/instancetemplate_fitask.go index c8c609767ceaf..a5acce3adfed5 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instancetemplate_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/instancetemplate_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *InstanceTemplate) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *InstanceTemplate) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &InstanceTemplate{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/gcetasks/network_fitask.go b/upup/pkg/fi/cloudup/gcetasks/network_fitask.go index 6d26a08663e24..7b7d4eae3fabe 100644 --- a/upup/pkg/fi/cloudup/gcetasks/network_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/network_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *Network) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *Network) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &Network{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/gcetasks/storagebucketacl_fitask.go b/upup/pkg/fi/cloudup/gcetasks/storagebucketacl_fitask.go index 16242116f51b6..8c971f0196116 100644 --- a/upup/pkg/fi/cloudup/gcetasks/storagebucketacl_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/storagebucketacl_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *StorageBucketAcl) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *StorageBucketAcl) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &StorageBucketAcl{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/gcetasks/storagebucketiam_fitask.go b/upup/pkg/fi/cloudup/gcetasks/storagebucketiam_fitask.go index 82f0d42eee0f7..6f09fa60602fb 100644 --- a/upup/pkg/fi/cloudup/gcetasks/storagebucketiam_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/storagebucketiam_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *StorageBucketIam) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *StorageBucketIam) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &StorageBucketIam{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/gcetasks/storageobjectacl_fitask.go b/upup/pkg/fi/cloudup/gcetasks/storageobjectacl_fitask.go index ea2b0d2ac13c8..278d41f240015 100644 --- a/upup/pkg/fi/cloudup/gcetasks/storageobjectacl_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/storageobjectacl_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *StorageObjectAcl) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *StorageObjectAcl) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &StorageObjectAcl{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/gcetasks/subnet_fitask.go b/upup/pkg/fi/cloudup/gcetasks/subnet_fitask.go index 33a30c8e65a9a..71ae2efe642e6 100644 --- a/upup/pkg/fi/cloudup/gcetasks/subnet_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/subnet_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *Subnet) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *Subnet) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &Subnet{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/gcetasks/targetpool_fitask.go b/upup/pkg/fi/cloudup/gcetasks/targetpool_fitask.go index 0c3b9ab23cbd6..763da639091a6 100644 --- a/upup/pkg/fi/cloudup/gcetasks/targetpool_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/targetpool_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *TargetPool) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *TargetPool) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &TargetPool{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/loader.go b/upup/pkg/fi/cloudup/loader.go index a8dada3dfea72..7e097c2eea253 100644 --- a/upup/pkg/fi/cloudup/loader.go +++ b/upup/pkg/fi/cloudup/loader.go @@ -149,7 +149,7 @@ func ignoreHandler(i *loader.TreeWalkItem) error { return nil } -func (l *Loader) BuildTasks(modelStore vfs.Path, models []string, assetBuilder *assets.AssetBuilder, lifecycle *fi.Lifecycle) (map[string]fi.Task, error) { +func (l *Loader) BuildTasks(modelStore vfs.Path, models []string, assetBuilder *assets.AssetBuilder, lifecycle *fi.Lifecycle, lifecycleOverrides map[string]fi.Lifecycle) (map[string]fi.Task, error) { // Second pass: load everything else tw := &loader.TreeWalker{ DefaultHandler: l.objectHandler, @@ -172,7 +172,8 @@ func (l *Loader) BuildTasks(modelStore vfs.Path, models []string, assetBuilder * for _, builder := range l.Builders { context := &fi.ModelBuilderContext{ - Tasks: l.tasks, + Tasks: l.tasks, + LifecycleOverrides: lifecycleOverrides, } err := builder.Build(context) if err != nil { diff --git a/upup/pkg/fi/cloudup/openstacktasks/securitygroup_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/securitygroup_fitask.go index 2092cb284bb2e..1606a4321e19f 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/securitygroup_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/securitygroup_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *SecurityGroup) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *SecurityGroup) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &SecurityGroup{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go b/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go index 7a5c2a034c00b..609c539687055 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go +++ b/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go @@ -160,6 +160,10 @@ func (r *SecurityGroupRule) GetLifecycle() *fi.Lifecycle { return r.Lifecycle } +func (r *SecurityGroupRule) SetLifecycle(lifecycle fi.Lifecycle) { + r.Lifecycle = &lifecycle +} + func (r *SecurityGroupRule) String() string { return fi.TaskAsString(r) } diff --git a/upup/pkg/fi/cloudup/openstacktasks/volume_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/volume_fitask.go index 7c20bb55f6086..935bfb2513925 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/volume_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/volume_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *Volume) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *Volume) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &Volume{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/fitasks/keypair_fitask.go b/upup/pkg/fi/fitasks/keypair_fitask.go index d1de8a641f544..98e54bbdefdbb 100644 --- a/upup/pkg/fi/fitasks/keypair_fitask.go +++ b/upup/pkg/fi/fitasks/keypair_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *Keypair) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *Keypair) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &Keypair{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/fitasks/managedfile_fitask.go b/upup/pkg/fi/fitasks/managedfile_fitask.go index 31f032773af31..66d95a6dd404a 100644 --- a/upup/pkg/fi/fitasks/managedfile_fitask.go +++ b/upup/pkg/fi/fitasks/managedfile_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *ManagedFile) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *ManagedFile) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &ManagedFile{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/fitasks/mirrorkeystore_fitask.go b/upup/pkg/fi/fitasks/mirrorkeystore_fitask.go index 2ce074c1fa2e7..8bdf6269d4858 100644 --- a/upup/pkg/fi/fitasks/mirrorkeystore_fitask.go +++ b/upup/pkg/fi/fitasks/mirrorkeystore_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *MirrorKeystore) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *MirrorKeystore) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &MirrorKeystore{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/fitasks/mirrorsecrets_fitask.go b/upup/pkg/fi/fitasks/mirrorsecrets_fitask.go index 0707b3ed8f8d1..91721df193990 100644 --- a/upup/pkg/fi/fitasks/mirrorsecrets_fitask.go +++ b/upup/pkg/fi/fitasks/mirrorsecrets_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *MirrorSecrets) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *MirrorSecrets) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &MirrorSecrets{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/fitasks/secret_fitask.go b/upup/pkg/fi/fitasks/secret_fitask.go index b6896a0416433..e766e54df9baa 100644 --- a/upup/pkg/fi/fitasks/secret_fitask.go +++ b/upup/pkg/fi/fitasks/secret_fitask.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,6 +52,11 @@ func (o *Secret) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *Secret) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &Secret{} // GetName returns the Name of the object, implementing fi.HasName diff --git a/upup/pkg/fi/lifecycle.go b/upup/pkg/fi/lifecycle.go index 9f780a9152e29..b586a3a529196 100644 --- a/upup/pkg/fi/lifecycle.go +++ b/upup/pkg/fi/lifecycle.go @@ -16,6 +16,8 @@ limitations under the License. package fi +import "k8s.io/apimachinery/pkg/util/sets" + type Lifecycle string const ( @@ -38,4 +40,27 @@ const ( // HasLifecycle indicates that the task has a Lifecycle type HasLifecycle interface { GetLifecycle() *Lifecycle + // SetLifecycle is used to override a tasks lifecycle. If a lifecycle overide exists for a specific task name, then the + // lifecycle is modified. + SetLifecycle(lifecycle Lifecycle) +} + +// Lifecycles are used for ux validation. When validation fails the lifecycle names are +// printed out. +var Lifecycles = sets.NewString( + string(LifecycleSync), + string(LifecycleIgnore), + string(LifecycleWarnIfInsufficientAccess), + string(LifecycleExistsAndValidates), + string(LifecycleExistsAndWarnIfChanges), +) + +// LifecycleNameMap is used to validate in the UX. When a user provides a lifecycle name +// it then can be mapped to the actual lifecycle. +var LifecycleNameMap = map[string]Lifecycle{ + "Sync": LifecycleSync, + "Ignore": LifecycleIgnore, + "WarnIfInsufficientAccess": LifecycleWarnIfInsufficientAccess, + "ExistsAndValidates": LifecycleExistsAndValidates, + "ExistsAndWarnIfChanges": LifecycleExistsAndWarnIfChanges, } diff --git a/upup/pkg/fi/task.go b/upup/pkg/fi/task.go index 2599f884ad0ec..9a4f30e2330e0 100644 --- a/upup/pkg/fi/task.go +++ b/upup/pkg/fi/task.go @@ -46,10 +46,12 @@ type ModelBuilder interface { // ModelBuilderContext is a context object that holds state we want to pass to ModelBuilder type ModelBuilderContext struct { - Tasks map[string]Task + Tasks map[string]Task + LifecycleOverrides map[string]Lifecycle } func (c *ModelBuilderContext) AddTask(task Task) { + task = c.setLifecycleOverride(task) key := buildTaskKey(task) existing, found := c.Tasks[key] @@ -64,6 +66,7 @@ func (c *ModelBuilderContext) AddTask(task Task) { // If it does exist, it verifies that the existing task reflect.DeepEqual the new task, // if they are different an error is returned. func (c *ModelBuilderContext) EnsureTask(task Task) error { + task = c.setLifecycleOverride(task) key := buildTaskKey(task) existing, found := c.Tasks[key] @@ -83,6 +86,32 @@ func (c *ModelBuilderContext) EnsureTask(task Task) error { return nil } +// setLifecycleOverride determines if a Lifecycle is in the LifecycleOverrides map for the current task. +// If the lifecycle exist then the task lifecycle is set to the lifecycle provides in LifecycleOverrides. +// This func allows for lifecycles to be passed in dynamically and have the task lifecycle set accordingly. +func (c *ModelBuilderContext) setLifecycleOverride(task Task) Task { + // TODO(@chrislovecnm) - wonder if we should update the nodeup tasks to have lifecycle + // TODO - so that we can return an error here, rather than just returning. + // certain tasks have not implemented HasLifecycle interface + hl, ok := task.(HasLifecycle) + if !ok { + glog.V(8).Infof("task %T does not implement HasLifecycle", task) + return task + } + + typeName := TypeNameForTask(task) + glog.V(8).Infof("testing task %q", typeName) + + // typeName can be values like "InternetGateway" + value, ok := c.LifecycleOverrides[typeName] + if ok { + glog.Warningf("overriding task %s, lifecycle %s", task, value) + hl.SetLifecycle(value) + } + + return task +} + func buildTaskKey(task Task) string { hasName, ok := task.(HasName) if !ok { diff --git a/upup/tools/generators/fitask/generator.go b/upup/tools/generators/fitask/generator.go index cf6e57d51a2cc..7eb65296ff782 100644 --- a/upup/tools/generators/fitask/generator.go +++ b/upup/tools/generators/fitask/generator.go @@ -30,7 +30,7 @@ type FitaskGenerator struct { var _ codegen.Generator = &FitaskGenerator{} const fileHeaderDef = `/* -Copyright 2016 The Kubernetes Authors. +Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -86,6 +86,11 @@ func (o *{{.Name}}) GetLifecycle() *fi.Lifecycle { return o.Lifecycle } +// SetLifecycle sets the Lifecycle of the object, implementing fi.SetLifecycle +func (o *{{.Name}}) SetLifecycle(lifecycle fi.Lifecycle) { + o.Lifecycle = &lifecycle +} + var _ fi.HasName = &{{.Name}}{} // GetName returns the Name of the object, implementing fi.HasName