From b23f0ebb26439a2caadeeaae143c4d4529270174 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Sun, 26 Jul 2020 23:09:27 -0700 Subject: [PATCH 1/8] Remove dead code --- hack/.packages | 1 - upup/pkg/fi/cloudup/dnstasks/BUILD.bazel | 13 --- upup/pkg/fi/cloudup/dnstasks/dnszone.go | 129 ----------------------- 3 files changed, 143 deletions(-) delete mode 100644 upup/pkg/fi/cloudup/dnstasks/BUILD.bazel delete mode 100644 upup/pkg/fi/cloudup/dnstasks/dnszone.go diff --git a/hack/.packages b/hack/.packages index 740757f37a103..a678ada2ca2b5 100644 --- a/hack/.packages +++ b/hack/.packages @@ -165,7 +165,6 @@ k8s.io/kops/upup/pkg/fi/cloudup/aliup k8s.io/kops/upup/pkg/fi/cloudup/awstasks k8s.io/kops/upup/pkg/fi/cloudup/awsup k8s.io/kops/upup/pkg/fi/cloudup/cloudformation -k8s.io/kops/upup/pkg/fi/cloudup/dnstasks k8s.io/kops/upup/pkg/fi/cloudup/do k8s.io/kops/upup/pkg/fi/cloudup/dotasks k8s.io/kops/upup/pkg/fi/cloudup/gce diff --git a/upup/pkg/fi/cloudup/dnstasks/BUILD.bazel b/upup/pkg/fi/cloudup/dnstasks/BUILD.bazel deleted file mode 100644 index 3f9e44f4684cb..0000000000000 --- a/upup/pkg/fi/cloudup/dnstasks/BUILD.bazel +++ /dev/null @@ -1,13 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = ["dnszone.go"], - importpath = "k8s.io/kops/upup/pkg/fi/cloudup/dnstasks", - visibility = ["//visibility:public"], - deps = [ - "//dnsprovider/pkg/dnsprovider:go_default_library", - "//upup/pkg/fi:go_default_library", - "//vendor/k8s.io/klog:go_default_library", - ], -) diff --git a/upup/pkg/fi/cloudup/dnstasks/dnszone.go b/upup/pkg/fi/cloudup/dnstasks/dnszone.go deleted file mode 100644 index 73794336b3a11..0000000000000 --- a/upup/pkg/fi/cloudup/dnstasks/dnszone.go +++ /dev/null @@ -1,129 +0,0 @@ -/* -Copyright 2019 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. -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 dnstasks - -import ( - "fmt" - - "strings" - - "k8s.io/klog" - "k8s.io/kops/dnsprovider/pkg/dnsprovider" - "k8s.io/kops/upup/pkg/fi" -) - -// DNSZone is a zone object in a dns provider -//go:generate fitask -type=DNSZone -type DNSZone struct { - Name *string - ID *string -} - -var _ fi.CompareWithID = &DNSZone{} - -func (e *DNSZone) CompareWithID() *string { - return e.Name -} - -func (e *DNSZone) Find(c *fi.Context) (*DNSZone, error) { - dns := c.DNS - - z, err := e.findExisting(dns) - if err != nil { - return nil, err - } - - if z == nil { - return nil, nil - } - - actual := &DNSZone{} - actual.Name = e.Name - actual.ID = fi.String(z.Name()) - - if e.ID == nil { - e.ID = actual.ID - } - - return actual, nil -} - -func (e *DNSZone) findExisting(dns dnsprovider.Interface) (dnsprovider.Zone, error) { - findName := fi.StringValue(e.Name) - if findName == "" { - return nil, nil - } - if !strings.HasSuffix(findName, ".") { - findName += "." - } - zonesProvider, ok := dns.Zones() - if !ok { - return nil, fmt.Errorf("DNS provider does not support zones") - } - // TODO: Support filtering! - zones, err := zonesProvider.List() - if err != nil { - return nil, fmt.Errorf("error listing DNS zones: %v", err) - } - - for _, zone := range zones { - if zone.Name() == findName { - zones = append(zones, zone) - } - } - if len(zones) == 0 { - return nil, nil - } - if len(zones) != 1 { - return nil, fmt.Errorf("found multiple hosted zones matching name %q", findName) - } - - return zones[0], nil -} - -func (e *DNSZone) Run(c *fi.Context) error { - return fi.DefaultDeltaRunMethod(e, c) -} - -func (s *DNSZone) CheckChanges(a, e, changes *DNSZone) error { - if fi.StringValue(e.Name) == "" { - return fi.RequiredField("Name") - } - return nil -} - -func (_ *DNSZone) Render(c *fi.Context, a, e, changes *DNSZone) error { - dns := c.DNS - zonesProvider, ok := dns.Zones() - if !ok { - return fmt.Errorf("DNS provider does not support zones") - } - - if a == nil { - name := fi.StringValue(e.Name) - - klog.V(2).Infof("Creating DNS Zone with Name %q", name) - zone, err := zonesProvider.New(name) - if err != nil { - return fmt.Errorf("error creating DNS Zone %q: %v", name, err) - } - - e.ID = fi.String(zone.Name()) - } - - return nil -} From 9596ed8f373abec6dc7745f9726de6a7398b8fa5 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Sun, 26 Jul 2020 18:05:47 -0700 Subject: [PATCH 2/8] Reimplement fitask generator using gengo --- Makefile | 10 +- go.mod | 1 + go.sum | 7 + hack/.packages | 1 - upup/tools/generators/fitask/BUILD.bazel | 9 +- upup/tools/generators/fitask/generator.go | 139 ++++++++++++------ upup/tools/generators/fitask/main.go | 20 ++- upup/tools/generators/pkg/codegen/BUILD.bazel | 12 -- .../tools/generators/pkg/codegen/generator.go | 26 ---- .../generators/pkg/codegen/main_helper.go | 136 ----------------- upup/tools/generators/pkg/codegen/parse.go | 119 --------------- 11 files changed, 127 insertions(+), 353 deletions(-) delete mode 100644 upup/tools/generators/pkg/codegen/BUILD.bazel delete mode 100644 upup/tools/generators/pkg/codegen/generator.go delete mode 100644 upup/tools/generators/pkg/codegen/main_helper.go delete mode 100644 upup/tools/generators/pkg/codegen/parse.go diff --git a/Makefile b/Makefile index 661c5931abd8c..7c13c81fb4eff 100644 --- a/Makefile +++ b/Makefile @@ -162,14 +162,8 @@ upup/models/bindata.go: ${UPUP_MODELS_BINDATA_SOURCES} .PHONY: codegen codegen: kops-gobindata go install k8s.io/kops/upup/tools/generators/... - PATH="${GOPATH_1ST}/bin:${PATH}" go generate k8s.io/kops/upup/pkg/fi/cloudup/awstasks - PATH="${GOPATH_1ST}/bin:${PATH}" go generate k8s.io/kops/upup/pkg/fi/cloudup/gcetasks - PATH="${GOPATH_1ST}/bin:${PATH}" go generate k8s.io/kops/upup/pkg/fi/cloudup/dotasks - PATH="${GOPATH_1ST}/bin:${PATH}" go generate k8s.io/kops/upup/pkg/fi/cloudup/openstacktasks - PATH="${GOPATH_1ST}/bin:${PATH}" go generate k8s.io/kops/upup/pkg/fi/cloudup/alitasks - PATH="${GOPATH_1ST}/bin:${PATH}" go generate k8s.io/kops/upup/pkg/fi/cloudup/spotinsttasks - PATH="${GOPATH_1ST}/bin:${PATH}" go generate k8s.io/kops/upup/pkg/fi/assettasks - PATH="${GOPATH_1ST}/bin:${PATH}" go generate k8s.io/kops/upup/pkg/fi/fitasks + ${GOPATH_1ST}/bin/fitask --input-dirs k8s.io/kops/upup/pkg/fi/... \ + --go-header-file "hack/boilerplate/boilerplate.go.txt" .PHONY: protobuf protobuf: diff --git a/go.mod b/go.mod index e9a306b9d7269..fdaa84d28be62 100644 --- a/go.mod +++ b/go.mod @@ -114,6 +114,7 @@ require ( k8s.io/client-go v0.18.1 k8s.io/cloud-provider-openstack v1.17.0 k8s.io/component-base v0.18.1 + k8s.io/gengo v0.0.0-20200710205751-c0d492a0f3ca k8s.io/helm v2.9.0+incompatible k8s.io/klog v1.0.0 k8s.io/kubectl v0.0.0 diff --git a/go.sum b/go.sum index 6e55e4b1bc839..e40a1fc1c1e56 100644 --- a/go.sum +++ b/go.sum @@ -370,6 +370,8 @@ github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= @@ -1017,6 +1019,7 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191203134012-c197fd4bf371 h1:Cjq6sG3gnKDchzWy7ouGQklhxMtWvh4AhSNJ0qGIeo4= golang.org/x/tools v0.0.0-20191203134012-c197fd4bf371/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f h1:JcoF/bowzCDI+MXu1yLqQGNO3ibqWsWq+Sk7pOT218w= golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1142,6 +1145,8 @@ k8s.io/gengo v0.0.0-20190822140433-26a664648505 h1:ZY6yclUKVbZ+SdWnkfY+Je5vrMpKO k8s.io/gengo v0.0.0-20190822140433-26a664648505/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20200114144118-36b2048a9120 h1:RPscN6KhmG54S33L+lr3GS+oD1jmchIU0ll519K6FA4= k8s.io/gengo v0.0.0-20200114144118-36b2048a9120/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/gengo v0.0.0-20200710205751-c0d492a0f3ca h1:/o8XeHsWWmi4lTKp3uxWAZY7Eq/v1HelCDmrKZM4SVQ= +k8s.io/gengo v0.0.0-20200710205751-c0d492a0f3ca/go.mod h1:aG2eeomYfcUw8sE3fa7YdkjgnGtyY56TjZlaJJ0ZoWo= k8s.io/heapster v1.2.0-beta.1/go.mod h1:h1uhptVXMwC8xtZBYsPXKVi8fpdlYkTs6k949KozGrM= k8s.io/helm v2.9.0+incompatible h1:3EFDJoqKSUe1BpC9qP+YaHi2Oua9hFT+C24/LhX2G1g= k8s.io/helm v2.9.0+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI= @@ -1151,6 +1156,8 @@ k8s.io/klog v0.3.1 h1:RVgyDHY/kFKtLqh67NvEWIgkMneNoIrdkN0CxDSQc68= k8s.io/klog v0.3.1/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= +k8s.io/klog/v2 v2.0.0 h1:Foj74zO6RbjjP4hBEKjnYtjjAhGg4jNynUdYF6fJrok= +k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/kube-aggregator v0.18.1/go.mod h1:cXwR5+w/IZ/6tbDGFz3aEYrZctFN9R3X6u0gUcWwVzA= k8s.io/kube-controller-manager v0.18.1/go.mod h1:HFp15+aGPbGns4K9jD9TxJVuc9eeiylCtjgCunRV3B4= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= diff --git a/hack/.packages b/hack/.packages index a678ada2ca2b5..203321be3734a 100644 --- a/hack/.packages +++ b/hack/.packages @@ -184,7 +184,6 @@ k8s.io/kops/upup/pkg/fi/secrets k8s.io/kops/upup/pkg/fi/utils k8s.io/kops/upup/pkg/kutil k8s.io/kops/upup/tools/generators/fitask -k8s.io/kops/upup/tools/generators/pkg/codegen k8s.io/kops/util/pkg/architectures k8s.io/kops/util/pkg/env k8s.io/kops/util/pkg/exec diff --git a/upup/tools/generators/fitask/BUILD.bazel b/upup/tools/generators/fitask/BUILD.bazel index b913c55ab188d..8b9b1eb7406a1 100644 --- a/upup/tools/generators/fitask/BUILD.bazel +++ b/upup/tools/generators/fitask/BUILD.bazel @@ -8,7 +8,14 @@ go_library( ], importpath = "k8s.io/kops/upup/tools/generators/fitask", visibility = ["//visibility:private"], - deps = ["//upup/tools/generators/pkg/codegen:go_default_library"], + deps = [ + "//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + "//vendor/k8s.io/gengo/generator:go_default_library", + "//vendor/k8s.io/gengo/namer:go_default_library", + "//vendor/k8s.io/gengo/types:go_default_library", + "//vendor/k8s.io/klog/v2:go_default_library", + ], ) go_binary( diff --git a/upup/tools/generators/fitask/generator.go b/upup/tools/generators/fitask/generator.go index ef644c0f5cc3f..9859cdb64e66d 100644 --- a/upup/tools/generators/fitask/generator.go +++ b/upup/tools/generators/fitask/generator.go @@ -17,45 +17,26 @@ limitations under the License. package main import ( + "fmt" "io" + "path/filepath" + "strings" "text/template" - "k8s.io/kops/upup/tools/generators/pkg/codegen" + "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/gengo/args" + "k8s.io/gengo/generator" + "k8s.io/gengo/namer" + "k8s.io/gengo/types" + "k8s.io/klog/v2" ) -type FitaskGenerator struct { - Package string -} - -var _ codegen.Generator = &FitaskGenerator{} - -const fileHeaderDef = `/* -Copyright 2019 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. -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. -*/ - -` +// These are the comment tags that carry parameters for fitask generation. +const tagName = "kops:fitask" -var preambleDef = ` -package {{.Package}} - -import ( - "encoding/json" - - "k8s.io/kops/upup/pkg/fi" -) -` +func extractTag(comments []string) []string { + return types.ExtractCommentTags("+", comments)[tagName] +} const perTypeDef = ` // {{.Name}} @@ -109,33 +90,99 @@ func (o *{{.Name}}) String() string { } ` -func (g *FitaskGenerator) Init(parser *codegen.GoParser) error { - g.Package = parser.Package.Name +// NameSystems returns the name system used by the generators in this package. +func NameSystems() namer.NameSystems { + return namer.NameSystems{ + "public": namer.NewPublicNamer(0), + "private": namer.NewPrivateNamer(0), + "raw": namer.NewRawNamer("", nil), + } +} - return nil +// DefaultNameSystem returns the default name system for ordering the types to be +// processed by the generators in this package. +func DefaultNameSystem() string { + return "public" } -func (g *FitaskGenerator) WriteFileHeader(w io.Writer) error { - t := template.Must(template.New("FileHeader").Parse(fileHeaderDef)) +// Packages makes the sets package definition. +func Packages(context *generator.Context, arguments *args.GeneratorArgs) generator.Packages { + boilerplate, err := arguments.LoadGoBoilerplate() + if err != nil { + klog.Fatalf("Failed loading boilerplate: %v", err) + } + + inputs := sets.NewString(context.Inputs...) + packages := generator.Packages{} + header := append([]byte(fmt.Sprintf("// +build !%s\n\n", arguments.GeneratedBuildTag)), boilerplate...) + + for i := range inputs { + klog.V(5).Infof("considering pkg %q", i) + pkg := context.Universe[i] + if pkg == nil { + // If the input had no Go files, for example. + continue + } + + fitasks := map[*types.Type]bool{} + for _, t := range pkg.Types { + if t.Kind == types.Struct && len(extractTag(t.CommentLines)) > 0 { + fitasks[t] = true + } + } + + packages = append(packages, &generator.DefaultPackage{ + PackageName: filepath.Base(pkg.Path), + PackagePath: strings.TrimPrefix(pkg.Path, "k8s.io/kops/"), + HeaderText: header, + GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) { + for t := range fitasks { + generators = append(generators, NewGenFitask(t)) + } + return generators + }, + FilterFunc: func(c *generator.Context, t *types.Type) bool { + return fitasks[t] + }, + }) + } - return t.Execute(w, g) + return packages } -func (g *FitaskGenerator) WritePreamble(w io.Writer) error { - t := template.Must(template.New("Preamble").Parse(preambleDef)) +type genFitask struct { + generator.DefaultGen + typeToMatch *types.Type +} - return t.Execute(w, g) +func NewGenFitask(t *types.Type) generator.Generator { + return &genFitask{ + DefaultGen: generator.DefaultGen{ + OptionalName: strings.ToLower(t.Name.Name) + "_fitask", + }, + typeToMatch: t, + } +} + +// Filter ignores all but one type because we're making a single file per type. +func (g *genFitask) Filter(c *generator.Context, t *types.Type) bool { return t == g.typeToMatch } + +func (g *genFitask) Imports(c *generator.Context) (imports []string) { + return []string{ + "encoding/json", + "k8s.io/kops/upup/pkg/fi", + } } type TypeData struct { Name string } -func (g *FitaskGenerator) WriteType(w io.Writer, typeName string) error { - t := template.Must(template.New("PerType").Parse(perTypeDef)) +func (g *genFitask) GenerateType(_ *generator.Context, t *types.Type, w io.Writer) error { + tmpl := template.Must(template.New("PerType").Parse(perTypeDef)) d := &TypeData{} - d.Name = typeName + d.Name = t.Name.Name - return t.Execute(w, d) + return tmpl.Execute(w, d) } diff --git a/upup/tools/generators/fitask/main.go b/upup/tools/generators/fitask/main.go index 2b3e239449a7a..2428dec9e067b 100644 --- a/upup/tools/generators/fitask/main.go +++ b/upup/tools/generators/fitask/main.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -17,10 +17,22 @@ limitations under the License. package main import ( - "k8s.io/kops/upup/tools/generators/pkg/codegen" + "os" + + "k8s.io/gengo/args" + "k8s.io/klog/v2" ) func main() { - generator := &FitaskGenerator{} - codegen.RunGenerator("fitask", generator) + klog.InitFlags(nil) + arguments := args.Default() + if err := arguments.Execute( + NameSystems(), + DefaultNameSystem(), + Packages, + ); err != nil { + klog.Errorf("Error: %v", err) + os.Exit(1) + } + klog.V(2).Info("Completed successfully.") } diff --git a/upup/tools/generators/pkg/codegen/BUILD.bazel b/upup/tools/generators/pkg/codegen/BUILD.bazel deleted file mode 100644 index b98acc31c3b13..0000000000000 --- a/upup/tools/generators/pkg/codegen/BUILD.bazel +++ /dev/null @@ -1,12 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "generator.go", - "main_helper.go", - "parse.go", - ], - importpath = "k8s.io/kops/upup/tools/generators/pkg/codegen", - visibility = ["//visibility:public"], -) diff --git a/upup/tools/generators/pkg/codegen/generator.go b/upup/tools/generators/pkg/codegen/generator.go deleted file mode 100644 index 8c1cfbd33cebb..0000000000000 --- a/upup/tools/generators/pkg/codegen/generator.go +++ /dev/null @@ -1,26 +0,0 @@ -/* -Copyright 2019 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. -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 codegen - -import "io" - -type Generator interface { - Init(parser *GoParser) error - WriteFileHeader(w io.Writer) error - WritePreamble(w io.Writer) error - WriteType(w io.Writer, typeName string) error -} diff --git a/upup/tools/generators/pkg/codegen/main_helper.go b/upup/tools/generators/pkg/codegen/main_helper.go deleted file mode 100644 index cafec215a1865..0000000000000 --- a/upup/tools/generators/pkg/codegen/main_helper.go +++ /dev/null @@ -1,136 +0,0 @@ -/* -Copyright 2019 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. -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 codegen - -import ( - "bytes" - "flag" - "fmt" - "go/format" - "io/ioutil" - "log" - "os" - "path/filepath" - "strings" -) - -var ( - flagTypes = flag.String("type", "", "comma-separated list of type names; must be set") - output = flag.String("output", "", "output file name; default srcdir/_fitask.go") -) - -// Usage is a replacement usage function for the flags package. -func Usage() { - fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) - fmt.Fprintf(os.Stderr, "\tfitask [flags] -type T [directory]\n") - fmt.Fprintf(os.Stderr, "\tfitask [flags] -type T files... # Must be a single package\n") - fmt.Fprintf(os.Stderr, "Flags:\n") - flag.PrintDefaults() -} - -// isDirectory reports whether the named file is a directory. -func isDirectory(name string) bool { - info, err := os.Stat(name) - if err != nil { - log.Fatal(err) - } - return info.IsDir() -} - -func RunGenerator(key string, generator Generator) { - flag.Usage = Usage - flag.Parse() - if len(*flagTypes) == 0 { - flag.Usage() - os.Exit(2) - } - typeNames := strings.Split(*flagTypes, ",") - - // We accept either one directory or a list of files. Which do we have? - args := flag.Args() - if len(args) == 0 { - // Default: process whole package in current directory. - args = []string{"."} - } - - // Parse the package once. - var dir string - var parser GoParser - - if len(args) == 1 && isDirectory(args[0]) { - dir = args[0] - parser.parsePackageDir(args[0]) - //} else { - // dir = filepath.Dir(args[0]) - // g.parsePackageFiles(args) - } - - err := generator.Init(&parser) - if err != nil { - log.Fatalf("error initializing generator: %v", err) - } - - var b bytes.Buffer - - err = generator.WriteFileHeader(&b) - if err != nil { - log.Fatalf("error generating header: %v", err) - } - - fmt.Fprintf(&b, "// Code generated by \"%q %s\"; DO NOT EDIT\n\n", key, strings.Join(os.Args[1:], " ")) - - err = generator.WritePreamble(&b) - if err != nil { - log.Fatalf("error generating header: %v", err) - } - - // Run generate for each type. - for _, typeName := range typeNames { - err := generator.WriteType(&b, typeName) - if err != nil { - log.Fatalf("error generating header: %v", err) - } - } - - // gofmt the output. - src := gofmt(b.Bytes()) - - // Write to file. - outputName := *output - if outputName == "" { - baseName := fmt.Sprintf("%s_%s.go", typeNames[0], key) - outputName = filepath.Join(dir, strings.ToLower(baseName)) - } - err = ioutil.WriteFile(outputName, src, 0644) - if err != nil { - log.Fatalf("writing output: %s", err) - } - -} - -// format returns the gofmt-ed contents of the Generator's buffer. -func gofmt(src []byte) []byte { - formatted, err := format.Source(src) - if err != nil { - // Should never happen, but can arise when developing this code. - // The user can compile the output to see the error. - log.Printf("warning: internal error: invalid Go generated: %s", err) - log.Printf("warning: compile the package to analyze the error") - return src - } - return formatted -} diff --git a/upup/tools/generators/pkg/codegen/parse.go b/upup/tools/generators/pkg/codegen/parse.go deleted file mode 100644 index 24b0a16ee0780..0000000000000 --- a/upup/tools/generators/pkg/codegen/parse.go +++ /dev/null @@ -1,119 +0,0 @@ -/* -Copyright 2019 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. -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 codegen - -import ( - "go/ast" - "go/build" - "go/importer" - "go/parser" - "go/token" - "go/types" - "log" - "path/filepath" - "strings" -) - -type GoParser struct { - Package *Package // Package we are scanning. -} - -// File holds a single parsed file and associated data. -type File struct { - pkg *Package // Package to which this file belongs. - file *ast.File // Parsed AST. -} - -type Package struct { - dir string - Name string - defs map[*ast.Ident]types.Object - files []*File - typesPkg *types.Package -} - -// prefixDirectory prepends the directory name on the beginning of each name in the list. -func prefixDirectory(directory string, names []string) []string { - if directory == "." { - return names - } - ret := make([]string, len(names)) - for i, name := range names { - ret[i] = filepath.Join(directory, name) - } - return ret -} - -// parsePackageDir parses the package residing in the directory. -func (g *GoParser) parsePackageDir(directory string) { - pkg, err := build.Default.ImportDir(directory, 0) - if err != nil { - log.Fatalf("cannot process directory %s: %s", directory, err) - } - var names []string - names = append(names, pkg.GoFiles...) - //names = append(names, pkg.CgoFiles...) - //names = append(names, pkg.SFiles...) - names = prefixDirectory(directory, names) - g.parsePackage(directory, names, nil) -} - -// parsePackage analyzes the single package constructed from the named files. -// If text is non-nil, it is a string to be used instead of the content of the file, -// to be used for testing. parsePackage exits if there is an error. -func (g *GoParser) parsePackage(directory string, names []string, text interface{}) { - var files []*File - var astFiles []*ast.File - g.Package = new(Package) - fs := token.NewFileSet() - for _, name := range names { - if !strings.HasSuffix(name, ".go") { - continue - } - parsedFile, err := parser.ParseFile(fs, name, text, 0) - if err != nil { - log.Fatalf("parsing package: %s: %s", name, err) - } - astFiles = append(astFiles, parsedFile) - files = append(files, &File{ - file: parsedFile, - pkg: g.Package, - }) - } - if len(astFiles) == 0 { - log.Fatalf("%s: no buildable Go files", directory) - } - g.Package.Name = astFiles[0].Name.Name - g.Package.files = files - g.Package.dir = directory - // Type check the package. - g.Package.check(fs, astFiles) -} - -// check type-checks the package. The package must be OK to proceed. -func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) { - pkg.defs = make(map[*ast.Ident]types.Object) - config := types.Config{Importer: importer.ForCompiler(token.NewFileSet(), "source", nil), FakeImportC: true} - info := &types.Info{ - Defs: pkg.defs, - } - typesPkg, err := config.Check(pkg.dir, fs, astFiles, info) - if err != nil { - log.Fatalf("checking package: %s", err) - } - pkg.typesPkg = typesPkg -} From ae8688b35683301afb925e0c5c973ec02c3268f4 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Sun, 26 Jul 2020 18:06:15 -0700 Subject: [PATCH 3/8] make gomod --- go.mod | 1 + .../github.com/google/go-cmp/cmp/compare.go | 83 +- .../google/go-cmp/cmp/export_panic.go | 4 +- .../google/go-cmp/cmp/export_unsafe.go | 6 +- .../github.com/google/go-cmp/cmp/options.go | 55 +- vendor/github.com/google/go-cmp/cmp/path.go | 71 +- vendor/golang.org/x/tools/imports/BUILD.bazel | 10 + vendor/golang.org/x/tools/imports/forward.go | 62 + vendor/k8s.io/gengo/LICENSE | 202 +++ vendor/k8s.io/gengo/args/BUILD.bazel | 16 + vendor/k8s.io/gengo/args/args.go | 212 +++ vendor/k8s.io/gengo/generator/BUILD.bazel | 26 + .../gengo/generator/default_generator.go | 62 + .../k8s.io/gengo/generator/default_package.go | 75 + vendor/k8s.io/gengo/generator/doc.go | 31 + .../k8s.io/gengo/generator/error_tracker.go | 50 + vendor/k8s.io/gengo/generator/execute.go | 314 ++++ vendor/k8s.io/gengo/generator/generator.go | 256 +++ .../k8s.io/gengo/generator/import_tracker.go | 70 + .../k8s.io/gengo/generator/snippet_writer.go | 154 ++ .../gengo/generator/transitive_closure.go | 65 + vendor/k8s.io/gengo/namer/BUILD.bazel | 16 + vendor/k8s.io/gengo/namer/doc.go | 31 + vendor/k8s.io/gengo/namer/import_tracker.go | 112 ++ vendor/k8s.io/gengo/namer/namer.go | 383 +++++ vendor/k8s.io/gengo/namer/order.go | 72 + vendor/k8s.io/gengo/namer/plural_namer.go | 120 ++ vendor/k8s.io/gengo/parser/BUILD.bazel | 16 + vendor/k8s.io/gengo/parser/doc.go | 19 + vendor/k8s.io/gengo/parser/parse.go | 862 ++++++++++ vendor/k8s.io/gengo/types/BUILD.bazel | 14 + vendor/k8s.io/gengo/types/comments.go | 82 + vendor/k8s.io/gengo/types/doc.go | 19 + vendor/k8s.io/gengo/types/flatten.go | 57 + vendor/k8s.io/gengo/types/types.go | 526 ++++++ vendor/k8s.io/klog/v2/.gitignore | 17 + vendor/k8s.io/klog/v2/BUILD.bazel | 13 + vendor/k8s.io/klog/v2/CONTRIBUTING.md | 22 + vendor/k8s.io/klog/v2/LICENSE | 191 +++ vendor/k8s.io/klog/v2/OWNERS | 19 + vendor/k8s.io/klog/v2/README.md | 99 ++ vendor/k8s.io/klog/v2/RELEASE.md | 9 + vendor/k8s.io/klog/v2/SECURITY_CONTACTS | 20 + vendor/k8s.io/klog/v2/code-of-conduct.md | 3 + vendor/k8s.io/klog/v2/go.mod | 5 + vendor/k8s.io/klog/v2/go.sum | 2 + vendor/k8s.io/klog/v2/klog.go | 1496 +++++++++++++++++ vendor/k8s.io/klog/v2/klog_file.go | 158 ++ vendor/modules.txt | 13 +- 49 files changed, 6178 insertions(+), 43 deletions(-) create mode 100644 vendor/golang.org/x/tools/imports/BUILD.bazel create mode 100644 vendor/golang.org/x/tools/imports/forward.go create mode 100644 vendor/k8s.io/gengo/LICENSE create mode 100644 vendor/k8s.io/gengo/args/BUILD.bazel create mode 100644 vendor/k8s.io/gengo/args/args.go create mode 100644 vendor/k8s.io/gengo/generator/BUILD.bazel create mode 100644 vendor/k8s.io/gengo/generator/default_generator.go create mode 100644 vendor/k8s.io/gengo/generator/default_package.go create mode 100644 vendor/k8s.io/gengo/generator/doc.go create mode 100644 vendor/k8s.io/gengo/generator/error_tracker.go create mode 100644 vendor/k8s.io/gengo/generator/execute.go create mode 100644 vendor/k8s.io/gengo/generator/generator.go create mode 100644 vendor/k8s.io/gengo/generator/import_tracker.go create mode 100644 vendor/k8s.io/gengo/generator/snippet_writer.go create mode 100644 vendor/k8s.io/gengo/generator/transitive_closure.go create mode 100644 vendor/k8s.io/gengo/namer/BUILD.bazel create mode 100644 vendor/k8s.io/gengo/namer/doc.go create mode 100644 vendor/k8s.io/gengo/namer/import_tracker.go create mode 100644 vendor/k8s.io/gengo/namer/namer.go create mode 100644 vendor/k8s.io/gengo/namer/order.go create mode 100644 vendor/k8s.io/gengo/namer/plural_namer.go create mode 100644 vendor/k8s.io/gengo/parser/BUILD.bazel create mode 100644 vendor/k8s.io/gengo/parser/doc.go create mode 100644 vendor/k8s.io/gengo/parser/parse.go create mode 100644 vendor/k8s.io/gengo/types/BUILD.bazel create mode 100644 vendor/k8s.io/gengo/types/comments.go create mode 100644 vendor/k8s.io/gengo/types/doc.go create mode 100644 vendor/k8s.io/gengo/types/flatten.go create mode 100644 vendor/k8s.io/gengo/types/types.go create mode 100644 vendor/k8s.io/klog/v2/.gitignore create mode 100644 vendor/k8s.io/klog/v2/BUILD.bazel create mode 100644 vendor/k8s.io/klog/v2/CONTRIBUTING.md create mode 100644 vendor/k8s.io/klog/v2/LICENSE create mode 100644 vendor/k8s.io/klog/v2/OWNERS create mode 100644 vendor/k8s.io/klog/v2/README.md create mode 100644 vendor/k8s.io/klog/v2/RELEASE.md create mode 100644 vendor/k8s.io/klog/v2/SECURITY_CONTACTS create mode 100644 vendor/k8s.io/klog/v2/code-of-conduct.md create mode 100644 vendor/k8s.io/klog/v2/go.mod create mode 100644 vendor/k8s.io/klog/v2/go.sum create mode 100644 vendor/k8s.io/klog/v2/klog.go create mode 100644 vendor/k8s.io/klog/v2/klog_file.go diff --git a/go.mod b/go.mod index fdaa84d28be62..219bca4c11dca 100644 --- a/go.mod +++ b/go.mod @@ -117,6 +117,7 @@ require ( k8s.io/gengo v0.0.0-20200710205751-c0d492a0f3ca k8s.io/helm v2.9.0+incompatible k8s.io/klog v1.0.0 + k8s.io/klog/v2 v2.0.0 k8s.io/kubectl v0.0.0 k8s.io/legacy-cloud-providers v0.0.0 k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 diff --git a/vendor/github.com/google/go-cmp/cmp/compare.go b/vendor/github.com/google/go-cmp/cmp/compare.go index 2133562b01c3a..c9a63ceda5e6a 100644 --- a/vendor/github.com/google/go-cmp/cmp/compare.go +++ b/vendor/github.com/google/go-cmp/cmp/compare.go @@ -22,8 +22,8 @@ // equality is determined by recursively comparing the primitive kinds on both // values, much like reflect.DeepEqual. Unlike reflect.DeepEqual, unexported // fields are not compared by default; they result in panics unless suppressed -// by using an Ignore option (see cmpopts.IgnoreUnexported) or explicitly compared -// using the AllowUnexported option. +// by using an Ignore option (see cmpopts.IgnoreUnexported) or explicitly +// compared using the Exporter option. package cmp import ( @@ -62,8 +62,8 @@ import ( // // Structs are equal if recursively calling Equal on all fields report equal. // If a struct contains unexported fields, Equal panics unless an Ignore option -// (e.g., cmpopts.IgnoreUnexported) ignores that field or the AllowUnexported -// option explicitly permits comparing the unexported field. +// (e.g., cmpopts.IgnoreUnexported) ignores that field or the Exporter option +// explicitly permits comparing the unexported field. // // Slices are equal if they are both nil or both non-nil, where recursively // calling Equal on all non-ignored slice or array elements report equal. @@ -80,6 +80,11 @@ import ( // Pointers and interfaces are equal if they are both nil or both non-nil, // where they have the same underlying concrete type and recursively // calling Equal on the underlying values reports equal. +// +// Before recursing into a pointer, slice element, or map, the current path +// is checked to detect whether the address has already been visited. +// If there is a cycle, then the pointed at values are considered equal +// only if both addresses were previously visited in the same path step. func Equal(x, y interface{}, opts ...Option) bool { vx := reflect.ValueOf(x) vy := reflect.ValueOf(y) @@ -137,6 +142,7 @@ type state struct { // Calling statelessCompare must not result in observable changes to these. result diff.Result // The current result of comparison curPath Path // The current path in the value tree + curPtrs pointerPath // The current set of visited pointers reporters []reporter // Optional reporters // recChecker checks for infinite cycles applying the same set of @@ -148,13 +154,14 @@ type state struct { dynChecker dynChecker // These fields, once set by processOption, will not change. - exporters map[reflect.Type]bool // Set of structs with unexported field visibility - opts Options // List of all fundamental and filter options + exporters []exporter // List of exporters for structs with unexported fields + opts Options // List of all fundamental and filter options } func newState(opts []Option) *state { // Always ensure a validator option exists to validate the inputs. s := &state{opts: Options{validator{}}} + s.curPtrs.Init() s.processOption(Options(opts)) return s } @@ -174,13 +181,8 @@ func (s *state) processOption(opt Option) { panic(fmt.Sprintf("cannot use an unfiltered option: %v", opt)) } s.opts = append(s.opts, opt) - case visibleStructs: - if s.exporters == nil { - s.exporters = make(map[reflect.Type]bool) - } - for t := range opt { - s.exporters[t] = true - } + case exporter: + s.exporters = append(s.exporters, opt) case reporter: s.reporters = append(s.reporters, opt) default: @@ -192,9 +194,9 @@ func (s *state) processOption(opt Option) { // This function is stateless in that it does not alter the current result, // or output to any registered reporters. func (s *state) statelessCompare(step PathStep) diff.Result { - // We do not save and restore the curPath because all of the compareX - // methods should properly push and pop from the path. - // It is an implementation bug if the contents of curPath differs from + // We do not save and restore curPath and curPtrs because all of the + // compareX methods should properly push and pop from them. + // It is an implementation bug if the contents of the paths differ from // when calling this function to when returning from it. oldResult, oldReporters := s.result, s.reporters @@ -216,9 +218,17 @@ func (s *state) compareAny(step PathStep) { } s.recChecker.Check(s.curPath) - // Obtain the current type and values. + // Cycle-detection for slice elements (see NOTE in compareSlice). t := step.Type() vx, vy := step.Values() + if si, ok := step.(SliceIndex); ok && si.isSlice && vx.IsValid() && vy.IsValid() { + px, py := vx.Addr(), vy.Addr() + if eq, visited := s.curPtrs.Push(px, py); visited { + s.report(eq, reportByCycle) + return + } + defer s.curPtrs.Pop(px, py) + } // Rule 1: Check whether an option applies on this node in the value tree. if s.tryOptions(t, vx, vy) { @@ -354,6 +364,7 @@ func sanitizeValue(v reflect.Value, t reflect.Type) reflect.Value { func (s *state) compareStruct(t reflect.Type, vx, vy reflect.Value) { var vax, vay reflect.Value // Addressable versions of vx and vy + var mayForce, mayForceInit bool step := StructField{&structField{}} for i := 0; i < t.NumField(); i++ { step.typ = t.Field(i).Type @@ -375,7 +386,13 @@ func (s *state) compareStruct(t reflect.Type, vx, vy reflect.Value) { vax = makeAddressable(vx) vay = makeAddressable(vy) } - step.mayForce = s.exporters[t] + if !mayForceInit { + for _, xf := range s.exporters { + mayForce = mayForce || xf(t) + } + mayForceInit = true + } + step.mayForce = mayForce step.pvx = vax step.pvy = vay step.field = t.Field(i) @@ -391,9 +408,21 @@ func (s *state) compareSlice(t reflect.Type, vx, vy reflect.Value) { return } - // TODO: Support cyclic data structures. + // NOTE: It is incorrect to call curPtrs.Push on the slice header pointer + // since slices represents a list of pointers, rather than a single pointer. + // The pointer checking logic must be handled on a per-element basis + // in compareAny. + // + // A slice header (see reflect.SliceHeader) in Go is a tuple of a starting + // pointer P, a length N, and a capacity C. Supposing each slice element has + // a memory size of M, then the slice is equivalent to the list of pointers: + // [P+i*M for i in range(N)] + // + // For example, v[:0] and v[:1] are slices with the same starting pointer, + // but they are clearly different values. Using the slice pointer alone + // violates the assumption that equal pointers implies equal values. - step := SliceIndex{&sliceIndex{pathStep: pathStep{typ: t.Elem()}}} + step := SliceIndex{&sliceIndex{pathStep: pathStep{typ: t.Elem()}, isSlice: isSlice}} withIndexes := func(ix, iy int) SliceIndex { if ix >= 0 { step.vx, step.xkey = vx.Index(ix), ix @@ -470,7 +499,12 @@ func (s *state) compareMap(t reflect.Type, vx, vy reflect.Value) { return } - // TODO: Support cyclic data structures. + // Cycle-detection for maps. + if eq, visited := s.curPtrs.Push(vx, vy); visited { + s.report(eq, reportByCycle) + return + } + defer s.curPtrs.Pop(vx, vy) // We combine and sort the two map keys so that we can perform the // comparisons in a deterministic order. @@ -507,7 +541,12 @@ func (s *state) comparePtr(t reflect.Type, vx, vy reflect.Value) { return } - // TODO: Support cyclic data structures. + // Cycle-detection for pointers. + if eq, visited := s.curPtrs.Push(vx, vy); visited { + s.report(eq, reportByCycle) + return + } + defer s.curPtrs.Pop(vx, vy) vx, vy = vx.Elem(), vy.Elem() s.compareAny(Indirect{&indirect{pathStep{t.Elem(), vx, vy}}}) diff --git a/vendor/github.com/google/go-cmp/cmp/export_panic.go b/vendor/github.com/google/go-cmp/cmp/export_panic.go index abc3a1c3e7655..dd032354fef1f 100644 --- a/vendor/github.com/google/go-cmp/cmp/export_panic.go +++ b/vendor/github.com/google/go-cmp/cmp/export_panic.go @@ -8,8 +8,8 @@ package cmp import "reflect" -const supportAllowUnexported = false +const supportExporters = false func retrieveUnexportedField(reflect.Value, reflect.StructField) reflect.Value { - panic("retrieveUnexportedField is not implemented") + panic("no support for forcibly accessing unexported fields") } diff --git a/vendor/github.com/google/go-cmp/cmp/export_unsafe.go b/vendor/github.com/google/go-cmp/cmp/export_unsafe.go index 59d4ee91b47f4..57020e26ca76a 100644 --- a/vendor/github.com/google/go-cmp/cmp/export_unsafe.go +++ b/vendor/github.com/google/go-cmp/cmp/export_unsafe.go @@ -11,7 +11,7 @@ import ( "unsafe" ) -const supportAllowUnexported = true +const supportExporters = true // retrieveUnexportedField uses unsafe to forcibly retrieve any field from // a struct such that the value has read-write permissions. @@ -19,5 +19,7 @@ const supportAllowUnexported = true // The parent struct, v, must be addressable, while f must be a StructField // describing the field to retrieve. func retrieveUnexportedField(v reflect.Value, f reflect.StructField) reflect.Value { - return reflect.NewAt(f.Type, unsafe.Pointer(v.UnsafeAddr()+f.Offset)).Elem() + // See https://github.com/google/go-cmp/issues/167 for discussion of the + // following expression. + return reflect.NewAt(f.Type, unsafe.Pointer(uintptr(unsafe.Pointer(v.UnsafeAddr()))+f.Offset)).Elem() } diff --git a/vendor/github.com/google/go-cmp/cmp/options.go b/vendor/github.com/google/go-cmp/cmp/options.go index 793448160ee71..abbd2a63b69a9 100644 --- a/vendor/github.com/google/go-cmp/cmp/options.go +++ b/vendor/github.com/google/go-cmp/cmp/options.go @@ -225,8 +225,20 @@ func (validator) apply(s *state, vx, vy reflect.Value) { // Unable to Interface implies unexported field without visibility access. if !vx.CanInterface() || !vy.CanInterface() { - const help = "consider using a custom Comparer; if you control the implementation of type, you can also consider AllowUnexported or cmpopts.IgnoreUnexported" - panic(fmt.Sprintf("cannot handle unexported field: %#v\n%s", s.curPath, help)) + const help = "consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported" + var name string + if t := s.curPath.Index(-2).Type(); t.Name() != "" { + // Named type with unexported fields. + name = fmt.Sprintf("%q.%v", t.PkgPath(), t.Name()) // e.g., "path/to/package".MyType + } else { + // Unnamed type with unexported fields. Derive PkgPath from field. + var pkgPath string + for i := 0; i < t.NumField() && pkgPath == ""; i++ { + pkgPath = t.Field(i).PkgPath + } + name = fmt.Sprintf("%q.(%v)", pkgPath, t.String()) // e.g., "path/to/package".(struct { a int }) + } + panic(fmt.Sprintf("cannot handle unexported field at %#v:\n\t%v\n%s", s.curPath, name, help)) } panic("not reachable") @@ -360,9 +372,8 @@ func (cm comparer) String() string { return fmt.Sprintf("Comparer(%s)", function.NameOf(cm.fnc)) } -// AllowUnexported returns an Option that forcibly allows operations on -// unexported fields in certain structs, which are specified by passing in a -// value of each struct type. +// Exporter returns an Option that specifies whether Equal is allowed to +// introspect into the unexported fields of certain struct types. // // Users of this option must understand that comparing on unexported fields // from external packages is not safe since changes in the internal @@ -386,10 +397,24 @@ func (cm comparer) String() string { // // In other cases, the cmpopts.IgnoreUnexported option can be used to ignore // all unexported fields on specified struct types. -func AllowUnexported(types ...interface{}) Option { - if !supportAllowUnexported { - panic("AllowUnexported is not supported on purego builds, Google App Engine Standard, or GopherJS") +func Exporter(f func(reflect.Type) bool) Option { + if !supportExporters { + panic("Exporter is not supported on purego builds") } + return exporter(f) +} + +type exporter func(reflect.Type) bool + +func (exporter) filter(_ *state, _ reflect.Type, _, _ reflect.Value) applicableOption { + panic("not implemented") +} + +// AllowUnexported returns an Options that allows Equal to forcibly introspect +// unexported fields of the specified struct types. +// +// See Exporter for the proper use of this option. +func AllowUnexported(types ...interface{}) Option { m := make(map[reflect.Type]bool) for _, typ := range types { t := reflect.TypeOf(typ) @@ -398,13 +423,7 @@ func AllowUnexported(types ...interface{}) Option { } m[t] = true } - return visibleStructs(m) -} - -type visibleStructs map[reflect.Type]bool - -func (visibleStructs) filter(_ *state, _ reflect.Type, _, _ reflect.Value) applicableOption { - panic("not implemented") + return exporter(func(t reflect.Type) bool { return m[t] }) } // Result represents the comparison result for a single node and @@ -436,6 +455,11 @@ func (r Result) ByFunc() bool { return r.flags&reportByFunc != 0 } +// ByCycle reports whether a reference cycle was detected. +func (r Result) ByCycle() bool { + return r.flags&reportByCycle != 0 +} + type resultFlags uint const ( @@ -446,6 +470,7 @@ const ( reportByIgnore reportByMethod reportByFunc + reportByCycle ) // Reporter is an Option that can be passed to Equal. When Equal traverses diff --git a/vendor/github.com/google/go-cmp/cmp/path.go b/vendor/github.com/google/go-cmp/cmp/path.go index 96fffd291f735..509d6b8527dba 100644 --- a/vendor/github.com/google/go-cmp/cmp/path.go +++ b/vendor/github.com/google/go-cmp/cmp/path.go @@ -10,6 +10,8 @@ import ( "strings" "unicode" "unicode/utf8" + + "github.com/google/go-cmp/cmp/internal/value" ) // Path is a list of PathSteps describing the sequence of operations to get @@ -41,7 +43,7 @@ type PathStep interface { // In some cases, one or both may be invalid or have restrictions: // • For StructField, both are not interface-able if the current field // is unexported and the struct type is not explicitly permitted by - // AllowUnexported to traverse unexported fields. + // an Exporter to traverse unexported fields. // • For SliceIndex, one may be invalid if an element is missing from // either the x or y slice. // • For MapIndex, one may be invalid if an entry is missing from @@ -207,6 +209,7 @@ type SliceIndex struct{ *sliceIndex } type sliceIndex struct { pathStep xkey, ykey int + isSlice bool // False for reflect.Array } func (si SliceIndex) Type() reflect.Type { return si.typ } @@ -301,6 +304,72 @@ func (tf Transform) Func() reflect.Value { return tf.trans.fnc } // The == operator can be used to detect the exact option used. func (tf Transform) Option() Option { return tf.trans } +// pointerPath represents a dual-stack of pointers encountered when +// recursively traversing the x and y values. This data structure supports +// detection of cycles and determining whether the cycles are equal. +// In Go, cycles can occur via pointers, slices, and maps. +// +// The pointerPath uses a map to represent a stack; where descension into a +// pointer pushes the address onto the stack, and ascension from a pointer +// pops the address from the stack. Thus, when traversing into a pointer from +// reflect.Ptr, reflect.Slice element, or reflect.Map, we can detect cycles +// by checking whether the pointer has already been visited. The cycle detection +// uses a seperate stack for the x and y values. +// +// If a cycle is detected we need to determine whether the two pointers +// should be considered equal. The definition of equality chosen by Equal +// requires two graphs to have the same structure. To determine this, both the +// x and y values must have a cycle where the previous pointers were also +// encountered together as a pair. +// +// Semantically, this is equivalent to augmenting Indirect, SliceIndex, and +// MapIndex with pointer information for the x and y values. +// Suppose px and py are two pointers to compare, we then search the +// Path for whether px was ever encountered in the Path history of x, and +// similarly so with py. If either side has a cycle, the comparison is only +// equal if both px and py have a cycle resulting from the same PathStep. +// +// Using a map as a stack is more performant as we can perform cycle detection +// in O(1) instead of O(N) where N is len(Path). +type pointerPath struct { + // mx is keyed by x pointers, where the value is the associated y pointer. + mx map[value.Pointer]value.Pointer + // my is keyed by y pointers, where the value is the associated x pointer. + my map[value.Pointer]value.Pointer +} + +func (p *pointerPath) Init() { + p.mx = make(map[value.Pointer]value.Pointer) + p.my = make(map[value.Pointer]value.Pointer) +} + +// Push indicates intent to descend into pointers vx and vy where +// visited reports whether either has been seen before. If visited before, +// equal reports whether both pointers were encountered together. +// Pop must be called if and only if the pointers were never visited. +// +// The pointers vx and vy must be a reflect.Ptr, reflect.Slice, or reflect.Map +// and be non-nil. +func (p pointerPath) Push(vx, vy reflect.Value) (equal, visited bool) { + px := value.PointerOf(vx) + py := value.PointerOf(vy) + _, ok1 := p.mx[px] + _, ok2 := p.my[py] + if ok1 || ok2 { + equal = p.mx[px] == py && p.my[py] == px // Pointers paired together + return equal, true + } + p.mx[px] = py + p.my[py] = px + return false, false +} + +// Pop ascends from pointers vx and vy. +func (p pointerPath) Pop(vx, vy reflect.Value) { + delete(p.mx, value.PointerOf(vx)) + delete(p.my, value.PointerOf(vy)) +} + // isExported reports whether the identifier is exported. func isExported(id string) bool { r, _ := utf8.DecodeRuneInString(id) diff --git a/vendor/golang.org/x/tools/imports/BUILD.bazel b/vendor/golang.org/x/tools/imports/BUILD.bazel new file mode 100644 index 0000000000000..350cef368734f --- /dev/null +++ b/vendor/golang.org/x/tools/imports/BUILD.bazel @@ -0,0 +1,10 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["forward.go"], + importmap = "k8s.io/kops/vendor/golang.org/x/tools/imports", + importpath = "golang.org/x/tools/imports", + visibility = ["//visibility:public"], + deps = ["//vendor/golang.org/x/tools/internal/imports:go_default_library"], +) diff --git a/vendor/golang.org/x/tools/imports/forward.go b/vendor/golang.org/x/tools/imports/forward.go new file mode 100644 index 0000000000000..83f4e44731bfa --- /dev/null +++ b/vendor/golang.org/x/tools/imports/forward.go @@ -0,0 +1,62 @@ +// Package imports implements a Go pretty-printer (like package "go/format") +// that also adds or removes import statements as necessary. +package imports // import "golang.org/x/tools/imports" + +import ( + "log" + + intimp "golang.org/x/tools/internal/imports" +) + +// Options specifies options for processing files. +type Options struct { + Fragment bool // Accept fragment of a source file (no package statement) + AllErrors bool // Report all errors (not just the first 10 on different lines) + + Comments bool // Print comments (true if nil *Options provided) + TabIndent bool // Use tabs for indent (true if nil *Options provided) + TabWidth int // Tab width (8 if nil *Options provided) + + FormatOnly bool // Disable the insertion and deletion of imports +} + +// Debug controls verbose logging. +var Debug = false + +// LocalPrefix is a comma-separated string of import path prefixes, which, if +// set, instructs Process to sort the import paths with the given prefixes +// into another group after 3rd-party packages. +var LocalPrefix string + +// Process formats and adjusts imports for the provided file. +// If opt is nil the defaults are used. +// +// Note that filename's directory influences which imports can be chosen, +// so it is important that filename be accurate. +// To process data ``as if'' it were in filename, pass the data as a non-nil src. +func Process(filename string, src []byte, opt *Options) ([]byte, error) { + if opt == nil { + opt = &Options{Comments: true, TabIndent: true, TabWidth: 8} + } + intopt := &intimp.Options{ + Env: &intimp.ProcessEnv{ + LocalPrefix: LocalPrefix, + }, + AllErrors: opt.AllErrors, + Comments: opt.Comments, + FormatOnly: opt.FormatOnly, + Fragment: opt.Fragment, + TabIndent: opt.TabIndent, + TabWidth: opt.TabWidth, + } + if Debug { + intopt.Env.Logf = log.Printf + } + return intimp.Process(filename, src, intopt) +} + +// VendorlessPath returns the devendorized version of the import path ipath. +// For example, VendorlessPath("foo/bar/vendor/a/b") returns "a/b". +func VendorlessPath(ipath string) string { + return intimp.VendorlessPath(ipath) +} diff --git a/vendor/k8s.io/gengo/LICENSE b/vendor/k8s.io/gengo/LICENSE new file mode 100644 index 0000000000000..00b2401109fde --- /dev/null +++ b/vendor/k8s.io/gengo/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014 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. + 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. diff --git a/vendor/k8s.io/gengo/args/BUILD.bazel b/vendor/k8s.io/gengo/args/BUILD.bazel new file mode 100644 index 0000000000000..9d45d6adc5d82 --- /dev/null +++ b/vendor/k8s.io/gengo/args/BUILD.bazel @@ -0,0 +1,16 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["args.go"], + importmap = "k8s.io/kops/vendor/k8s.io/gengo/args", + importpath = "k8s.io/gengo/args", + visibility = ["//visibility:public"], + deps = [ + "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/gengo/generator:go_default_library", + "//vendor/k8s.io/gengo/namer:go_default_library", + "//vendor/k8s.io/gengo/parser:go_default_library", + "//vendor/k8s.io/gengo/types:go_default_library", + ], +) diff --git a/vendor/k8s.io/gengo/args/args.go b/vendor/k8s.io/gengo/args/args.go new file mode 100644 index 0000000000000..49cc76dac9f5b --- /dev/null +++ b/vendor/k8s.io/gengo/args/args.go @@ -0,0 +1,212 @@ +/* +Copyright 2015 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. +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 args has common command-line flags for generation programs. +package args + +import ( + "bytes" + goflag "flag" + "fmt" + "io/ioutil" + "os" + "path" + "path/filepath" + "strconv" + "strings" + "time" + + "k8s.io/gengo/generator" + "k8s.io/gengo/namer" + "k8s.io/gengo/parser" + "k8s.io/gengo/types" + + "github.com/spf13/pflag" +) + +// Default returns a defaulted GeneratorArgs. You may change the defaults +// before calling AddFlags. +func Default() *GeneratorArgs { + return &GeneratorArgs{ + OutputBase: DefaultSourceTree(), + GoHeaderFilePath: filepath.Join(DefaultSourceTree(), "k8s.io/gengo/boilerplate/boilerplate.go.txt"), + GeneratedBuildTag: "ignore_autogenerated", + GeneratedByCommentTemplate: "// Code generated by GENERATOR_NAME. DO NOT EDIT.", + defaultCommandLineFlags: true, + } +} + +// GeneratorArgs has arguments that are passed to generators. +type GeneratorArgs struct { + // Which directories to parse. + InputDirs []string + + // Source tree to write results to. + OutputBase string + + // Package path within the source tree. + OutputPackagePath string + + // Output file name. + OutputFileBaseName string + + // Where to get copyright header text. + GoHeaderFilePath string + + // If GeneratedByCommentTemplate is set, generate a "Code generated by" comment + // below the bloilerplate, of the format defined by this string. + // Any instances of "GENERATOR_NAME" will be replaced with the name of the code generator. + GeneratedByCommentTemplate string + + // If true, only verify, don't write anything. + VerifyOnly bool + + // If true, include *_test.go files + IncludeTestFiles bool + + // GeneratedBuildTag is the tag used to identify code generated by execution + // of this type. Each generator should use a different tag, and different + // groups of generators (external API that depends on Kube generations) should + // keep tags distinct as well. + GeneratedBuildTag string + + // Any custom arguments go here + CustomArgs interface{} + + // Whether to use default command line flags + defaultCommandLineFlags bool +} + +// WithoutDefaultFlagParsing disables implicit addition of command line flags and parsing. +func (g *GeneratorArgs) WithoutDefaultFlagParsing() *GeneratorArgs { + g.defaultCommandLineFlags = false + return g +} + +func (g *GeneratorArgs) AddFlags(fs *pflag.FlagSet) { + fs.StringSliceVarP(&g.InputDirs, "input-dirs", "i", g.InputDirs, "Comma-separated list of import paths to get input types from.") + fs.StringVarP(&g.OutputBase, "output-base", "o", g.OutputBase, "Output base; defaults to $GOPATH/src/ or ./ if $GOPATH is not set.") + fs.StringVarP(&g.OutputPackagePath, "output-package", "p", g.OutputPackagePath, "Base package path.") + fs.StringVarP(&g.OutputFileBaseName, "output-file-base", "O", g.OutputFileBaseName, "Base name (without .go suffix) for output files.") + fs.StringVarP(&g.GoHeaderFilePath, "go-header-file", "h", g.GoHeaderFilePath, "File containing boilerplate header text. The string YEAR will be replaced with the current 4-digit year.") + fs.BoolVar(&g.VerifyOnly, "verify-only", g.VerifyOnly, "If true, only verify existing output, do not write anything.") + fs.StringVar(&g.GeneratedBuildTag, "build-tag", g.GeneratedBuildTag, "A Go build tag to use to identify files generated by this command. Should be unique.") +} + +// LoadGoBoilerplate loads the boilerplate file passed to --go-header-file. +func (g *GeneratorArgs) LoadGoBoilerplate() ([]byte, error) { + b, err := ioutil.ReadFile(g.GoHeaderFilePath) + if err != nil { + return nil, err + } + b = bytes.Replace(b, []byte("YEAR"), []byte(strconv.Itoa(time.Now().UTC().Year())), -1) + + if g.GeneratedByCommentTemplate != "" { + if len(b) != 0 { + b = append(b, byte('\n')) + } + generatorName := path.Base(os.Args[0]) + generatedByComment := strings.Replace(g.GeneratedByCommentTemplate, "GENERATOR_NAME", generatorName, -1) + s := fmt.Sprintf("%s\n\n", generatedByComment) + b = append(b, []byte(s)...) + } + return b, nil +} + +// NewBuilder makes a new parser.Builder and populates it with the input +// directories. +func (g *GeneratorArgs) NewBuilder() (*parser.Builder, error) { + b := parser.New() + + // flag for including *_test.go + b.IncludeTestFiles = g.IncludeTestFiles + + // Ignore all auto-generated files. + b.AddBuildTags(g.GeneratedBuildTag) + + for _, d := range g.InputDirs { + var err error + if strings.HasSuffix(d, "/...") { + err = b.AddDirRecursive(strings.TrimSuffix(d, "/...")) + } else { + err = b.AddDir(d) + } + if err != nil { + return nil, fmt.Errorf("unable to add directory %q: %v", d, err) + } + } + return b, nil +} + +// InputIncludes returns true if the given package is a (sub) package of one of +// the InputDirs. +func (g *GeneratorArgs) InputIncludes(p *types.Package) bool { + for _, dir := range g.InputDirs { + d := dir + if strings.HasSuffix(d, "...") { + d = strings.TrimSuffix(d, "...") + } + if strings.HasPrefix(d, "./vendor/") { + d = strings.TrimPrefix(d, "./vendor/") + } + if strings.HasPrefix(p.Path, d) { + return true + } + } + return false +} + +// DefaultSourceTree returns the /src directory of the first entry in $GOPATH. +// If $GOPATH is empty, it returns "./". Useful as a default output location. +func DefaultSourceTree() string { + paths := strings.Split(os.Getenv("GOPATH"), string(filepath.ListSeparator)) + if len(paths) > 0 && len(paths[0]) > 0 { + return filepath.Join(paths[0], "src") + } + return "./" +} + +// Execute implements main(). +// If you don't need any non-default behavior, use as: +// args.Default().Execute(...) +func (g *GeneratorArgs) Execute(nameSystems namer.NameSystems, defaultSystem string, pkgs func(*generator.Context, *GeneratorArgs) generator.Packages) error { + if g.defaultCommandLineFlags { + g.AddFlags(pflag.CommandLine) + pflag.CommandLine.AddGoFlagSet(goflag.CommandLine) + pflag.Parse() + } + + b, err := g.NewBuilder() + if err != nil { + return fmt.Errorf("Failed making a parser: %v", err) + } + + // pass through the flag on whether to include *_test.go files + b.IncludeTestFiles = g.IncludeTestFiles + + c, err := generator.NewContext(b, nameSystems, defaultSystem) + if err != nil { + return fmt.Errorf("Failed making a context: %v", err) + } + + c.Verify = g.VerifyOnly + packages := pkgs(c, g) + if err := c.ExecutePackages(g.OutputBase, packages); err != nil { + return fmt.Errorf("Failed executing generator: %v", err) + } + + return nil +} diff --git a/vendor/k8s.io/gengo/generator/BUILD.bazel b/vendor/k8s.io/gengo/generator/BUILD.bazel new file mode 100644 index 0000000000000..39805eabbf722 --- /dev/null +++ b/vendor/k8s.io/gengo/generator/BUILD.bazel @@ -0,0 +1,26 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "default_generator.go", + "default_package.go", + "doc.go", + "error_tracker.go", + "execute.go", + "generator.go", + "import_tracker.go", + "snippet_writer.go", + "transitive_closure.go", + ], + importmap = "k8s.io/kops/vendor/k8s.io/gengo/generator", + importpath = "k8s.io/gengo/generator", + visibility = ["//visibility:public"], + deps = [ + "//vendor/golang.org/x/tools/imports:go_default_library", + "//vendor/k8s.io/gengo/namer:go_default_library", + "//vendor/k8s.io/gengo/parser:go_default_library", + "//vendor/k8s.io/gengo/types:go_default_library", + "//vendor/k8s.io/klog/v2:go_default_library", + ], +) diff --git a/vendor/k8s.io/gengo/generator/default_generator.go b/vendor/k8s.io/gengo/generator/default_generator.go new file mode 100644 index 0000000000000..f9476682148d2 --- /dev/null +++ b/vendor/k8s.io/gengo/generator/default_generator.go @@ -0,0 +1,62 @@ +/* +Copyright 2015 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. +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 generator + +import ( + "io" + + "k8s.io/gengo/namer" + "k8s.io/gengo/types" +) + +const ( + GolangFileType = "golang" +) + +// DefaultGen implements a do-nothing Generator. +// +// It can be used to implement static content files. +type DefaultGen struct { + // OptionalName, if present, will be used for the generator's name, and + // the filename (with ".go" appended). + OptionalName string + + // OptionalBody, if present, will be used as the return from the "Init" + // method. This causes it to be static content for the entire file if + // no other generator touches the file. + OptionalBody []byte +} + +func (d DefaultGen) Name() string { return d.OptionalName } +func (d DefaultGen) Filter(*Context, *types.Type) bool { return true } +func (d DefaultGen) Namers(*Context) namer.NameSystems { return nil } +func (d DefaultGen) Imports(*Context) []string { return []string{} } +func (d DefaultGen) PackageVars(*Context) []string { return []string{} } +func (d DefaultGen) PackageConsts(*Context) []string { return []string{} } +func (d DefaultGen) GenerateType(*Context, *types.Type, io.Writer) error { return nil } +func (d DefaultGen) Filename() string { return d.OptionalName + ".go" } +func (d DefaultGen) FileType() string { return GolangFileType } +func (d DefaultGen) Finalize(*Context, io.Writer) error { return nil } + +func (d DefaultGen) Init(c *Context, w io.Writer) error { + _, err := w.Write(d.OptionalBody) + return err +} + +var ( + _ = Generator(DefaultGen{}) +) diff --git a/vendor/k8s.io/gengo/generator/default_package.go b/vendor/k8s.io/gengo/generator/default_package.go new file mode 100644 index 0000000000000..dcf0883235dd2 --- /dev/null +++ b/vendor/k8s.io/gengo/generator/default_package.go @@ -0,0 +1,75 @@ +/* +Copyright 2015 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. +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 generator + +import ( + "k8s.io/gengo/types" +) + +// DefaultPackage contains a default implementation of Package. +type DefaultPackage struct { + // Short name of package, used in the "package xxxx" line. + PackageName string + // Import path of the package, and the location on disk of the package. + PackagePath string + // The location of the package on disk. + Source string + + // Emitted at the top of every file. + HeaderText []byte + + // Emitted only for a "doc.go" file; appended to the HeaderText for + // that file. + PackageDocumentation []byte + + // If non-nil, will be called on "Generators"; otherwise, the static + // list will be used. So you should set only one of these two fields. + GeneratorFunc func(*Context) []Generator + GeneratorList []Generator + + // Optional; filters the types exposed to the generators. + FilterFunc func(*Context, *types.Type) bool +} + +func (d *DefaultPackage) Name() string { return d.PackageName } +func (d *DefaultPackage) Path() string { return d.PackagePath } +func (d *DefaultPackage) SourcePath() string { return d.Source } + +func (d *DefaultPackage) Filter(c *Context, t *types.Type) bool { + if d.FilterFunc != nil { + return d.FilterFunc(c, t) + } + return true +} + +func (d *DefaultPackage) Generators(c *Context) []Generator { + if d.GeneratorFunc != nil { + return d.GeneratorFunc(c) + } + return d.GeneratorList +} + +func (d *DefaultPackage) Header(filename string) []byte { + if filename == "doc.go" { + return append(d.HeaderText, d.PackageDocumentation...) + } + return d.HeaderText +} + +var ( + _ = Package(&DefaultPackage{}) +) diff --git a/vendor/k8s.io/gengo/generator/doc.go b/vendor/k8s.io/gengo/generator/doc.go new file mode 100644 index 0000000000000..d8e12534a44ee --- /dev/null +++ b/vendor/k8s.io/gengo/generator/doc.go @@ -0,0 +1,31 @@ +/* +Copyright 2015 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. +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 generator defines an interface for code generators to implement. +// +// To use this package, you'll implement the "Package" and "Generator" +// interfaces; you'll call NewContext to load up the types you want to work +// with, and then you'll call one or more of the Execute methods. See the +// interface definitions for explanations. All output will have gofmt called on +// it automatically, so you do not need to worry about generating correct +// indentation. +// +// This package also exposes SnippetWriter. SnippetWriter reduces to a minimum +// the boilerplate involved in setting up a template from go's text/template +// package. Additionally, all naming systems in the Context will be added as +// functions to the parsed template, so that they can be called directly from +// your templates! +package generator // import "k8s.io/gengo/generator" diff --git a/vendor/k8s.io/gengo/generator/error_tracker.go b/vendor/k8s.io/gengo/generator/error_tracker.go new file mode 100644 index 0000000000000..964dae37ba55a --- /dev/null +++ b/vendor/k8s.io/gengo/generator/error_tracker.go @@ -0,0 +1,50 @@ +/* +Copyright 2015 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. +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 generator + +import ( + "io" +) + +// ErrorTracker tracks errors to the underlying writer, so that you can ignore +// them until you're ready to return. +type ErrorTracker struct { + io.Writer + err error +} + +// NewErrorTracker makes a new error tracker; note that it implements io.Writer. +func NewErrorTracker(w io.Writer) *ErrorTracker { + return &ErrorTracker{Writer: w} +} + +// Write intercepts calls to Write. +func (et *ErrorTracker) Write(p []byte) (n int, err error) { + if et.err != nil { + return 0, et.err + } + n, err = et.Writer.Write(p) + if err != nil { + et.err = err + } + return n, err +} + +// Error returns nil if no error has occurred, otherwise it returns the error. +func (et *ErrorTracker) Error() error { + return et.err +} diff --git a/vendor/k8s.io/gengo/generator/execute.go b/vendor/k8s.io/gengo/generator/execute.go new file mode 100644 index 0000000000000..e489fd3f0d5b2 --- /dev/null +++ b/vendor/k8s.io/gengo/generator/execute.go @@ -0,0 +1,314 @@ +/* +Copyright 2015 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. +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 generator + +import ( + "bytes" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + + "golang.org/x/tools/imports" + "k8s.io/gengo/namer" + "k8s.io/gengo/types" + + "k8s.io/klog/v2" +) + +func errs2strings(errors []error) []string { + strs := make([]string, len(errors)) + for i := range errors { + strs[i] = errors[i].Error() + } + return strs +} + +// ExecutePackages runs the generators for every package in 'packages'. 'outDir' +// is the base directory in which to place all the generated packages; it +// should be a physical path on disk, not an import path. e.g.: +// /path/to/home/path/to/gopath/src/ +// Each package has its import path already, this will be appended to 'outDir'. +func (c *Context) ExecutePackages(outDir string, packages Packages) error { + var errors []error + for _, p := range packages { + if err := c.ExecutePackage(outDir, p); err != nil { + errors = append(errors, err) + } + } + if len(errors) > 0 { + return fmt.Errorf("some packages had errors:\n%v\n", strings.Join(errs2strings(errors), "\n")) + } + return nil +} + +type DefaultFileType struct { + Format func([]byte) ([]byte, error) + Assemble func(io.Writer, *File) +} + +func (ft DefaultFileType) AssembleFile(f *File, pathname string) error { + klog.V(2).Infof("Assembling file %q", pathname) + destFile, err := os.Create(pathname) + if err != nil { + return err + } + defer destFile.Close() + + b := &bytes.Buffer{} + et := NewErrorTracker(b) + ft.Assemble(et, f) + if et.Error() != nil { + return et.Error() + } + if formatted, err := ft.Format(b.Bytes()); err != nil { + err = fmt.Errorf("unable to format file %q (%v).", pathname, err) + // Write the file anyway, so they can see what's going wrong and fix the generator. + if _, err2 := destFile.Write(b.Bytes()); err2 != nil { + return err2 + } + return err + } else { + _, err = destFile.Write(formatted) + return err + } +} + +func (ft DefaultFileType) VerifyFile(f *File, pathname string) error { + klog.V(2).Infof("Verifying file %q", pathname) + friendlyName := filepath.Join(f.PackageName, f.Name) + b := &bytes.Buffer{} + et := NewErrorTracker(b) + ft.Assemble(et, f) + if et.Error() != nil { + return et.Error() + } + formatted, err := ft.Format(b.Bytes()) + if err != nil { + return fmt.Errorf("unable to format the output for %q: %v", friendlyName, err) + } + existing, err := ioutil.ReadFile(pathname) + if err != nil { + return fmt.Errorf("unable to read file %q for comparison: %v", friendlyName, err) + } + if bytes.Compare(formatted, existing) == 0 { + return nil + } + // Be nice and find the first place where they differ + i := 0 + for i < len(formatted) && i < len(existing) && formatted[i] == existing[i] { + i++ + } + eDiff, fDiff := existing[i:], formatted[i:] + if len(eDiff) > 100 { + eDiff = eDiff[:100] + } + if len(fDiff) > 100 { + fDiff = fDiff[:100] + } + return fmt.Errorf("output for %q differs; first existing/expected diff: \n %q\n %q", friendlyName, string(eDiff), string(fDiff)) +} + +func assembleGolangFile(w io.Writer, f *File) { + w.Write(f.Header) + fmt.Fprintf(w, "package %v\n\n", f.PackageName) + + if len(f.Imports) > 0 { + fmt.Fprint(w, "import (\n") + for i := range f.Imports { + if strings.Contains(i, "\"") { + // they included quotes, or are using the + // `name "path/to/pkg"` format. + fmt.Fprintf(w, "\t%s\n", i) + } else { + fmt.Fprintf(w, "\t%q\n", i) + } + } + fmt.Fprint(w, ")\n\n") + } + + if f.Vars.Len() > 0 { + fmt.Fprint(w, "var (\n") + w.Write(f.Vars.Bytes()) + fmt.Fprint(w, ")\n\n") + } + + if f.Consts.Len() > 0 { + fmt.Fprint(w, "const (\n") + w.Write(f.Consts.Bytes()) + fmt.Fprint(w, ")\n\n") + } + + w.Write(f.Body.Bytes()) +} + +func importsWrapper(src []byte) ([]byte, error) { + return imports.Process("", src, nil) +} + +func NewGolangFile() *DefaultFileType { + return &DefaultFileType{ + Format: importsWrapper, + Assemble: assembleGolangFile, + } +} + +// format should be one line only, and not end with \n. +func addIndentHeaderComment(b *bytes.Buffer, format string, args ...interface{}) { + if b.Len() > 0 { + fmt.Fprintf(b, "\n// "+format+"\n", args...) + } else { + fmt.Fprintf(b, "// "+format+"\n", args...) + } +} + +func (c *Context) filteredBy(f func(*Context, *types.Type) bool) *Context { + c2 := *c + c2.Order = []*types.Type{} + for _, t := range c.Order { + if f(c, t) { + c2.Order = append(c2.Order, t) + } + } + return &c2 +} + +// make a new context; inheret c.Namers, but add on 'namers'. In case of a name +// collision, the namer in 'namers' wins. +func (c *Context) addNameSystems(namers namer.NameSystems) *Context { + if namers == nil { + return c + } + c2 := *c + // Copy the existing name systems so we don't corrupt a parent context + c2.Namers = namer.NameSystems{} + for k, v := range c.Namers { + c2.Namers[k] = v + } + + for name, namer := range namers { + c2.Namers[name] = namer + } + return &c2 +} + +// ExecutePackage executes a single package. 'outDir' is the base directory in +// which to place the package; it should be a physical path on disk, not an +// import path. e.g.: '/path/to/home/path/to/gopath/src/' The package knows its +// import path already, this will be appended to 'outDir'. +func (c *Context) ExecutePackage(outDir string, p Package) error { + path := filepath.Join(outDir, p.Path()) + klog.V(2).Infof("Processing package %q, disk location %q", p.Name(), path) + // Filter out any types the *package* doesn't care about. + packageContext := c.filteredBy(p.Filter) + os.MkdirAll(path, 0755) + files := map[string]*File{} + for _, g := range p.Generators(packageContext) { + // Filter out types the *generator* doesn't care about. + genContext := packageContext.filteredBy(g.Filter) + // Now add any extra name systems defined by this generator + genContext = genContext.addNameSystems(g.Namers(genContext)) + + fileType := g.FileType() + if len(fileType) == 0 { + return fmt.Errorf("generator %q must specify a file type", g.Name()) + } + f := files[g.Filename()] + if f == nil { + // This is the first generator to reference this file, so start it. + f = &File{ + Name: g.Filename(), + FileType: fileType, + PackageName: p.Name(), + PackagePath: p.Path(), + PackageSourcePath: p.SourcePath(), + Header: p.Header(g.Filename()), + Imports: map[string]struct{}{}, + } + files[f.Name] = f + } else { + if f.FileType != g.FileType() { + return fmt.Errorf("file %q already has type %q, but generator %q wants to use type %q", f.Name, f.FileType, g.Name(), g.FileType()) + } + } + + if vars := g.PackageVars(genContext); len(vars) > 0 { + addIndentHeaderComment(&f.Vars, "Package-wide variables from generator %q.", g.Name()) + for _, v := range vars { + if _, err := fmt.Fprintf(&f.Vars, "%s\n", v); err != nil { + return err + } + } + } + if consts := g.PackageConsts(genContext); len(consts) > 0 { + addIndentHeaderComment(&f.Consts, "Package-wide consts from generator %q.", g.Name()) + for _, v := range consts { + if _, err := fmt.Fprintf(&f.Consts, "%s\n", v); err != nil { + return err + } + } + } + if err := genContext.executeBody(&f.Body, g); err != nil { + return err + } + if imports := g.Imports(genContext); len(imports) > 0 { + for _, i := range imports { + f.Imports[i] = struct{}{} + } + } + } + + var errors []error + for _, f := range files { + finalPath := filepath.Join(path, f.Name) + assembler, ok := c.FileTypes[f.FileType] + if !ok { + return fmt.Errorf("the file type %q registered for file %q does not exist in the context", f.FileType, f.Name) + } + var err error + if c.Verify { + err = assembler.VerifyFile(f, finalPath) + } else { + err = assembler.AssembleFile(f, finalPath) + } + if err != nil { + errors = append(errors, err) + } + } + if len(errors) > 0 { + return fmt.Errorf("errors in package %q:\n%v\n", p.Path(), strings.Join(errs2strings(errors), "\n")) + } + return nil +} + +func (c *Context) executeBody(w io.Writer, generator Generator) error { + et := NewErrorTracker(w) + if err := generator.Init(c, et); err != nil { + return err + } + for _, t := range c.Order { + if err := generator.GenerateType(c, t, et); err != nil { + return err + } + } + if err := generator.Finalize(c, et); err != nil { + return err + } + return et.Error() +} diff --git a/vendor/k8s.io/gengo/generator/generator.go b/vendor/k8s.io/gengo/generator/generator.go new file mode 100644 index 0000000000000..4b48f503cf091 --- /dev/null +++ b/vendor/k8s.io/gengo/generator/generator.go @@ -0,0 +1,256 @@ +/* +Copyright 2015 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. +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 generator + +import ( + "bytes" + "io" + + "k8s.io/gengo/namer" + "k8s.io/gengo/parser" + "k8s.io/gengo/types" +) + +// Package contains the contract for generating a package. +type Package interface { + // Name returns the package short name. + Name() string + // Path returns the package import path. + Path() string + // SourcePath returns the location of the package on disk. + SourcePath() string + + // Filter should return true if this package cares about this type. + // Otherwise, this type will be omitted from the type ordering for + // this package. + Filter(*Context, *types.Type) bool + + // Header should return a header for the file, including comment markers. + // Useful for copyright notices and doc strings. Include an + // autogeneration notice! Do not include the "package x" line. + Header(filename string) []byte + + // Generators returns the list of generators for this package. It is + // allowed for more than one generator to write to the same file. + // A Context is passed in case the list of generators depends on the + // input types. + Generators(*Context) []Generator +} + +type File struct { + Name string + FileType string + PackageName string + Header []byte + PackagePath string + PackageSourcePath string + Imports map[string]struct{} + Vars bytes.Buffer + Consts bytes.Buffer + Body bytes.Buffer +} + +type FileType interface { + AssembleFile(f *File, path string) error + VerifyFile(f *File, path string) error +} + +// Packages is a list of packages to generate. +type Packages []Package + +// Generator is the contract for anything that wants to do auto-generation. +// It's expected that the io.Writers passed to the below functions will be +// ErrorTrackers; this allows implementations to not check for io errors, +// making more readable code. +// +// The call order for the functions that take a Context is: +// 1. Filter() // Subsequent calls see only types that pass this. +// 2. Namers() // Subsequent calls see the namers provided by this. +// 3. PackageVars() +// 4. PackageConsts() +// 5. Init() +// 6. GenerateType() // Called N times, once per type in the context's Order. +// 7. Imports() +// +// You may have multiple generators for the same file. +type Generator interface { + // The name of this generator. Will be included in generated comments. + Name() string + + // Filter should return true if this generator cares about this type. + // (otherwise, GenerateType will not be called.) + // + // Filter is called before any of the generator's other functions; + // subsequent calls will get a context with only the types that passed + // this filter. + Filter(*Context, *types.Type) bool + + // If this generator needs special namers, return them here. These will + // override the original namers in the context if there is a collision. + // You may return nil if you don't need special names. These names will + // be available in the context passed to the rest of the generator's + // functions. + // + // A use case for this is to return a namer that tracks imports. + Namers(*Context) namer.NameSystems + + // Init should write an init function, and any other content that's not + // generated per-type. (It's not intended for generator specific + // initialization! Do that when your Package constructs the + // Generators.) + Init(*Context, io.Writer) error + + // Finalize should write finish up functions, and any other content that's not + // generated per-type. + Finalize(*Context, io.Writer) error + + // PackageVars should emit an array of variable lines. They will be + // placed in a var ( ... ) block. There's no need to include a leading + // \t or trailing \n. + PackageVars(*Context) []string + + // PackageConsts should emit an array of constant lines. They will be + // placed in a const ( ... ) block. There's no need to include a leading + // \t or trailing \n. + PackageConsts(*Context) []string + + // GenerateType should emit the code for a particular type. + GenerateType(*Context, *types.Type, io.Writer) error + + // Imports should return a list of necessary imports. They will be + // formatted correctly. You do not need to include quotation marks, + // return only the package name; alternatively, you can also return + // imports in the format `name "path/to/pkg"`. Imports will be called + // after Init, PackageVars, PackageConsts, and GenerateType, to allow + // you to keep track of what imports you actually need. + Imports(*Context) []string + + // Preferred file name of this generator, not including a path. It is + // allowed for multiple generators to use the same filename, but it's + // up to you to make sure they don't have colliding import names. + // TODO: provide per-file import tracking, removing the requirement + // that generators coordinate.. + Filename() string + + // A registered file type in the context to generate this file with. If + // the FileType is not found in the context, execution will stop. + FileType() string +} + +// Context is global context for individual generators to consume. +type Context struct { + // A map from the naming system to the names for that system. E.g., you + // might have public names and several private naming systems. + Namers namer.NameSystems + + // All the types, in case you want to look up something. + Universe types.Universe + + // Incoming imports, i.e. packages importing the given package. + incomingImports map[string][]string + + // Incoming transitive imports, i.e. the transitive closure of IncomingImports + incomingTransitiveImports map[string][]string + + // All the user-specified packages. This is after recursive expansion. + Inputs []string + + // The canonical ordering of the types (will be filtered by both the + // Package's and Generator's Filter methods). + Order []*types.Type + + // A set of types this context can process. If this is empty or nil, + // the default "golang" filetype will be provided. + FileTypes map[string]FileType + + // If true, Execute* calls will just verify that the existing output is + // correct. (You may set this after calling NewContext.) + Verify bool + + // Allows generators to add packages at runtime. + builder *parser.Builder +} + +// NewContext generates a context from the given builder, naming systems, and +// the naming system you wish to construct the canonical ordering from. +func NewContext(b *parser.Builder, nameSystems namer.NameSystems, canonicalOrderName string) (*Context, error) { + universe, err := b.FindTypes() + if err != nil { + return nil, err + } + + c := &Context{ + Namers: namer.NameSystems{}, + Universe: universe, + Inputs: b.FindPackages(), + FileTypes: map[string]FileType{ + GolangFileType: NewGolangFile(), + }, + builder: b, + } + + for name, systemNamer := range nameSystems { + c.Namers[name] = systemNamer + if name == canonicalOrderName { + orderer := namer.Orderer{Namer: systemNamer} + c.Order = orderer.OrderUniverse(universe) + } + } + return c, nil +} + +// IncomingImports returns the incoming imports for each package. The map is lazily computed. +func (ctxt *Context) IncomingImports() map[string][]string { + if ctxt.incomingImports == nil { + incoming := map[string][]string{} + for _, pkg := range ctxt.Universe { + for imp := range pkg.Imports { + incoming[imp] = append(incoming[imp], pkg.Path) + } + } + ctxt.incomingImports = incoming + } + return ctxt.incomingImports +} + +// TransitiveIncomingImports returns the transitive closure of the incoming imports for each package. +// The map is lazily computed. +func (ctxt *Context) TransitiveIncomingImports() map[string][]string { + if ctxt.incomingTransitiveImports == nil { + ctxt.incomingTransitiveImports = transitiveClosure(ctxt.IncomingImports()) + } + return ctxt.incomingTransitiveImports +} + +// AddDir adds a Go package to the context. The specified path must be a single +// go package import path. GOPATH, GOROOT, and the location of your go binary +// (`which go`) will all be searched, in the normal Go fashion. +// Deprecated. Please use AddDirectory. +func (ctxt *Context) AddDir(path string) error { + ctxt.incomingImports = nil + ctxt.incomingTransitiveImports = nil + return ctxt.builder.AddDirTo(path, &ctxt.Universe) +} + +// AddDirectory adds a Go package to the context. The specified path must be a +// single go package import path. GOPATH, GOROOT, and the location of your go +// binary (`which go`) will all be searched, in the normal Go fashion. +func (ctxt *Context) AddDirectory(path string) (*types.Package, error) { + ctxt.incomingImports = nil + ctxt.incomingTransitiveImports = nil + return ctxt.builder.AddDirectoryTo(path, &ctxt.Universe) +} diff --git a/vendor/k8s.io/gengo/generator/import_tracker.go b/vendor/k8s.io/gengo/generator/import_tracker.go new file mode 100644 index 0000000000000..60c899ac4649c --- /dev/null +++ b/vendor/k8s.io/gengo/generator/import_tracker.go @@ -0,0 +1,70 @@ +/* +Copyright 2015 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. +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 generator + +import ( + "go/token" + "strings" + + "k8s.io/klog/v2" + + "k8s.io/gengo/namer" + "k8s.io/gengo/types" +) + +func NewImportTracker(typesToAdd ...*types.Type) namer.ImportTracker { + tracker := namer.NewDefaultImportTracker(types.Name{}) + tracker.IsInvalidType = func(*types.Type) bool { return false } + tracker.LocalName = func(name types.Name) string { return golangTrackerLocalName(&tracker, name) } + tracker.PrintImport = func(path, name string) string { return name + " \"" + path + "\"" } + + tracker.AddTypes(typesToAdd...) + return &tracker + +} + +func golangTrackerLocalName(tracker namer.ImportTracker, t types.Name) string { + path := t.Package + + // Using backslashes in package names causes gengo to produce Go code which + // will not compile with the gc compiler. See the comment on GoSeperator. + if strings.ContainsRune(path, '\\') { + klog.Warningf("Warning: backslash used in import path '%v', this is unsupported.\n", path) + } + + dirs := strings.Split(path, namer.GoSeperator) + for n := len(dirs) - 1; n >= 0; n-- { + // follow kube convention of not having anything between directory names + name := strings.Join(dirs[n:], "") + name = strings.Replace(name, "_", "", -1) + // These characters commonly appear in import paths for go + // packages, but aren't legal go names. So we'll sanitize. + name = strings.Replace(name, ".", "", -1) + name = strings.Replace(name, "-", "", -1) + if _, found := tracker.PathOf(name); found { + // This name collides with some other package + continue + } + + // If the import name is a Go keyword, prefix with an underscore. + if token.Lookup(name).IsKeyword() { + name = "_" + name + } + return name + } + panic("can't find import for " + path) +} diff --git a/vendor/k8s.io/gengo/generator/snippet_writer.go b/vendor/k8s.io/gengo/generator/snippet_writer.go new file mode 100644 index 0000000000000..590775ff228b1 --- /dev/null +++ b/vendor/k8s.io/gengo/generator/snippet_writer.go @@ -0,0 +1,154 @@ +/* +Copyright 2015 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. +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 generator + +import ( + "fmt" + "io" + "runtime" + "text/template" +) + +// SnippetWriter is an attempt to make the template library usable. +// Methods are chainable, and you don't have to check Error() until you're all +// done. +type SnippetWriter struct { + w io.Writer + context *Context + // Left & right delimiters. text/template defaults to "{{" and "}}" + // which is totally unusable for go code based templates. + left, right string + funcMap template.FuncMap + err error +} + +// w is the destination; left and right are the delimiters; @ and $ are both +// reasonable choices. +// +// c is used to make a function for every naming system, to which you can pass +// a type and get the corresponding name. +func NewSnippetWriter(w io.Writer, c *Context, left, right string) *SnippetWriter { + sw := &SnippetWriter{ + w: w, + context: c, + left: left, + right: right, + funcMap: template.FuncMap{}, + } + for name, namer := range c.Namers { + sw.funcMap[name] = namer.Name + } + return sw +} + +// Do parses format and runs args through it. You can have arbitrary logic in +// the format (see the text/template documentation), but consider running many +// short templates with ordinary go logic in between--this may be more +// readable. Do is chainable. Any error causes every other call to do to be +// ignored, and the error will be returned by Error(). So you can check it just +// once, at the end of your function. +// +// 'args' can be quite literally anything; read the text/template documentation +// for details. Maps and structs work particularly nicely. Conveniently, the +// types package is designed to have structs that are easily referencable from +// the template language. +// +// Example: +// +// sw := generator.NewSnippetWriter(outBuffer, context, "$", "$") +// sw.Do(`The public type name is: $.type|public$`, map[string]interface{}{"type": t}) +// return sw.Error() +// +// Where: +// * "$" starts a template directive +// * "." references the entire thing passed as args +// * "type" therefore sees a map and looks up the key "type" +// * "|" means "pass the thing on the left to the thing on the right" +// * "public" is the name of a naming system, so the SnippetWriter has given +// the template a function called "public" that takes a *types.Type and +// returns the naming system's name. E.g., if the type is "string" this might +// return "String". +// * the second "$" ends the template directive. +// +// The map is actually not necessary. The below does the same thing: +// +// sw.Do(`The public type name is: $.|public$`, t) +// +// You may or may not find it more readable to use the map with a descriptive +// key, but if you want to pass more than one arg, the map or a custom struct +// becomes a requirement. You can do arbitrary logic inside these templates, +// but you should consider doing the logic in go and stitching them together +// for the sake of your readers. +// +// TODO: Change Do() to optionally take a list of pairs of parameters (key, value) +// and have it construct a combined map with that and args. +func (s *SnippetWriter) Do(format string, args interface{}) *SnippetWriter { + if s.err != nil { + return s + } + // Name the template by source file:line so it can be found when + // there's an error. + _, file, line, _ := runtime.Caller(1) + tmpl, err := template. + New(fmt.Sprintf("%s:%d", file, line)). + Delims(s.left, s.right). + Funcs(s.funcMap). + Parse(format) + if err != nil { + s.err = err + return s + } + err = tmpl.Execute(s.w, args) + if err != nil { + s.err = err + } + return s +} + +// Args exists to make it convenient to construct arguments for +// SnippetWriter.Do. +type Args map[interface{}]interface{} + +// With makes a copy of a and adds the given key, value pair. +func (a Args) With(key, value interface{}) Args { + a2 := Args{key: value} + for k, v := range a { + a2[k] = v + } + return a2 +} + +// WithArgs makes a copy of a and adds the given arguments. +func (a Args) WithArgs(rhs Args) Args { + a2 := Args{} + for k, v := range rhs { + a2[k] = v + } + for k, v := range a { + a2[k] = v + } + return a2 +} + +func (s *SnippetWriter) Out() io.Writer { + return s.w +} + +// Error returns any encountered error. +func (s *SnippetWriter) Error() error { + return s.err +} diff --git a/vendor/k8s.io/gengo/generator/transitive_closure.go b/vendor/k8s.io/gengo/generator/transitive_closure.go new file mode 100644 index 0000000000000..385a49fce312d --- /dev/null +++ b/vendor/k8s.io/gengo/generator/transitive_closure.go @@ -0,0 +1,65 @@ +/* +Copyright 2019 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. +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 generator + +import "sort" + +type edge struct { + from string + to string +} + +func transitiveClosure(in map[string][]string) map[string][]string { + adj := make(map[edge]bool) + imports := make(map[string]struct{}) + for from, tos := range in { + for _, to := range tos { + adj[edge{from, to}] = true + imports[to] = struct{}{} + } + } + + // Warshal's algorithm + for k := range in { + for i := range in { + if !adj[edge{i, k}] { + continue + } + for j := range imports { + if adj[edge{i, j}] { + continue + } + if adj[edge{k, j}] { + adj[edge{i, j}] = true + } + } + } + } + + out := make(map[string][]string, len(in)) + for i := range in { + for j := range imports { + if adj[edge{i, j}] { + out[i] = append(out[i], j) + } + } + + sort.Strings(out[i]) + } + + return out +} diff --git a/vendor/k8s.io/gengo/namer/BUILD.bazel b/vendor/k8s.io/gengo/namer/BUILD.bazel new file mode 100644 index 0000000000000..f283f89f07966 --- /dev/null +++ b/vendor/k8s.io/gengo/namer/BUILD.bazel @@ -0,0 +1,16 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "doc.go", + "import_tracker.go", + "namer.go", + "order.go", + "plural_namer.go", + ], + importmap = "k8s.io/kops/vendor/k8s.io/gengo/namer", + importpath = "k8s.io/gengo/namer", + visibility = ["//visibility:public"], + deps = ["//vendor/k8s.io/gengo/types:go_default_library"], +) diff --git a/vendor/k8s.io/gengo/namer/doc.go b/vendor/k8s.io/gengo/namer/doc.go new file mode 100644 index 0000000000000..8a44ea995973f --- /dev/null +++ b/vendor/k8s.io/gengo/namer/doc.go @@ -0,0 +1,31 @@ +/* +Copyright 2015 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. +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 namer has support for making different type naming systems. +// +// This is because sometimes you want to refer to the literal type, sometimes +// you want to make a name for the thing you're generating, and you want to +// make the name based on the type. For example, if you have `type foo string`, +// you want to be able to generate something like `func FooPrinter(f *foo) { +// Print(string(*f)) }`; that is, you want to refer to a public name, a literal +// name, and the underlying literal name. +// +// This package supports the idea of a "Namer" and a set of "NameSystems" to +// support these use cases. +// +// Additionally, a "RawNamer" can optionally keep track of what needs to be +// imported. +package namer // import "k8s.io/gengo/namer" diff --git a/vendor/k8s.io/gengo/namer/import_tracker.go b/vendor/k8s.io/gengo/namer/import_tracker.go new file mode 100644 index 0000000000000..37094b2deb5a6 --- /dev/null +++ b/vendor/k8s.io/gengo/namer/import_tracker.go @@ -0,0 +1,112 @@ +/* +Copyright 2015 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. +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 namer + +import ( + "sort" + + "k8s.io/gengo/types" +) + +// ImportTracker may be passed to a namer.RawNamer, to track the imports needed +// for the types it names. +// +// TODO: pay attention to the package name (instead of renaming every package). +type DefaultImportTracker struct { + pathToName map[string]string + // forbidden names are in here. (e.g. "go" is a directory in which + // there is code, but "go" is not a legal name for a package, so we put + // it here to prevent us from naming any package "go") + nameToPath map[string]string + local types.Name + + // Returns true if a given types is an invalid type and should be ignored. + IsInvalidType func(*types.Type) bool + // Returns the final local name for the given name + LocalName func(types.Name) string + // Returns the "import" line for a given (path, name). + PrintImport func(string, string) string +} + +func NewDefaultImportTracker(local types.Name) DefaultImportTracker { + return DefaultImportTracker{ + pathToName: map[string]string{}, + nameToPath: map[string]string{}, + local: local, + } +} + +func (tracker *DefaultImportTracker) AddTypes(types ...*types.Type) { + for _, t := range types { + tracker.AddType(t) + } +} +func (tracker *DefaultImportTracker) AddType(t *types.Type) { + if tracker.local.Package == t.Name.Package { + return + } + + if tracker.IsInvalidType(t) { + if t.Kind == types.Builtin { + return + } + if _, ok := tracker.nameToPath[t.Name.Package]; !ok { + tracker.nameToPath[t.Name.Package] = "" + } + return + } + + if len(t.Name.Package) == 0 { + return + } + path := t.Name.Path + if len(path) == 0 { + path = t.Name.Package + } + if _, ok := tracker.pathToName[path]; ok { + return + } + name := tracker.LocalName(t.Name) + tracker.nameToPath[name] = path + tracker.pathToName[path] = name +} + +func (tracker *DefaultImportTracker) ImportLines() []string { + importPaths := []string{} + for path := range tracker.pathToName { + importPaths = append(importPaths, path) + } + sort.Sort(sort.StringSlice(importPaths)) + out := []string{} + for _, path := range importPaths { + out = append(out, tracker.PrintImport(path, tracker.pathToName[path])) + } + return out +} + +// LocalNameOf returns the name you would use to refer to the package at the +// specified path within the body of a file. +func (tracker *DefaultImportTracker) LocalNameOf(path string) string { + return tracker.pathToName[path] +} + +// PathOf returns the path that a given localName is referring to within the +// body of a file. +func (tracker *DefaultImportTracker) PathOf(localName string) (string, bool) { + name, ok := tracker.nameToPath[localName] + return name, ok +} diff --git a/vendor/k8s.io/gengo/namer/namer.go b/vendor/k8s.io/gengo/namer/namer.go new file mode 100644 index 0000000000000..d700a00a53ea3 --- /dev/null +++ b/vendor/k8s.io/gengo/namer/namer.go @@ -0,0 +1,383 @@ +/* +Copyright 2015 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. +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 namer + +import ( + "path/filepath" + "strings" + + "k8s.io/gengo/types" +) + +const ( + // GoSeperator is used to split go import paths. + // Forward slash is used instead of filepath.Seperator because it is the + // only universally-accepted path delimiter and the only delimiter not + // potentially forbidden by Go compilers. (In particular gc does not allow + // the use of backslashes in import paths.) + // See https://golang.org/ref/spec#Import_declarations. + // See also https://github.com/kubernetes/gengo/issues/83#issuecomment-367040772. + GoSeperator = "/" +) + +// Returns whether a name is a private Go name. +func IsPrivateGoName(name string) bool { + return len(name) == 0 || strings.ToLower(name[:1]) == name[:1] +} + +// NewPublicNamer is a helper function that returns a namer that makes +// CamelCase names. See the NameStrategy struct for an explanation of the +// arguments to this constructor. +func NewPublicNamer(prependPackageNames int, ignoreWords ...string) *NameStrategy { + n := &NameStrategy{ + Join: Joiner(IC, IC), + IgnoreWords: map[string]bool{}, + PrependPackageNames: prependPackageNames, + } + for _, w := range ignoreWords { + n.IgnoreWords[w] = true + } + return n +} + +// NewPrivateNamer is a helper function that returns a namer that makes +// camelCase names. See the NameStrategy struct for an explanation of the +// arguments to this constructor. +func NewPrivateNamer(prependPackageNames int, ignoreWords ...string) *NameStrategy { + n := &NameStrategy{ + Join: Joiner(IL, IC), + IgnoreWords: map[string]bool{}, + PrependPackageNames: prependPackageNames, + } + for _, w := range ignoreWords { + n.IgnoreWords[w] = true + } + return n +} + +// NewRawNamer will return a Namer that makes a name by which you would +// directly refer to a type, optionally keeping track of the import paths +// necessary to reference the names it provides. Tracker may be nil. +// The 'pkg' is the full package name, in which the Namer is used - all +// types from that package will be referenced by just type name without +// referencing the package. +// +// For example, if the type is map[string]int, a raw namer will literally +// return "map[string]int". +// +// Or if the type, in package foo, is "type Bar struct { ... }", then the raw +// namer will return "foo.Bar" as the name of the type, and if 'tracker' was +// not nil, will record that package foo needs to be imported. +func NewRawNamer(pkg string, tracker ImportTracker) *rawNamer { + return &rawNamer{pkg: pkg, tracker: tracker} +} + +// Names is a map from Type to name, as defined by some Namer. +type Names map[*types.Type]string + +// Namer takes a type, and assigns a name. +// +// The purpose of this complexity is so that you can assign coherent +// side-by-side systems of names for the types. For example, you might want a +// public interface, a private implementation struct, and also to reference +// literally the type name. +// +// Note that it is safe to call your own Name() function recursively to find +// the names of keys, elements, etc. This is because anonymous types can't have +// cycles in their names, and named types don't require the sort of recursion +// that would be problematic. +type Namer interface { + Name(*types.Type) string +} + +// NameSystems is a map of a system name to a namer for that system. +type NameSystems map[string]Namer + +// NameStrategy is a general Namer. The easiest way to use it is to copy the +// Public/PrivateNamer variables, and modify the members you wish to change. +// +// The Name method produces a name for the given type, of the forms: +// Anonymous types: +// Named types: +// +// In all cases, every part of the name is run through the capitalization +// functions. +// +// The IgnoreWords map can be set if you have directory names that are +// semantically meaningless for naming purposes, e.g. "proto". +// +// Prefix and Suffix can be used to disambiguate parallel systems of type +// names. For example, if you want to generate an interface and an +// implementation, you might want to suffix one with "Interface" and the other +// with "Implementation". Another common use-- if you want to generate private +// types, and one of your source types could be "string", you can't use the +// default lowercase private namer. You'll have to add a suffix or prefix. +type NameStrategy struct { + Prefix, Suffix string + Join func(pre string, parts []string, post string) string + + // Add non-meaningful package directory names here (e.g. "proto") and + // they will be ignored. + IgnoreWords map[string]bool + + // If > 0, prepend exactly that many package directory names (or as + // many as there are). Package names listed in "IgnoreWords" will be + // ignored. + // + // For example, if Ignore words lists "proto" and type Foo is in + // pkg/server/frobbing/proto, then a value of 1 will give a type name + // of FrobbingFoo, 2 gives ServerFrobbingFoo, etc. + PrependPackageNames int + + // A cache of names thus far assigned by this namer. + Names +} + +// IC ensures the first character is uppercase. +func IC(in string) string { + if in == "" { + return in + } + return strings.ToUpper(in[:1]) + in[1:] +} + +// IL ensures the first character is lowercase. +func IL(in string) string { + if in == "" { + return in + } + return strings.ToLower(in[:1]) + in[1:] +} + +// Joiner lets you specify functions that preprocess the various components of +// a name before joining them. You can construct e.g. camelCase or CamelCase or +// any other way of joining words. (See the IC and IL convenience functions.) +func Joiner(first, others func(string) string) func(pre string, in []string, post string) string { + return func(pre string, in []string, post string) string { + tmp := []string{others(pre)} + for i := range in { + tmp = append(tmp, others(in[i])) + } + tmp = append(tmp, others(post)) + return first(strings.Join(tmp, "")) + } +} + +func (ns *NameStrategy) removePrefixAndSuffix(s string) string { + // The join function may have changed capitalization. + lowerIn := strings.ToLower(s) + lowerP := strings.ToLower(ns.Prefix) + lowerS := strings.ToLower(ns.Suffix) + b, e := 0, len(s) + if strings.HasPrefix(lowerIn, lowerP) { + b = len(ns.Prefix) + } + if strings.HasSuffix(lowerIn, lowerS) { + e -= len(ns.Suffix) + } + return s[b:e] +} + +var ( + importPathNameSanitizer = strings.NewReplacer("-", "_", ".", "") +) + +// filters out unwanted directory names and sanitizes remaining names. +func (ns *NameStrategy) filterDirs(path string) []string { + allDirs := strings.Split(path, GoSeperator) + dirs := make([]string, 0, len(allDirs)) + for _, p := range allDirs { + if ns.IgnoreWords == nil || !ns.IgnoreWords[p] { + dirs = append(dirs, importPathNameSanitizer.Replace(p)) + } + } + return dirs +} + +// See the comment on NameStrategy. +func (ns *NameStrategy) Name(t *types.Type) string { + if ns.Names == nil { + ns.Names = Names{} + } + if s, ok := ns.Names[t]; ok { + return s + } + + if t.Name.Package != "" { + dirs := append(ns.filterDirs(t.Name.Package), t.Name.Name) + i := ns.PrependPackageNames + 1 + dn := len(dirs) + if i > dn { + i = dn + } + name := ns.Join(ns.Prefix, dirs[dn-i:], ns.Suffix) + ns.Names[t] = name + return name + } + + // Only anonymous types remain. + var name string + switch t.Kind { + case types.Builtin: + name = ns.Join(ns.Prefix, []string{t.Name.Name}, ns.Suffix) + case types.Map: + name = ns.Join(ns.Prefix, []string{ + "Map", + ns.removePrefixAndSuffix(ns.Name(t.Key)), + "To", + ns.removePrefixAndSuffix(ns.Name(t.Elem)), + }, ns.Suffix) + case types.Slice: + name = ns.Join(ns.Prefix, []string{ + "Slice", + ns.removePrefixAndSuffix(ns.Name(t.Elem)), + }, ns.Suffix) + case types.Pointer: + name = ns.Join(ns.Prefix, []string{ + "Pointer", + ns.removePrefixAndSuffix(ns.Name(t.Elem)), + }, ns.Suffix) + case types.Struct: + names := []string{"Struct"} + for _, m := range t.Members { + names = append(names, ns.removePrefixAndSuffix(ns.Name(m.Type))) + } + name = ns.Join(ns.Prefix, names, ns.Suffix) + case types.Chan: + name = ns.Join(ns.Prefix, []string{ + "Chan", + ns.removePrefixAndSuffix(ns.Name(t.Elem)), + }, ns.Suffix) + case types.Interface: + // TODO: add to name test + names := []string{"Interface"} + for _, m := range t.Methods { + // TODO: include function signature + names = append(names, m.Name.Name) + } + name = ns.Join(ns.Prefix, names, ns.Suffix) + case types.Func: + // TODO: add to name test + parts := []string{"Func"} + for _, pt := range t.Signature.Parameters { + parts = append(parts, ns.removePrefixAndSuffix(ns.Name(pt))) + } + parts = append(parts, "Returns") + for _, rt := range t.Signature.Results { + parts = append(parts, ns.removePrefixAndSuffix(ns.Name(rt))) + } + name = ns.Join(ns.Prefix, parts, ns.Suffix) + default: + name = "unnameable_" + string(t.Kind) + } + ns.Names[t] = name + return name +} + +// ImportTracker allows a raw namer to keep track of the packages needed for +// import. You can implement yourself or use the one in the generation package. +type ImportTracker interface { + AddType(*types.Type) + LocalNameOf(packagePath string) string + PathOf(localName string) (string, bool) + ImportLines() []string +} + +type rawNamer struct { + pkg string + tracker ImportTracker + Names +} + +// Name makes a name the way you'd write it to literally refer to type t, +// making ordinary assumptions about how you've imported t's package (or using +// r.tracker to specifically track the package imports). +func (r *rawNamer) Name(t *types.Type) string { + if r.Names == nil { + r.Names = Names{} + } + if name, ok := r.Names[t]; ok { + return name + } + if t.Name.Package != "" { + var name string + if r.tracker != nil { + r.tracker.AddType(t) + if t.Name.Package == r.pkg { + name = t.Name.Name + } else { + name = r.tracker.LocalNameOf(t.Name.Package) + "." + t.Name.Name + } + } else { + if t.Name.Package == r.pkg { + name = t.Name.Name + } else { + name = filepath.Base(t.Name.Package) + "." + t.Name.Name + } + } + r.Names[t] = name + return name + } + var name string + switch t.Kind { + case types.Builtin: + name = t.Name.Name + case types.Map: + name = "map[" + r.Name(t.Key) + "]" + r.Name(t.Elem) + case types.Slice: + name = "[]" + r.Name(t.Elem) + case types.Pointer: + name = "*" + r.Name(t.Elem) + case types.Struct: + elems := []string{} + for _, m := range t.Members { + elems = append(elems, m.Name+" "+r.Name(m.Type)) + } + name = "struct{" + strings.Join(elems, "; ") + "}" + case types.Chan: + // TODO: include directionality + name = "chan " + r.Name(t.Elem) + case types.Interface: + // TODO: add to name test + elems := []string{} + for _, m := range t.Methods { + // TODO: include function signature + elems = append(elems, m.Name.Name) + } + name = "interface{" + strings.Join(elems, "; ") + "}" + case types.Func: + // TODO: add to name test + params := []string{} + for _, pt := range t.Signature.Parameters { + params = append(params, r.Name(pt)) + } + results := []string{} + for _, rt := range t.Signature.Results { + results = append(results, r.Name(rt)) + } + name = "func(" + strings.Join(params, ",") + ")" + if len(results) == 1 { + name += " " + results[0] + } else if len(results) > 1 { + name += " (" + strings.Join(results, ",") + ")" + } + default: + name = "unnameable_" + string(t.Kind) + } + r.Names[t] = name + return name +} diff --git a/vendor/k8s.io/gengo/namer/order.go b/vendor/k8s.io/gengo/namer/order.go new file mode 100644 index 0000000000000..fd89be9b08371 --- /dev/null +++ b/vendor/k8s.io/gengo/namer/order.go @@ -0,0 +1,72 @@ +/* +Copyright 2015 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. +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 namer + +import ( + "sort" + + "k8s.io/gengo/types" +) + +// Orderer produces an ordering of types given a Namer. +type Orderer struct { + Namer +} + +// OrderUniverse assigns a name to every type in the Universe, including Types, +// Functions and Variables, and returns a list sorted by those names. +func (o *Orderer) OrderUniverse(u types.Universe) []*types.Type { + list := tList{ + namer: o.Namer, + } + for _, p := range u { + for _, t := range p.Types { + list.types = append(list.types, t) + } + for _, f := range p.Functions { + list.types = append(list.types, f) + } + for _, v := range p.Variables { + list.types = append(list.types, v) + } + for _, v := range p.Constants { + list.types = append(list.types, v) + } + } + sort.Sort(list) + return list.types +} + +// OrderTypes assigns a name to every type, and returns a list sorted by those +// names. +func (o *Orderer) OrderTypes(typeList []*types.Type) []*types.Type { + list := tList{ + namer: o.Namer, + types: typeList, + } + sort.Sort(list) + return list.types +} + +type tList struct { + namer Namer + types []*types.Type +} + +func (t tList) Len() int { return len(t.types) } +func (t tList) Less(i, j int) bool { return t.namer.Name(t.types[i]) < t.namer.Name(t.types[j]) } +func (t tList) Swap(i, j int) { t.types[i], t.types[j] = t.types[j], t.types[i] } diff --git a/vendor/k8s.io/gengo/namer/plural_namer.go b/vendor/k8s.io/gengo/namer/plural_namer.go new file mode 100644 index 0000000000000..0e3ebbf262a71 --- /dev/null +++ b/vendor/k8s.io/gengo/namer/plural_namer.go @@ -0,0 +1,120 @@ +/* +Copyright 2015 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. +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 namer + +import ( + "strings" + + "k8s.io/gengo/types" +) + +var consonants = "bcdfghjklmnpqrstvwxyz" + +type pluralNamer struct { + // key is the case-sensitive type name, value is the case-insensitive + // intended output. + exceptions map[string]string + finalize func(string) string +} + +// NewPublicPluralNamer returns a namer that returns the plural form of the input +// type's name, starting with a uppercase letter. +func NewPublicPluralNamer(exceptions map[string]string) *pluralNamer { + return &pluralNamer{exceptions, IC} +} + +// NewPrivatePluralNamer returns a namer that returns the plural form of the input +// type's name, starting with a lowercase letter. +func NewPrivatePluralNamer(exceptions map[string]string) *pluralNamer { + return &pluralNamer{exceptions, IL} +} + +// NewAllLowercasePluralNamer returns a namer that returns the plural form of the input +// type's name, with all letters in lowercase. +func NewAllLowercasePluralNamer(exceptions map[string]string) *pluralNamer { + return &pluralNamer{exceptions, strings.ToLower} +} + +// Name returns the plural form of the type's name. If the type's name is found +// in the exceptions map, the map value is returned. +func (r *pluralNamer) Name(t *types.Type) string { + singular := t.Name.Name + var plural string + var ok bool + if plural, ok = r.exceptions[singular]; ok { + return r.finalize(plural) + } + if len(singular) < 2 { + return r.finalize(singular) + } + + switch rune(singular[len(singular)-1]) { + case 's', 'x', 'z': + plural = esPlural(singular) + case 'y': + sl := rune(singular[len(singular)-2]) + if isConsonant(sl) { + plural = iesPlural(singular) + } else { + plural = sPlural(singular) + } + case 'h': + sl := rune(singular[len(singular)-2]) + if sl == 'c' || sl == 's' { + plural = esPlural(singular) + } else { + plural = sPlural(singular) + } + case 'e': + sl := rune(singular[len(singular)-2]) + if sl == 'f' { + plural = vesPlural(singular[:len(singular)-1]) + } else { + plural = sPlural(singular) + } + case 'f': + plural = vesPlural(singular) + default: + plural = sPlural(singular) + } + return r.finalize(plural) +} + +func iesPlural(singular string) string { + return singular[:len(singular)-1] + "ies" +} + +func vesPlural(singular string) string { + return singular[:len(singular)-1] + "ves" +} + +func esPlural(singular string) string { + return singular + "es" +} + +func sPlural(singular string) string { + return singular + "s" +} + +func isConsonant(char rune) bool { + for _, c := range consonants { + if char == c { + return true + } + } + return false +} diff --git a/vendor/k8s.io/gengo/parser/BUILD.bazel b/vendor/k8s.io/gengo/parser/BUILD.bazel new file mode 100644 index 0000000000000..22518da8e8e95 --- /dev/null +++ b/vendor/k8s.io/gengo/parser/BUILD.bazel @@ -0,0 +1,16 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "doc.go", + "parse.go", + ], + importmap = "k8s.io/kops/vendor/k8s.io/gengo/parser", + importpath = "k8s.io/gengo/parser", + visibility = ["//visibility:public"], + deps = [ + "//vendor/k8s.io/gengo/types:go_default_library", + "//vendor/k8s.io/klog/v2:go_default_library", + ], +) diff --git a/vendor/k8s.io/gengo/parser/doc.go b/vendor/k8s.io/gengo/parser/doc.go new file mode 100644 index 0000000000000..8231b6d432034 --- /dev/null +++ b/vendor/k8s.io/gengo/parser/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2015 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. +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 parser provides code to parse go files, type-check them, extract the +// types. +package parser // import "k8s.io/gengo/parser" diff --git a/vendor/k8s.io/gengo/parser/parse.go b/vendor/k8s.io/gengo/parser/parse.go new file mode 100644 index 0000000000000..92cf42d315052 --- /dev/null +++ b/vendor/k8s.io/gengo/parser/parse.go @@ -0,0 +1,862 @@ +/* +Copyright 2015 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. +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 parser + +import ( + "fmt" + "go/ast" + "go/build" + "go/parser" + "go/token" + tc "go/types" + "io/ioutil" + "os" + "os/exec" + "path" + "path/filepath" + "regexp" + "sort" + "strings" + + "k8s.io/gengo/types" + "k8s.io/klog/v2" +) + +// This clarifies when a pkg path has been canonicalized. +type importPathString string + +// Builder lets you add all the go files in all the packages that you care +// about, then constructs the type source data. +type Builder struct { + context *build.Context + + // If true, include *_test.go + IncludeTestFiles bool + + // Map of package names to more canonical information about the package. + // This might hold the same value for multiple names, e.g. if someone + // referenced ./pkg/name or in the case of vendoring, which canonicalizes + // differently that what humans would type. + buildPackages map[string]*build.Package + + fset *token.FileSet + // map of package path to list of parsed files + parsed map[importPathString][]parsedFile + // map of package path to absolute path (to prevent overlap) + absPaths map[importPathString]string + + // Set by typeCheckPackage(), used by importPackage() and friends. + typeCheckedPackages map[importPathString]*tc.Package + + // Map of package path to whether the user requested it or it was from + // an import. + userRequested map[importPathString]bool + + // All comments from everywhere in every parsed file. + endLineToCommentGroup map[fileLine]*ast.CommentGroup + + // map of package to list of packages it imports. + importGraph map[importPathString]map[string]struct{} +} + +// parsedFile is for tracking files with name +type parsedFile struct { + name string + file *ast.File +} + +// key type for finding comments. +type fileLine struct { + file string + line int +} + +// New constructs a new builder. +func New() *Builder { + c := build.Default + if c.GOROOT == "" { + if p, err := exec.Command("which", "go").CombinedOutput(); err == nil { + // The returned string will have some/path/bin/go, so remove the last two elements. + c.GOROOT = filepath.Dir(filepath.Dir(strings.Trim(string(p), "\n"))) + } else { + klog.Warningf("Warning: $GOROOT not set, and unable to run `which go` to find it: %v\n", err) + } + } + // Force this to off, since we don't properly parse CGo. All symbols must + // have non-CGo equivalents. + c.CgoEnabled = false + return &Builder{ + context: &c, + buildPackages: map[string]*build.Package{}, + typeCheckedPackages: map[importPathString]*tc.Package{}, + fset: token.NewFileSet(), + parsed: map[importPathString][]parsedFile{}, + absPaths: map[importPathString]string{}, + userRequested: map[importPathString]bool{}, + endLineToCommentGroup: map[fileLine]*ast.CommentGroup{}, + importGraph: map[importPathString]map[string]struct{}{}, + } +} + +// AddBuildTags adds the specified build tags to the parse context. +func (b *Builder) AddBuildTags(tags ...string) { + b.context.BuildTags = append(b.context.BuildTags, tags...) +} + +// Get package information from the go/build package. Automatically excludes +// e.g. test files and files for other platforms-- there is quite a bit of +// logic of that nature in the build package. +func (b *Builder) importBuildPackage(dir string) (*build.Package, error) { + if buildPkg, ok := b.buildPackages[dir]; ok { + return buildPkg, nil + } + // This validates the `package foo // github.com/bar/foo` comments. + buildPkg, err := b.importWithMode(dir, build.ImportComment) + if err != nil { + if _, ok := err.(*build.NoGoError); !ok { + return nil, fmt.Errorf("unable to import %q: %v", dir, err) + } + } + if buildPkg == nil { + // Might be an empty directory. Try to just find the dir. + buildPkg, err = b.importWithMode(dir, build.FindOnly) + if err != nil { + return nil, err + } + } + + // Remember it under the user-provided name. + klog.V(5).Infof("saving buildPackage %s", dir) + b.buildPackages[dir] = buildPkg + canonicalPackage := canonicalizeImportPath(buildPkg.ImportPath) + if dir != string(canonicalPackage) { + // Since `dir` is not the canonical name, see if we knew it under another name. + if buildPkg, ok := b.buildPackages[string(canonicalPackage)]; ok { + return buildPkg, nil + } + // Must be new, save it under the canonical name, too. + klog.V(5).Infof("saving buildPackage %s", canonicalPackage) + b.buildPackages[string(canonicalPackage)] = buildPkg + } + + return buildPkg, nil +} + +// AddFileForTest adds a file to the set, without verifying that the provided +// pkg actually exists on disk. The pkg must be of the form "canonical/pkg/path" +// and the path must be the absolute path to the file. Because this bypasses +// the normal recursive finding of package dependencies (on disk), test should +// sort their test files topologically first, so all deps are resolved by the +// time we need them. +func (b *Builder) AddFileForTest(pkg string, path string, src []byte) error { + if err := b.addFile(importPathString(pkg), path, src, true); err != nil { + return err + } + if _, err := b.typeCheckPackage(importPathString(pkg)); err != nil { + return err + } + return nil +} + +// addFile adds a file to the set. The pkgPath must be of the form +// "canonical/pkg/path" and the path must be the absolute path to the file. A +// flag indicates whether this file was user-requested or just from following +// the import graph. +func (b *Builder) addFile(pkgPath importPathString, path string, src []byte, userRequested bool) error { + for _, p := range b.parsed[pkgPath] { + if path == p.name { + klog.V(5).Infof("addFile %s %s already parsed, skipping", pkgPath, path) + return nil + } + } + klog.V(6).Infof("addFile %s %s", pkgPath, path) + p, err := parser.ParseFile(b.fset, path, src, parser.DeclarationErrors|parser.ParseComments) + if err != nil { + return err + } + + // This is redundant with addDir, but some tests call AddFileForTest, which + // call into here without calling addDir. + b.userRequested[pkgPath] = userRequested || b.userRequested[pkgPath] + + b.parsed[pkgPath] = append(b.parsed[pkgPath], parsedFile{path, p}) + for _, c := range p.Comments { + position := b.fset.Position(c.End()) + b.endLineToCommentGroup[fileLine{position.Filename, position.Line}] = c + } + + // We have to get the packages from this specific file, in case the + // user added individual files instead of entire directories. + if b.importGraph[pkgPath] == nil { + b.importGraph[pkgPath] = map[string]struct{}{} + } + for _, im := range p.Imports { + importedPath := strings.Trim(im.Path.Value, `"`) + b.importGraph[pkgPath][importedPath] = struct{}{} + } + return nil +} + +// AddDir adds an entire directory, scanning it for go files. 'dir' should have +// a single go package in it. GOPATH, GOROOT, and the location of your go +// binary (`which go`) will all be searched if dir doesn't literally resolve. +func (b *Builder) AddDir(dir string) error { + _, err := b.importPackage(dir, true) + return err +} + +// AddDirRecursive is just like AddDir, but it also recursively adds +// subdirectories; it returns an error only if the path couldn't be resolved; +// any directories recursed into without go source are ignored. +func (b *Builder) AddDirRecursive(dir string) error { + // Add the root. + if _, err := b.importPackage(dir, true); err != nil { + klog.Warningf("Ignoring directory %v: %v", dir, err) + } + + // filepath.Walk does not follow symlinks. We therefore evaluate symlinks and use that with + // filepath.Walk. + realPath, err := filepath.EvalSymlinks(b.buildPackages[dir].Dir) + if err != nil { + return err + } + + fn := func(filePath string, info os.FileInfo, err error) error { + if info != nil && info.IsDir() { + rel := filepath.ToSlash(strings.TrimPrefix(filePath, realPath)) + if rel != "" { + // Make a pkg path. + pkg := path.Join(string(canonicalizeImportPath(b.buildPackages[dir].ImportPath)), rel) + + // Add it. + if _, err := b.importPackage(pkg, true); err != nil { + klog.Warningf("Ignoring child directory %v: %v", pkg, err) + } + } + } + return nil + } + if err := filepath.Walk(realPath, fn); err != nil { + return err + } + return nil +} + +// AddDirTo adds an entire directory to a given Universe. Unlike AddDir, this +// processes the package immediately, which makes it safe to use from within a +// generator (rather than just at init time. 'dir' must be a single go package. +// GOPATH, GOROOT, and the location of your go binary (`which go`) will all be +// searched if dir doesn't literally resolve. +// Deprecated. Please use AddDirectoryTo. +func (b *Builder) AddDirTo(dir string, u *types.Universe) error { + // We want all types from this package, as if they were directly added + // by the user. They WERE added by the user, in effect. + if _, err := b.importPackage(dir, true); err != nil { + return err + } + return b.findTypesIn(canonicalizeImportPath(b.buildPackages[dir].ImportPath), u) +} + +// AddDirectoryTo adds an entire directory to a given Universe. Unlike AddDir, +// this processes the package immediately, which makes it safe to use from +// within a generator (rather than just at init time. 'dir' must be a single go +// package. GOPATH, GOROOT, and the location of your go binary (`which go`) +// will all be searched if dir doesn't literally resolve. +func (b *Builder) AddDirectoryTo(dir string, u *types.Universe) (*types.Package, error) { + // We want all types from this package, as if they were directly added + // by the user. They WERE added by the user, in effect. + if _, err := b.importPackage(dir, true); err != nil { + return nil, err + } + path := canonicalizeImportPath(b.buildPackages[dir].ImportPath) + if err := b.findTypesIn(path, u); err != nil { + return nil, err + } + return u.Package(string(path)), nil +} + +// The implementation of AddDir. A flag indicates whether this directory was +// user-requested or just from following the import graph. +func (b *Builder) addDir(dir string, userRequested bool) error { + klog.V(5).Infof("addDir %s", dir) + buildPkg, err := b.importBuildPackage(dir) + if err != nil { + return err + } + canonicalPackage := canonicalizeImportPath(buildPkg.ImportPath) + pkgPath := canonicalPackage + if dir != string(canonicalPackage) { + klog.V(5).Infof("addDir %s, canonical path is %s", dir, pkgPath) + } + + // Sanity check the pkg dir has not changed. + if prev, found := b.absPaths[pkgPath]; found { + if buildPkg.Dir != prev { + return fmt.Errorf("package %q (%s) previously resolved to %s", pkgPath, buildPkg.Dir, prev) + } + } else { + b.absPaths[pkgPath] = buildPkg.Dir + } + + files := []string{} + files = append(files, buildPkg.GoFiles...) + if b.IncludeTestFiles { + files = append(files, buildPkg.TestGoFiles...) + } + + for _, file := range files { + if !strings.HasSuffix(file, ".go") { + continue + } + absPath := filepath.Join(buildPkg.Dir, file) + data, err := ioutil.ReadFile(absPath) + if err != nil { + return fmt.Errorf("while loading %q: %v", absPath, err) + } + err = b.addFile(pkgPath, absPath, data, userRequested) + if err != nil { + return fmt.Errorf("while parsing %q: %v", absPath, err) + } + } + return nil +} + +// regexErrPackageNotFound helps test the expected error for not finding a package. +var regexErrPackageNotFound = regexp.MustCompile(`^unable to import ".*?":.*`) + +func isErrPackageNotFound(err error) bool { + return regexErrPackageNotFound.MatchString(err.Error()) +} + +// importPackage is a function that will be called by the type check package when it +// needs to import a go package. 'path' is the import path. +func (b *Builder) importPackage(dir string, userRequested bool) (*tc.Package, error) { + klog.V(5).Infof("importPackage %s", dir) + var pkgPath = importPathString(dir) + + // Get the canonical path if we can. + if buildPkg := b.buildPackages[dir]; buildPkg != nil { + canonicalPackage := canonicalizeImportPath(buildPkg.ImportPath) + klog.V(5).Infof("importPackage %s, canonical path is %s", dir, canonicalPackage) + pkgPath = canonicalPackage + } + + // If we have not seen this before, process it now. + ignoreError := false + if _, found := b.parsed[pkgPath]; !found { + // Ignore errors in paths that we're importing solely because + // they're referenced by other packages. + ignoreError = true + + // Add it. + if err := b.addDir(dir, userRequested); err != nil { + if isErrPackageNotFound(err) { + klog.V(6).Info(err) + return nil, nil + } + + return nil, err + } + + // Get the canonical path now that it has been added. + if buildPkg := b.buildPackages[dir]; buildPkg != nil { + canonicalPackage := canonicalizeImportPath(buildPkg.ImportPath) + klog.V(5).Infof("importPackage %s, canonical path is %s", dir, canonicalPackage) + pkgPath = canonicalPackage + } + } + + // If it was previously known, just check that the user-requestedness hasn't + // changed. + b.userRequested[pkgPath] = userRequested || b.userRequested[pkgPath] + + // Run the type checker. We may end up doing this to pkgs that are already + // done, or are in the queue to be done later, but it will short-circuit, + // and we can't miss pkgs that are only depended on. + pkg, err := b.typeCheckPackage(pkgPath) + if err != nil { + switch { + case ignoreError && pkg != nil: + klog.V(2).Infof("type checking encountered some issues in %q, but ignoring.\n", pkgPath) + case !ignoreError && pkg != nil: + klog.V(2).Infof("type checking encountered some errors in %q\n", pkgPath) + return nil, err + default: + return nil, err + } + } + + return pkg, nil +} + +type importAdapter struct { + b *Builder +} + +func (a importAdapter) Import(path string) (*tc.Package, error) { + return a.b.importPackage(path, false) +} + +// typeCheckPackage will attempt to return the package even if there are some +// errors, so you may check whether the package is nil or not even if you get +// an error. +func (b *Builder) typeCheckPackage(pkgPath importPathString) (*tc.Package, error) { + klog.V(5).Infof("typeCheckPackage %s", pkgPath) + if pkg, ok := b.typeCheckedPackages[pkgPath]; ok { + if pkg != nil { + klog.V(6).Infof("typeCheckPackage %s already done", pkgPath) + return pkg, nil + } + // We store a nil right before starting work on a package. So + // if we get here and it's present and nil, that means there's + // another invocation of this function on the call stack + // already processing this package. + return nil, fmt.Errorf("circular dependency for %q", pkgPath) + } + parsedFiles, ok := b.parsed[pkgPath] + if !ok { + return nil, fmt.Errorf("No files for pkg %q", pkgPath) + } + files := make([]*ast.File, len(parsedFiles)) + for i := range parsedFiles { + files[i] = parsedFiles[i].file + } + b.typeCheckedPackages[pkgPath] = nil + c := tc.Config{ + IgnoreFuncBodies: true, + // Note that importAdapter can call b.importPackage which calls this + // method. So there can't be cycles in the import graph. + Importer: importAdapter{b}, + Error: func(err error) { + klog.V(2).Infof("type checker: %v\n", err) + }, + } + pkg, err := c.Check(string(pkgPath), b.fset, files, nil) + b.typeCheckedPackages[pkgPath] = pkg // record the result whether or not there was an error + return pkg, err +} + +// FindPackages fetches a list of the user-imported packages. +// Note that you need to call b.FindTypes() first. +func (b *Builder) FindPackages() []string { + // Iterate packages in a predictable order. + pkgPaths := []string{} + for k := range b.typeCheckedPackages { + pkgPaths = append(pkgPaths, string(k)) + } + sort.Strings(pkgPaths) + + result := []string{} + for _, pkgPath := range pkgPaths { + if b.userRequested[importPathString(pkgPath)] { + // Since walkType is recursive, all types that are in packages that + // were directly mentioned will be included. We don't need to + // include all types in all transitive packages, though. + result = append(result, pkgPath) + } + } + return result +} + +// FindTypes finalizes the package imports, and searches through all the +// packages for types. +func (b *Builder) FindTypes() (types.Universe, error) { + // Take a snapshot of pkgs to iterate, since this will recursively mutate + // b.parsed. Iterate in a predictable order. + pkgPaths := []string{} + for pkgPath := range b.parsed { + pkgPaths = append(pkgPaths, string(pkgPath)) + } + sort.Strings(pkgPaths) + + u := types.Universe{} + for _, pkgPath := range pkgPaths { + if err := b.findTypesIn(importPathString(pkgPath), &u); err != nil { + return nil, err + } + } + return u, nil +} + +// findTypesIn finalizes the package import and searches through the package +// for types. +func (b *Builder) findTypesIn(pkgPath importPathString, u *types.Universe) error { + klog.V(5).Infof("findTypesIn %s", pkgPath) + pkg := b.typeCheckedPackages[pkgPath] + if pkg == nil { + return fmt.Errorf("findTypesIn(%s): package is not known", pkgPath) + } + if !b.userRequested[pkgPath] { + // Since walkType is recursive, all types that the + // packages they asked for depend on will be included. + // But we don't need to include all types in all + // *packages* they depend on. + klog.V(5).Infof("findTypesIn %s: package is not user requested", pkgPath) + return nil + } + + // We're keeping this package. This call will create the record. + u.Package(string(pkgPath)).Name = pkg.Name() + u.Package(string(pkgPath)).Path = pkg.Path() + u.Package(string(pkgPath)).SourcePath = b.absPaths[pkgPath] + + for _, f := range b.parsed[pkgPath] { + if _, fileName := filepath.Split(f.name); fileName == "doc.go" { + tp := u.Package(string(pkgPath)) + // findTypesIn might be called multiple times. Clean up tp.Comments + // to avoid repeatedly fill same comments to it. + tp.Comments = []string{} + for i := range f.file.Comments { + tp.Comments = append(tp.Comments, splitLines(f.file.Comments[i].Text())...) + } + if f.file.Doc != nil { + tp.DocComments = splitLines(f.file.Doc.Text()) + } + } + } + + s := pkg.Scope() + for _, n := range s.Names() { + obj := s.Lookup(n) + tn, ok := obj.(*tc.TypeName) + if ok { + t := b.walkType(*u, nil, tn.Type()) + c1 := b.priorCommentLines(obj.Pos(), 1) + // c1.Text() is safe if c1 is nil + t.CommentLines = splitLines(c1.Text()) + if c1 == nil { + t.SecondClosestCommentLines = splitLines(b.priorCommentLines(obj.Pos(), 2).Text()) + } else { + t.SecondClosestCommentLines = splitLines(b.priorCommentLines(c1.List[0].Slash, 2).Text()) + } + } + tf, ok := obj.(*tc.Func) + // We only care about functions, not concrete/abstract methods. + if ok && tf.Type() != nil && tf.Type().(*tc.Signature).Recv() == nil { + t := b.addFunction(*u, nil, tf) + c1 := b.priorCommentLines(obj.Pos(), 1) + // c1.Text() is safe if c1 is nil + t.CommentLines = splitLines(c1.Text()) + if c1 == nil { + t.SecondClosestCommentLines = splitLines(b.priorCommentLines(obj.Pos(), 2).Text()) + } else { + t.SecondClosestCommentLines = splitLines(b.priorCommentLines(c1.List[0].Slash, 2).Text()) + } + } + tv, ok := obj.(*tc.Var) + if ok && !tv.IsField() { + b.addVariable(*u, nil, tv) + } + tconst, ok := obj.(*tc.Const) + if ok { + b.addConstant(*u, nil, tconst) + } + } + + importedPkgs := []string{} + for k := range b.importGraph[pkgPath] { + importedPkgs = append(importedPkgs, string(k)) + } + sort.Strings(importedPkgs) + for _, p := range importedPkgs { + u.AddImports(string(pkgPath), p) + } + return nil +} + +func (b *Builder) importWithMode(dir string, mode build.ImportMode) (*build.Package, error) { + // This is a bit of a hack. The srcDir argument to Import() should + // properly be the dir of the file which depends on the package to be + // imported, so that vendoring can work properly and local paths can + // resolve. We assume that there is only one level of vendoring, and that + // the CWD is inside the GOPATH, so this should be safe. Nobody should be + // using local (relative) paths except on the CLI, so CWD is also + // sufficient. + cwd, err := os.Getwd() + if err != nil { + return nil, fmt.Errorf("unable to get current directory: %v", err) + } + buildPkg, err := b.context.Import(filepath.ToSlash(dir), cwd, mode) + if err != nil { + return nil, err + } + return buildPkg, nil +} + +// if there's a comment on the line `lines` before pos, return its text, otherwise "". +func (b *Builder) priorCommentLines(pos token.Pos, lines int) *ast.CommentGroup { + position := b.fset.Position(pos) + key := fileLine{position.Filename, position.Line - lines} + return b.endLineToCommentGroup[key] +} + +func splitLines(str string) []string { + return strings.Split(strings.TrimRight(str, "\n"), "\n") +} + +func tcFuncNameToName(in string) types.Name { + name := strings.TrimPrefix(in, "func ") + nameParts := strings.Split(name, "(") + return tcNameToName(nameParts[0]) +} + +func tcVarNameToName(in string) types.Name { + nameParts := strings.Split(in, " ") + // nameParts[0] is "var". + // nameParts[2:] is the type of the variable, we ignore it for now. + return tcNameToName(nameParts[1]) +} + +func tcNameToName(in string) types.Name { + // Detect anonymous type names. (These may have '.' characters because + // embedded types may have packages, so we detect them specially.) + if strings.HasPrefix(in, "struct{") || + strings.HasPrefix(in, "<-chan") || + strings.HasPrefix(in, "chan<-") || + strings.HasPrefix(in, "chan ") || + strings.HasPrefix(in, "func(") || + strings.HasPrefix(in, "*") || + strings.HasPrefix(in, "map[") || + strings.HasPrefix(in, "[") { + return types.Name{Name: in} + } + + // Otherwise, if there are '.' characters present, the name has a + // package path in front. + nameParts := strings.Split(in, ".") + name := types.Name{Name: in} + if n := len(nameParts); n >= 2 { + // The final "." is the name of the type--previous ones must + // have been in the package path. + name.Package, name.Name = strings.Join(nameParts[:n-1], "."), nameParts[n-1] + } + return name +} + +func (b *Builder) convertSignature(u types.Universe, t *tc.Signature) *types.Signature { + signature := &types.Signature{} + for i := 0; i < t.Params().Len(); i++ { + signature.Parameters = append(signature.Parameters, b.walkType(u, nil, t.Params().At(i).Type())) + } + for i := 0; i < t.Results().Len(); i++ { + signature.Results = append(signature.Results, b.walkType(u, nil, t.Results().At(i).Type())) + } + if r := t.Recv(); r != nil { + signature.Receiver = b.walkType(u, nil, r.Type()) + } + signature.Variadic = t.Variadic() + return signature +} + +// walkType adds the type, and any necessary child types. +func (b *Builder) walkType(u types.Universe, useName *types.Name, in tc.Type) *types.Type { + // Most of the cases are underlying types of the named type. + name := tcNameToName(in.String()) + if useName != nil { + name = *useName + } + + switch t := in.(type) { + case *tc.Struct: + out := u.Type(name) + if out.Kind != types.Unknown { + return out + } + out.Kind = types.Struct + for i := 0; i < t.NumFields(); i++ { + f := t.Field(i) + m := types.Member{ + Name: f.Name(), + Embedded: f.Anonymous(), + Tags: t.Tag(i), + Type: b.walkType(u, nil, f.Type()), + CommentLines: splitLines(b.priorCommentLines(f.Pos(), 1).Text()), + } + out.Members = append(out.Members, m) + } + return out + case *tc.Map: + out := u.Type(name) + if out.Kind != types.Unknown { + return out + } + out.Kind = types.Map + out.Elem = b.walkType(u, nil, t.Elem()) + out.Key = b.walkType(u, nil, t.Key()) + return out + case *tc.Pointer: + out := u.Type(name) + if out.Kind != types.Unknown { + return out + } + out.Kind = types.Pointer + out.Elem = b.walkType(u, nil, t.Elem()) + return out + case *tc.Slice: + out := u.Type(name) + if out.Kind != types.Unknown { + return out + } + out.Kind = types.Slice + out.Elem = b.walkType(u, nil, t.Elem()) + return out + case *tc.Array: + out := u.Type(name) + if out.Kind != types.Unknown { + return out + } + out.Kind = types.Array + out.Elem = b.walkType(u, nil, t.Elem()) + // TODO: need to store array length, otherwise raw type name + // cannot be properly written. + return out + case *tc.Chan: + out := u.Type(name) + if out.Kind != types.Unknown { + return out + } + out.Kind = types.Chan + out.Elem = b.walkType(u, nil, t.Elem()) + // TODO: need to store direction, otherwise raw type name + // cannot be properly written. + return out + case *tc.Basic: + out := u.Type(types.Name{ + Package: "", + Name: t.Name(), + }) + if out.Kind != types.Unknown { + return out + } + out.Kind = types.Unsupported + return out + case *tc.Signature: + out := u.Type(name) + if out.Kind != types.Unknown { + return out + } + out.Kind = types.Func + out.Signature = b.convertSignature(u, t) + return out + case *tc.Interface: + out := u.Type(name) + if out.Kind != types.Unknown { + return out + } + out.Kind = types.Interface + t.Complete() + for i := 0; i < t.NumMethods(); i++ { + if out.Methods == nil { + out.Methods = map[string]*types.Type{} + } + method := t.Method(i) + name := tcNameToName(method.String()) + mt := b.walkType(u, &name, method.Type()) + mt.CommentLines = splitLines(b.priorCommentLines(method.Pos(), 1).Text()) + out.Methods[method.Name()] = mt + } + return out + case *tc.Named: + var out *types.Type + switch t.Underlying().(type) { + case *tc.Named, *tc.Basic, *tc.Map, *tc.Slice: + name := tcNameToName(t.String()) + out = u.Type(name) + if out.Kind != types.Unknown { + return out + } + out.Kind = types.Alias + out.Underlying = b.walkType(u, nil, t.Underlying()) + default: + // tc package makes everything "named" with an + // underlying anonymous type--we remove that annoying + // "feature" for users. This flattens those types + // together. + name := tcNameToName(t.String()) + if out := u.Type(name); out.Kind != types.Unknown { + return out // short circuit if we've already made this. + } + out = b.walkType(u, &name, t.Underlying()) + } + // If the underlying type didn't already add methods, add them. + // (Interface types will have already added methods.) + if len(out.Methods) == 0 { + for i := 0; i < t.NumMethods(); i++ { + if out.Methods == nil { + out.Methods = map[string]*types.Type{} + } + method := t.Method(i) + name := tcNameToName(method.String()) + mt := b.walkType(u, &name, method.Type()) + mt.CommentLines = splitLines(b.priorCommentLines(method.Pos(), 1).Text()) + out.Methods[method.Name()] = mt + } + } + return out + default: + out := u.Type(name) + if out.Kind != types.Unknown { + return out + } + out.Kind = types.Unsupported + klog.Warningf("Making unsupported type entry %q for: %#v\n", out, t) + return out + } +} + +func (b *Builder) addFunction(u types.Universe, useName *types.Name, in *tc.Func) *types.Type { + name := tcFuncNameToName(in.String()) + if useName != nil { + name = *useName + } + out := u.Function(name) + out.Kind = types.DeclarationOf + out.Underlying = b.walkType(u, nil, in.Type()) + return out +} + +func (b *Builder) addVariable(u types.Universe, useName *types.Name, in *tc.Var) *types.Type { + name := tcVarNameToName(in.String()) + if useName != nil { + name = *useName + } + out := u.Variable(name) + out.Kind = types.DeclarationOf + out.Underlying = b.walkType(u, nil, in.Type()) + return out +} + +func (b *Builder) addConstant(u types.Universe, useName *types.Name, in *tc.Const) *types.Type { + name := tcVarNameToName(in.String()) + if useName != nil { + name = *useName + } + out := u.Constant(name) + out.Kind = types.DeclarationOf + out.Underlying = b.walkType(u, nil, in.Type()) + return out +} + +// canonicalizeImportPath takes an import path and returns the actual package. +// It doesn't support nested vendoring. +func canonicalizeImportPath(importPath string) importPathString { + if !strings.Contains(importPath, "/vendor/") { + return importPathString(importPath) + } + + return importPathString(importPath[strings.Index(importPath, "/vendor/")+len("/vendor/"):]) +} diff --git a/vendor/k8s.io/gengo/types/BUILD.bazel b/vendor/k8s.io/gengo/types/BUILD.bazel new file mode 100644 index 0000000000000..4393052b3f78b --- /dev/null +++ b/vendor/k8s.io/gengo/types/BUILD.bazel @@ -0,0 +1,14 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "comments.go", + "doc.go", + "flatten.go", + "types.go", + ], + importmap = "k8s.io/kops/vendor/k8s.io/gengo/types", + importpath = "k8s.io/gengo/types", + visibility = ["//visibility:public"], +) diff --git a/vendor/k8s.io/gengo/types/comments.go b/vendor/k8s.io/gengo/types/comments.go new file mode 100644 index 0000000000000..8150c383875d6 --- /dev/null +++ b/vendor/k8s.io/gengo/types/comments.go @@ -0,0 +1,82 @@ +/* +Copyright 2015 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. +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 types contains go type information, packaged in a way that makes +// auto-generation convenient, whether by template or straight go functions. +package types + +import ( + "fmt" + "strings" +) + +// ExtractCommentTags parses comments for lines of the form: +// +// 'marker' + "key=value". +// +// Values are optional; "" is the default. A tag can be specified more than +// one time and all values are returned. If the resulting map has an entry for +// a key, the value (a slice) is guaranteed to have at least 1 element. +// +// Example: if you pass "+" for 'marker', and the following lines are in +// the comments: +// +foo=value1 +// +bar +// +foo=value2 +// +baz="qux" +// Then this function will return: +// map[string][]string{"foo":{"value1, "value2"}, "bar": {""}, "baz": {"qux"}} +func ExtractCommentTags(marker string, lines []string) map[string][]string { + out := map[string][]string{} + for _, line := range lines { + line = strings.Trim(line, " ") + if len(line) == 0 { + continue + } + if !strings.HasPrefix(line, marker) { + continue + } + // TODO: we could support multiple values per key if we split on spaces + kv := strings.SplitN(line[len(marker):], "=", 2) + if len(kv) == 2 { + out[kv[0]] = append(out[kv[0]], kv[1]) + } else if len(kv) == 1 { + out[kv[0]] = append(out[kv[0]], "") + } + } + return out +} + +// ExtractSingleBoolCommentTag parses comments for lines of the form: +// +// 'marker' + "key=value1" +// +// If the tag is not found, the default value is returned. Values are asserted +// to be boolean ("true" or "false"), and any other value will cause an error +// to be returned. If the key has multiple values, the first one will be used. +func ExtractSingleBoolCommentTag(marker string, key string, defaultVal bool, lines []string) (bool, error) { + values := ExtractCommentTags(marker, lines)[key] + if values == nil { + return defaultVal, nil + } + if values[0] == "true" { + return true, nil + } + if values[0] == "false" { + return false, nil + } + return false, fmt.Errorf("tag value for %q is not boolean: %q", key, values[0]) +} diff --git a/vendor/k8s.io/gengo/types/doc.go b/vendor/k8s.io/gengo/types/doc.go new file mode 100644 index 0000000000000..74a969a763a14 --- /dev/null +++ b/vendor/k8s.io/gengo/types/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2015 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. +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 types contains go type information, packaged in a way that makes +// auto-generation convenient, whether by template or straight go functions. +package types // import "k8s.io/gengo/types" diff --git a/vendor/k8s.io/gengo/types/flatten.go b/vendor/k8s.io/gengo/types/flatten.go new file mode 100644 index 0000000000000..585014e8ba005 --- /dev/null +++ b/vendor/k8s.io/gengo/types/flatten.go @@ -0,0 +1,57 @@ +/* +Copyright 2015 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. +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 types + +// FlattenMembers recursively takes any embedded members and puts them in the +// top level, correctly hiding them if the top level hides them. There must not +// be a cycle-- that implies infinite members. +// +// This is useful for e.g. computing all the valid keys in a json struct, +// properly considering any configuration of embedded structs. +func FlattenMembers(m []Member) []Member { + embedded := []Member{} + normal := []Member{} + type nameInfo struct { + top bool + i int + } + names := map[string]nameInfo{} + for i := range m { + if m[i].Embedded && m[i].Type.Kind == Struct { + embedded = append(embedded, m[i]) + } else { + normal = append(normal, m[i]) + names[m[i].Name] = nameInfo{true, len(normal) - 1} + } + } + for i := range embedded { + for _, e := range FlattenMembers(embedded[i].Type.Members) { + if info, found := names[e.Name]; found { + if info.top { + continue + } + if n := normal[info.i]; n.Name == e.Name && n.Type == e.Type { + continue + } + panic("conflicting members") + } + normal = append(normal, e) + names[e.Name] = nameInfo{false, len(normal) - 1} + } + } + return normal +} diff --git a/vendor/k8s.io/gengo/types/types.go b/vendor/k8s.io/gengo/types/types.go new file mode 100644 index 0000000000000..78357bcce1b4c --- /dev/null +++ b/vendor/k8s.io/gengo/types/types.go @@ -0,0 +1,526 @@ +/* +Copyright 2015 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. +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 types + +import "strings" + +// Ref makes a reference to the given type. It can only be used for e.g. +// passing to namers. +func Ref(packageName, typeName string) *Type { + return &Type{Name: Name{ + Name: typeName, + Package: packageName, + }} +} + +// A type name may have a package qualifier. +type Name struct { + // Empty if embedded or builtin. This is the package path unless Path is specified. + Package string + // The type name. + Name string + // An optional location of the type definition for languages that can have disjoint + // packages and paths. + Path string +} + +// String returns the name formatted as a string. +func (n Name) String() string { + if n.Package == "" { + return n.Name + } + return n.Package + "." + n.Name +} + +// ParseFullyQualifiedName parses a name like k8s.io/kubernetes/pkg/api.Pod into a Name. +func ParseFullyQualifiedName(fqn string) Name { + cs := strings.Split(fqn, ".") + pkg := "" + if len(cs) > 1 { + pkg = strings.Join(cs[0:len(cs)-1], ".") + } + return Name{ + Name: cs[len(cs)-1], + Package: pkg, + } +} + +// The possible classes of types. +type Kind string + +const ( + // Builtin is a primitive, like bool, string, int. + Builtin Kind = "Builtin" + Struct Kind = "Struct" + Map Kind = "Map" + Slice Kind = "Slice" + Pointer Kind = "Pointer" + + // Alias is an alias of another type, e.g. in: + // type Foo string + // type Bar Foo + // Bar is an alias of Foo. + // + // In the real go type system, Foo is a "Named" string; but to simplify + // generation, this type system will just say that Foo *is* a builtin. + // We then need "Alias" as a way for us to say that Bar *is* a Foo. + Alias Kind = "Alias" + + // Interface is any type that could have differing types at run time. + Interface Kind = "Interface" + + // The remaining types are included for completeness, but are not well + // supported. + Array Kind = "Array" // Array is just like slice, but has a fixed length. + Chan Kind = "Chan" + Func Kind = "Func" + + // DeclarationOf is different from other Kinds; it indicates that instead of + // representing an actual Type, the type is a declaration of an instance of + // a type. E.g., a top-level function, variable, or constant. See the + // comment for Type.Name for more detail. + DeclarationOf Kind = "DeclarationOf" + Unknown Kind = "" + Unsupported Kind = "Unsupported" + + // Protobuf is protobuf type. + Protobuf Kind = "Protobuf" +) + +// Package holds package-level information. +// Fields are public, as everything in this package, to enable consumption by +// templates (for example). But it is strongly encouraged for code to build by +// using the provided functions. +type Package struct { + // Canonical name of this package-- its path. + Path string + + // The location this package was loaded from + SourcePath string + + // Short name of this package; the name that appears in the + // 'package x' line. + Name string + + // The comment right above the package declaration in doc.go, if any. + DocComments []string + + // All comments from doc.go, if any. + // TODO: remove Comments and use DocComments everywhere. + Comments []string + + // Types within this package, indexed by their name (*not* including + // package name). + Types map[string]*Type + + // Functions within this package, indexed by their name (*not* including + // package name). + Functions map[string]*Type + + // Global variables within this package, indexed by their name (*not* including + // package name). + Variables map[string]*Type + + // Global constants within this package, indexed by their name (*not* including + // package name). + Constants map[string]*Type + + // Packages imported by this package, indexed by (canonicalized) + // package path. + Imports map[string]*Package +} + +// Has returns true if the given name references a type known to this package. +func (p *Package) Has(name string) bool { + _, has := p.Types[name] + return has +} + +// Type gets the given Type in this Package. If the Type is not already +// defined, this will add it and return the new Type value. The caller is +// expected to finish initialization. +func (p *Package) Type(typeName string) *Type { + if t, ok := p.Types[typeName]; ok { + return t + } + if p.Path == "" { + // Import the standard builtin types! + if t, ok := builtins.Types[typeName]; ok { + p.Types[typeName] = t + return t + } + } + t := &Type{Name: Name{Package: p.Path, Name: typeName}} + p.Types[typeName] = t + return t +} + +// Function gets the given function Type in this Package. If the function is +// not already defined, this will add it. If a function is added, it's the +// caller's responsibility to finish construction of the function by setting +// Underlying to the correct type. +func (p *Package) Function(funcName string) *Type { + if t, ok := p.Functions[funcName]; ok { + return t + } + t := &Type{Name: Name{Package: p.Path, Name: funcName}} + t.Kind = DeclarationOf + p.Functions[funcName] = t + return t +} + +// Variable gets the given variable Type in this Package. If the variable is +// not already defined, this will add it. If a variable is added, it's the caller's +// responsibility to finish construction of the variable by setting Underlying +// to the correct type. +func (p *Package) Variable(varName string) *Type { + if t, ok := p.Variables[varName]; ok { + return t + } + t := &Type{Name: Name{Package: p.Path, Name: varName}} + t.Kind = DeclarationOf + p.Variables[varName] = t + return t +} + +// Constant gets the given constant Type in this Package. If the constant is +// not already defined, this will add it. If a constant is added, it's the caller's +// responsibility to finish construction of the constant by setting Underlying +// to the correct type. +func (p *Package) Constant(constName string) *Type { + if t, ok := p.Constants[constName]; ok { + return t + } + t := &Type{Name: Name{Package: p.Path, Name: constName}} + t.Kind = DeclarationOf + p.Constants[constName] = t + return t +} + +// HasImport returns true if p imports packageName. Package names include the +// package directory. +func (p *Package) HasImport(packageName string) bool { + _, has := p.Imports[packageName] + return has +} + +// Universe is a map of all packages. The key is the package name, but you +// should use Package(), Type(), Function(), or Variable() instead of direct +// access. +type Universe map[string]*Package + +// Type returns the canonical type for the given fully-qualified name. Builtin +// types will always be found, even if they haven't been explicitly added to +// the map. If a non-existing type is requested, this will create (a marker for) +// it. +func (u Universe) Type(n Name) *Type { + return u.Package(n.Package).Type(n.Name) +} + +// Function returns the canonical function for the given fully-qualified name. +// If a non-existing function is requested, this will create (a marker for) it. +// If a marker is created, it's the caller's responsibility to finish +// construction of the function by setting Underlying to the correct type. +func (u Universe) Function(n Name) *Type { + return u.Package(n.Package).Function(n.Name) +} + +// Variable returns the canonical variable for the given fully-qualified name. +// If a non-existing variable is requested, this will create (a marker for) it. +// If a marker is created, it's the caller's responsibility to finish +// construction of the variable by setting Underlying to the correct type. +func (u Universe) Variable(n Name) *Type { + return u.Package(n.Package).Variable(n.Name) +} + +// Constant returns the canonical constant for the given fully-qualified name. +// If a non-existing constant is requested, this will create (a marker for) it. +// If a marker is created, it's the caller's responsibility to finish +// construction of the constant by setting Underlying to the correct type. +func (u Universe) Constant(n Name) *Type { + return u.Package(n.Package).Constant(n.Name) +} + +// AddImports registers import lines for packageName. May be called multiple times. +// You are responsible for canonicalizing all package paths. +func (u Universe) AddImports(packagePath string, importPaths ...string) { + p := u.Package(packagePath) + for _, i := range importPaths { + p.Imports[i] = u.Package(i) + } +} + +// Package returns the Package for the given path. +// If a non-existing package is requested, this will create (a marker for) it. +// If a marker is created, it's the caller's responsibility to finish +// construction of the package. +func (u Universe) Package(packagePath string) *Package { + if p, ok := u[packagePath]; ok { + return p + } + p := &Package{ + Path: packagePath, + Types: map[string]*Type{}, + Functions: map[string]*Type{}, + Variables: map[string]*Type{}, + Constants: map[string]*Type{}, + Imports: map[string]*Package{}, + } + u[packagePath] = p + return p +} + +// Type represents a subset of possible go types. +type Type struct { + // There are two general categories of types, those explicitly named + // and those anonymous. Named ones will have a non-empty package in the + // name field. + // + // An exception: If Kind == DeclarationOf, then this name is the name of a + // top-level function, variable, or const, and the type can be found in Underlying. + // We do this to allow the naming system to work against these objects, even + // though they aren't strictly speaking types. + Name Name + + // The general kind of this type. + Kind Kind + + // If there are comment lines immediately before the type definition, + // they will be recorded here. + CommentLines []string + + // If there are comment lines preceding the `CommentLines`, they will be + // recorded here. There are two cases: + // --- + // SecondClosestCommentLines + // a blank line + // CommentLines + // type definition + // --- + // + // or + // --- + // SecondClosestCommentLines + // a blank line + // type definition + // --- + SecondClosestCommentLines []string + + // If Kind == Struct + Members []Member + + // If Kind == Map, Slice, Pointer, or Chan + Elem *Type + + // If Kind == Map, this is the map's key type. + Key *Type + + // If Kind == Alias, this is the underlying type. + // If Kind == DeclarationOf, this is the type of the declaration. + Underlying *Type + + // If Kind == Interface, this is the set of all required functions. + // Otherwise, if this is a named type, this is the list of methods that + // type has. (All elements will have Kind=="Func") + Methods map[string]*Type + + // If Kind == func, this is the signature of the function. + Signature *Signature + + // TODO: Add: + // * channel direction + // * array length +} + +// String returns the name of the type. +func (t *Type) String() string { + return t.Name.String() +} + +// IsPrimitive returns whether the type is a built-in type or is an alias to a +// built-in type. For example: strings and aliases of strings are primitives, +// structs are not. +func (t *Type) IsPrimitive() bool { + if t.Kind == Builtin || (t.Kind == Alias && t.Underlying.Kind == Builtin) { + return true + } + return false +} + +// IsAssignable returns whether the type is deep-assignable. For example, +// slices and maps and pointers are shallow copies, but ints and strings are +// complete. +func (t *Type) IsAssignable() bool { + if t.IsPrimitive() { + return true + } + if t.Kind == Struct { + for _, m := range t.Members { + if !m.Type.IsAssignable() { + return false + } + } + return true + } + return false +} + +// IsAnonymousStruct returns true if the type is an anonymous struct or an alias +// to an anonymous struct. +func (t *Type) IsAnonymousStruct() bool { + return (t.Kind == Struct && t.Name.Name == "struct{}") || (t.Kind == Alias && t.Underlying.IsAnonymousStruct()) +} + +// A single struct member +type Member struct { + // The name of the member. + Name string + + // If the member is embedded (anonymous) this will be true, and the + // Name will be the type name. + Embedded bool + + // If there are comment lines immediately before the member in the type + // definition, they will be recorded here. + CommentLines []string + + // If there are tags along with this member, they will be saved here. + Tags string + + // The type of this member. + Type *Type +} + +// String returns the name and type of the member. +func (m Member) String() string { + return m.Name + " " + m.Type.String() +} + +// Signature is a function's signature. +type Signature struct { + // TODO: store the parameter names, not just types. + + // If a method of some type, this is the type it's a member of. + Receiver *Type + Parameters []*Type + Results []*Type + + // True if the last in parameter is of the form ...T. + Variadic bool + + // If there are comment lines immediately before this + // signature/method/function declaration, they will be recorded here. + CommentLines []string +} + +// Built in types. +var ( + String = &Type{ + Name: Name{Name: "string"}, + Kind: Builtin, + } + Int64 = &Type{ + Name: Name{Name: "int64"}, + Kind: Builtin, + } + Int32 = &Type{ + Name: Name{Name: "int32"}, + Kind: Builtin, + } + Int16 = &Type{ + Name: Name{Name: "int16"}, + Kind: Builtin, + } + Int = &Type{ + Name: Name{Name: "int"}, + Kind: Builtin, + } + Uint64 = &Type{ + Name: Name{Name: "uint64"}, + Kind: Builtin, + } + Uint32 = &Type{ + Name: Name{Name: "uint32"}, + Kind: Builtin, + } + Uint16 = &Type{ + Name: Name{Name: "uint16"}, + Kind: Builtin, + } + Uint = &Type{ + Name: Name{Name: "uint"}, + Kind: Builtin, + } + Uintptr = &Type{ + Name: Name{Name: "uintptr"}, + Kind: Builtin, + } + Float64 = &Type{ + Name: Name{Name: "float64"}, + Kind: Builtin, + } + Float32 = &Type{ + Name: Name{Name: "float32"}, + Kind: Builtin, + } + Float = &Type{ + Name: Name{Name: "float"}, + Kind: Builtin, + } + Bool = &Type{ + Name: Name{Name: "bool"}, + Kind: Builtin, + } + Byte = &Type{ + Name: Name{Name: "byte"}, + Kind: Builtin, + } + + builtins = &Package{ + Types: map[string]*Type{ + "bool": Bool, + "string": String, + "int": Int, + "int64": Int64, + "int32": Int32, + "int16": Int16, + "int8": Byte, + "uint": Uint, + "uint64": Uint64, + "uint32": Uint32, + "uint16": Uint16, + "uint8": Byte, + "uintptr": Uintptr, + "byte": Byte, + "float": Float, + "float64": Float64, + "float32": Float32, + }, + Imports: map[string]*Package{}, + Path: "", + Name: "", + } +) + +func IsInteger(t *Type) bool { + switch t { + case Int, Int64, Int32, Int16, Uint, Uint64, Uint32, Uint16, Byte: + return true + default: + return false + } +} diff --git a/vendor/k8s.io/klog/v2/.gitignore b/vendor/k8s.io/klog/v2/.gitignore new file mode 100644 index 0000000000000..0aa2002392c05 --- /dev/null +++ b/vendor/k8s.io/klog/v2/.gitignore @@ -0,0 +1,17 @@ +# OSX leaves these everywhere on SMB shares +._* + +# OSX trash +.DS_Store + +# Eclipse files +.classpath +.project +.settings/** + +# Files generated by JetBrains IDEs, e.g. IntelliJ IDEA +.idea/ +*.iml + +# Vscode files +.vscode diff --git a/vendor/k8s.io/klog/v2/BUILD.bazel b/vendor/k8s.io/klog/v2/BUILD.bazel new file mode 100644 index 0000000000000..919d44c5a8a6f --- /dev/null +++ b/vendor/k8s.io/klog/v2/BUILD.bazel @@ -0,0 +1,13 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "klog.go", + "klog_file.go", + ], + importmap = "k8s.io/kops/vendor/k8s.io/klog/v2", + importpath = "k8s.io/klog/v2", + visibility = ["//visibility:public"], + deps = ["//vendor/github.com/go-logr/logr:go_default_library"], +) diff --git a/vendor/k8s.io/klog/v2/CONTRIBUTING.md b/vendor/k8s.io/klog/v2/CONTRIBUTING.md new file mode 100644 index 0000000000000..2641b1f41b7e1 --- /dev/null +++ b/vendor/k8s.io/klog/v2/CONTRIBUTING.md @@ -0,0 +1,22 @@ +# Contributing Guidelines + +Welcome to Kubernetes. We are excited about the prospect of you joining our [community](https://github.com/kubernetes/community)! The Kubernetes community abides by the CNCF [code of conduct](code-of-conduct.md). Here is an excerpt: + +_As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities._ + +## Getting Started + +We have full documentation on how to get started contributing here: + +- [Contributor License Agreement](https://git.k8s.io/community/CLA.md) Kubernetes projects require that you sign a Contributor License Agreement (CLA) before we can accept your pull requests +- [Kubernetes Contributor Guide](http://git.k8s.io/community/contributors/guide) - Main contributor documentation, or you can just jump directly to the [contributing section](http://git.k8s.io/community/contributors/guide#contributing) +- [Contributor Cheat Sheet](https://git.k8s.io/community/contributors/guide/contributor-cheatsheet) - Common resources for existing developers + +## Mentorship + +- [Mentoring Initiatives](https://git.k8s.io/community/mentoring) - We have a diverse set of mentorship programs available that are always looking for volunteers! + +## Contact Information + +- [Slack](https://kubernetes.slack.com/messages/sig-architecture) +- [Mailing List](https://groups.google.com/forum/#!forum/kubernetes-sig-architecture) diff --git a/vendor/k8s.io/klog/v2/LICENSE b/vendor/k8s.io/klog/v2/LICENSE new file mode 100644 index 0000000000000..37ec93a14fdcd --- /dev/null +++ b/vendor/k8s.io/klog/v2/LICENSE @@ -0,0 +1,191 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/k8s.io/klog/v2/OWNERS b/vendor/k8s.io/klog/v2/OWNERS new file mode 100644 index 0000000000000..380e514f2807b --- /dev/null +++ b/vendor/k8s.io/klog/v2/OWNERS @@ -0,0 +1,19 @@ +# See the OWNERS docs at https://go.k8s.io/owners +reviewers: + - jayunit100 + - hoegaarden + - andyxning + - neolit123 + - pohly + - yagonobre + - vincepri + - detiber +approvers: + - dims + - thockin + - justinsb + - tallclair + - piosz + - brancz + - DirectXMan12 + - lavalamp diff --git a/vendor/k8s.io/klog/v2/README.md b/vendor/k8s.io/klog/v2/README.md new file mode 100644 index 0000000000000..eda33d73d00af --- /dev/null +++ b/vendor/k8s.io/klog/v2/README.md @@ -0,0 +1,99 @@ +klog +==== + +klog is a permanent fork of https://github.com/golang/glog. + +## Why was klog created? + +The decision to create klog was one that wasn't made lightly, but it was necessary due to some +drawbacks that are present in [glog](https://github.com/golang/glog). Ultimately, the fork was created due to glog not being under active development; this can be seen in the glog README: + +> The code in this repo [...] is not itself under development + +This makes us unable to solve many use cases without a fork. The factors that contributed to needing feature development are listed below: + + * `glog` [presents a lot "gotchas"](https://github.com/kubernetes/kubernetes/issues/61006) and introduces challenges in containerized environments, all of which aren't well documented. + * `glog` doesn't provide an easy way to test logs, which detracts from the stability of software using it + * A long term goal is to implement a logging interface that allows us to add context, change output format, etc. + +Historical context is available here: + + * https://github.com/kubernetes/kubernetes/issues/61006 + * https://github.com/kubernetes/kubernetes/issues/70264 + * https://groups.google.com/forum/#!msg/kubernetes-sig-architecture/wCWiWf3Juzs/hXRVBH90CgAJ + * https://groups.google.com/forum/#!msg/kubernetes-dev/7vnijOMhLS0/1oRiNtigBgAJ + +---- + +How to use klog +=============== +- Replace imports for `github.com/golang/glog` with `k8s.io/klog` +- Use `klog.InitFlags(nil)` explicitly for initializing global flags as we no longer use `init()` method to register the flags +- You can now use `log_file` instead of `log_dir` for logging to a single file (See `examples/log_file/usage_log_file.go`) +- If you want to redirect everything logged using klog somewhere else (say syslog!), you can use `klog.SetOutput()` method and supply a `io.Writer`. (See `examples/set_output/usage_set_output.go`) +- For more logging conventions (See [Logging Conventions](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md)) + +**NOTE**: please use the newer go versions that support semantic import versioning in modules, ideally go 1.11.4 or greater. + +### Coexisting with glog +This package can be used side by side with glog. [This example](examples/coexist_glog/coexist_glog.go) shows how to initialize and syncronize flags from the global `flag.CommandLine` FlagSet. In addition, the example makes use of stderr as combined output by setting `alsologtostderr` (or `logtostderr`) to `true`. + +## Community, discussion, contribution, and support + +Learn how to engage with the Kubernetes community on the [community page](http://kubernetes.io/community/). + +You can reach the maintainers of this project at: + +- [Slack](https://kubernetes.slack.com/messages/sig-architecture) +- [Mailing List](https://groups.google.com/forum/#!forum/kubernetes-sig-architecture) + +### Code of conduct + +Participation in the Kubernetes community is governed by the [Kubernetes Code of Conduct](code-of-conduct.md). + +---- + +glog +==== + +Leveled execution logs for Go. + +This is an efficient pure Go implementation of leveled logs in the +manner of the open source C++ package + https://github.com/google/glog + +By binding methods to booleans it is possible to use the log package +without paying the expense of evaluating the arguments to the log. +Through the -vmodule flag, the package also provides fine-grained +control over logging at the file level. + +The comment from glog.go introduces the ideas: + + Package glog implements logging analogous to the Google-internal + C++ INFO/ERROR/V setup. It provides functions Info, Warning, + Error, Fatal, plus formatting variants such as Infof. It + also provides V-style logging controlled by the -v and + -vmodule=file=2 flags. + + Basic examples: + + glog.Info("Prepare to repel boarders") + + glog.Fatalf("Initialization failed: %s", err) + + See the documentation for the V function for an explanation + of these examples: + + if glog.V(2) { + glog.Info("Starting transaction...") + } + + glog.V(2).Infoln("Processed", nItems, "elements") + + +The repository contains an open source version of the log package +used inside Google. The master copy of the source lives inside +Google, not here. The code in this repo is for export only and is not itself +under development. Feature requests will be ignored. + +Send bug reports to golang-nuts@googlegroups.com. diff --git a/vendor/k8s.io/klog/v2/RELEASE.md b/vendor/k8s.io/klog/v2/RELEASE.md new file mode 100644 index 0000000000000..b53eb960ce78f --- /dev/null +++ b/vendor/k8s.io/klog/v2/RELEASE.md @@ -0,0 +1,9 @@ +# Release Process + +The `klog` is released on an as-needed basis. The process is as follows: + +1. An issue is proposing a new release with a changelog since the last release +1. All [OWNERS](OWNERS) must LGTM this release +1. An OWNER runs `git tag -s $VERSION` and inserts the changelog and pushes the tag with `git push $VERSION` +1. The release issue is closed +1. An announcement email is sent to `kubernetes-dev@googlegroups.com` with the subject `[ANNOUNCE] kubernetes-template-project $VERSION is released` diff --git a/vendor/k8s.io/klog/v2/SECURITY_CONTACTS b/vendor/k8s.io/klog/v2/SECURITY_CONTACTS new file mode 100644 index 0000000000000..6128a586995b4 --- /dev/null +++ b/vendor/k8s.io/klog/v2/SECURITY_CONTACTS @@ -0,0 +1,20 @@ +# Defined below are the security contacts for this repo. +# +# They are the contact point for the Product Security Committee to reach out +# to for triaging and handling of incoming issues. +# +# The below names agree to abide by the +# [Embargo Policy](https://git.k8s.io/security/private-distributors-list.md#embargo-policy) +# and will be removed and replaced if they violate that agreement. +# +# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE +# INSTRUCTIONS AT https://kubernetes.io/security/ + +dims +thockin +justinsb +tallclair +piosz +brancz +DirectXMan12 +lavalamp diff --git a/vendor/k8s.io/klog/v2/code-of-conduct.md b/vendor/k8s.io/klog/v2/code-of-conduct.md new file mode 100644 index 0000000000000..0d15c00cf3252 --- /dev/null +++ b/vendor/k8s.io/klog/v2/code-of-conduct.md @@ -0,0 +1,3 @@ +# Kubernetes Community Code of Conduct + +Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md) diff --git a/vendor/k8s.io/klog/v2/go.mod b/vendor/k8s.io/klog/v2/go.mod new file mode 100644 index 0000000000000..f50b2581499b7 --- /dev/null +++ b/vendor/k8s.io/klog/v2/go.mod @@ -0,0 +1,5 @@ +module k8s.io/klog/v2 + +go 1.13 + +require github.com/go-logr/logr v0.1.0 diff --git a/vendor/k8s.io/klog/v2/go.sum b/vendor/k8s.io/klog/v2/go.sum new file mode 100644 index 0000000000000..fb64d277a7afd --- /dev/null +++ b/vendor/k8s.io/klog/v2/go.sum @@ -0,0 +1,2 @@ +github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg= +github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= diff --git a/vendor/k8s.io/klog/v2/klog.go b/vendor/k8s.io/klog/v2/klog.go new file mode 100644 index 0000000000000..c334b14b2df6f --- /dev/null +++ b/vendor/k8s.io/klog/v2/klog.go @@ -0,0 +1,1496 @@ +// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/ +// +// Copyright 2013 Google Inc. All Rights Reserved. +// +// 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 klog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup. +// It provides functions Info, Warning, Error, Fatal, plus formatting variants such as +// Infof. It also provides V-style logging controlled by the -v and -vmodule=file=2 flags. +// +// Basic examples: +// +// klog.Info("Prepare to repel boarders") +// +// klog.Fatalf("Initialization failed: %s", err) +// +// See the documentation for the V function for an explanation of these examples: +// +// if klog.V(2) { +// klog.Info("Starting transaction...") +// } +// +// klog.V(2).Infoln("Processed", nItems, "elements") +// +// Log output is buffered and written periodically using Flush. Programs +// should call Flush before exiting to guarantee all log output is written. +// +// By default, all log statements write to standard error. +// This package provides several flags that modify this behavior. +// As a result, flag.Parse must be called before any logging is done. +// +// -logtostderr=true +// Logs are written to standard error instead of to files. +// -alsologtostderr=false +// Logs are written to standard error as well as to files. +// -stderrthreshold=ERROR +// Log events at or above this severity are logged to standard +// error as well as to files. +// -log_dir="" +// Log files will be written to this directory instead of the +// default temporary directory. +// +// Other flags provide aids to debugging. +// +// -log_backtrace_at="" +// When set to a file and line number holding a logging statement, +// such as +// -log_backtrace_at=gopherflakes.go:234 +// a stack trace will be written to the Info log whenever execution +// hits that statement. (Unlike with -vmodule, the ".go" must be +// present.) +// -v=0 +// Enable V-leveled logging at the specified level. +// -vmodule="" +// The syntax of the argument is a comma-separated list of pattern=N, +// where pattern is a literal file name (minus the ".go" suffix) or +// "glob" pattern and N is a V level. For instance, +// -vmodule=gopher*=3 +// sets the V level to 3 in all Go files whose names begin "gopher". +// +package klog + +import ( + "bufio" + "bytes" + "errors" + "flag" + "fmt" + "io" + stdLog "log" + "math" + "os" + "path/filepath" + "runtime" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" + + "github.com/go-logr/logr" +) + +// severity identifies the sort of log: info, warning etc. It also implements +// the flag.Value interface. The -stderrthreshold flag is of type severity and +// should be modified only through the flag.Value interface. The values match +// the corresponding constants in C++. +type severity int32 // sync/atomic int32 + +// These constants identify the log levels in order of increasing severity. +// A message written to a high-severity log file is also written to each +// lower-severity log file. +const ( + infoLog severity = iota + warningLog + errorLog + fatalLog + numSeverity = 4 +) + +const severityChar = "IWEF" + +var severityName = []string{ + infoLog: "INFO", + warningLog: "WARNING", + errorLog: "ERROR", + fatalLog: "FATAL", +} + +// get returns the value of the severity. +func (s *severity) get() severity { + return severity(atomic.LoadInt32((*int32)(s))) +} + +// set sets the value of the severity. +func (s *severity) set(val severity) { + atomic.StoreInt32((*int32)(s), int32(val)) +} + +// String is part of the flag.Value interface. +func (s *severity) String() string { + return strconv.FormatInt(int64(*s), 10) +} + +// Get is part of the flag.Getter interface. +func (s *severity) Get() interface{} { + return *s +} + +// Set is part of the flag.Value interface. +func (s *severity) Set(value string) error { + var threshold severity + // Is it a known name? + if v, ok := severityByName(value); ok { + threshold = v + } else { + v, err := strconv.ParseInt(value, 10, 32) + if err != nil { + return err + } + threshold = severity(v) + } + logging.stderrThreshold.set(threshold) + return nil +} + +func severityByName(s string) (severity, bool) { + s = strings.ToUpper(s) + for i, name := range severityName { + if name == s { + return severity(i), true + } + } + return 0, false +} + +// OutputStats tracks the number of output lines and bytes written. +type OutputStats struct { + lines int64 + bytes int64 +} + +// Lines returns the number of lines written. +func (s *OutputStats) Lines() int64 { + return atomic.LoadInt64(&s.lines) +} + +// Bytes returns the number of bytes written. +func (s *OutputStats) Bytes() int64 { + return atomic.LoadInt64(&s.bytes) +} + +// Stats tracks the number of lines of output and number of bytes +// per severity level. Values must be read with atomic.LoadInt64. +var Stats struct { + Info, Warning, Error OutputStats +} + +var severityStats = [numSeverity]*OutputStats{ + infoLog: &Stats.Info, + warningLog: &Stats.Warning, + errorLog: &Stats.Error, +} + +// Level is exported because it appears in the arguments to V and is +// the type of the v flag, which can be set programmatically. +// It's a distinct type because we want to discriminate it from logType. +// Variables of type level are only changed under logging.mu. +// The -v flag is read only with atomic ops, so the state of the logging +// module is consistent. + +// Level is treated as a sync/atomic int32. + +// Level specifies a level of verbosity for V logs. *Level implements +// flag.Value; the -v flag is of type Level and should be modified +// only through the flag.Value interface. +type Level int32 + +// get returns the value of the Level. +func (l *Level) get() Level { + return Level(atomic.LoadInt32((*int32)(l))) +} + +// set sets the value of the Level. +func (l *Level) set(val Level) { + atomic.StoreInt32((*int32)(l), int32(val)) +} + +// String is part of the flag.Value interface. +func (l *Level) String() string { + return strconv.FormatInt(int64(*l), 10) +} + +// Get is part of the flag.Getter interface. +func (l *Level) Get() interface{} { + return *l +} + +// Set is part of the flag.Value interface. +func (l *Level) Set(value string) error { + v, err := strconv.ParseInt(value, 10, 32) + if err != nil { + return err + } + logging.mu.Lock() + defer logging.mu.Unlock() + logging.setVState(Level(v), logging.vmodule.filter, false) + return nil +} + +// moduleSpec represents the setting of the -vmodule flag. +type moduleSpec struct { + filter []modulePat +} + +// modulePat contains a filter for the -vmodule flag. +// It holds a verbosity level and a file pattern to match. +type modulePat struct { + pattern string + literal bool // The pattern is a literal string + level Level +} + +// match reports whether the file matches the pattern. It uses a string +// comparison if the pattern contains no metacharacters. +func (m *modulePat) match(file string) bool { + if m.literal { + return file == m.pattern + } + match, _ := filepath.Match(m.pattern, file) + return match +} + +func (m *moduleSpec) String() string { + // Lock because the type is not atomic. TODO: clean this up. + logging.mu.Lock() + defer logging.mu.Unlock() + var b bytes.Buffer + for i, f := range m.filter { + if i > 0 { + b.WriteRune(',') + } + fmt.Fprintf(&b, "%s=%d", f.pattern, f.level) + } + return b.String() +} + +// Get is part of the (Go 1.2) flag.Getter interface. It always returns nil for this flag type since the +// struct is not exported. +func (m *moduleSpec) Get() interface{} { + return nil +} + +var errVmoduleSyntax = errors.New("syntax error: expect comma-separated list of filename=N") + +// Syntax: -vmodule=recordio=2,file=1,gfs*=3 +func (m *moduleSpec) Set(value string) error { + var filter []modulePat + for _, pat := range strings.Split(value, ",") { + if len(pat) == 0 { + // Empty strings such as from a trailing comma can be ignored. + continue + } + patLev := strings.Split(pat, "=") + if len(patLev) != 2 || len(patLev[0]) == 0 || len(patLev[1]) == 0 { + return errVmoduleSyntax + } + pattern := patLev[0] + v, err := strconv.ParseInt(patLev[1], 10, 32) + if err != nil { + return errors.New("syntax error: expect comma-separated list of filename=N") + } + if v < 0 { + return errors.New("negative value for vmodule level") + } + if v == 0 { + continue // Ignore. It's harmless but no point in paying the overhead. + } + // TODO: check syntax of filter? + filter = append(filter, modulePat{pattern, isLiteral(pattern), Level(v)}) + } + logging.mu.Lock() + defer logging.mu.Unlock() + logging.setVState(logging.verbosity, filter, true) + return nil +} + +// isLiteral reports whether the pattern is a literal string, that is, has no metacharacters +// that require filepath.Match to be called to match the pattern. +func isLiteral(pattern string) bool { + return !strings.ContainsAny(pattern, `\*?[]`) +} + +// traceLocation represents the setting of the -log_backtrace_at flag. +type traceLocation struct { + file string + line int +} + +// isSet reports whether the trace location has been specified. +// logging.mu is held. +func (t *traceLocation) isSet() bool { + return t.line > 0 +} + +// match reports whether the specified file and line matches the trace location. +// The argument file name is the full path, not the basename specified in the flag. +// logging.mu is held. +func (t *traceLocation) match(file string, line int) bool { + if t.line != line { + return false + } + if i := strings.LastIndex(file, "/"); i >= 0 { + file = file[i+1:] + } + return t.file == file +} + +func (t *traceLocation) String() string { + // Lock because the type is not atomic. TODO: clean this up. + logging.mu.Lock() + defer logging.mu.Unlock() + return fmt.Sprintf("%s:%d", t.file, t.line) +} + +// Get is part of the (Go 1.2) flag.Getter interface. It always returns nil for this flag type since the +// struct is not exported +func (t *traceLocation) Get() interface{} { + return nil +} + +var errTraceSyntax = errors.New("syntax error: expect file.go:234") + +// Syntax: -log_backtrace_at=gopherflakes.go:234 +// Note that unlike vmodule the file extension is included here. +func (t *traceLocation) Set(value string) error { + if value == "" { + // Unset. + logging.mu.Lock() + defer logging.mu.Unlock() + t.line = 0 + t.file = "" + return nil + } + fields := strings.Split(value, ":") + if len(fields) != 2 { + return errTraceSyntax + } + file, line := fields[0], fields[1] + if !strings.Contains(file, ".") { + return errTraceSyntax + } + v, err := strconv.Atoi(line) + if err != nil { + return errTraceSyntax + } + if v <= 0 { + return errors.New("negative or zero value for level") + } + logging.mu.Lock() + defer logging.mu.Unlock() + t.line = v + t.file = file + return nil +} + +// flushSyncWriter is the interface satisfied by logging destinations. +type flushSyncWriter interface { + Flush() error + Sync() error + io.Writer +} + +// init sets up the defaults and runs flushDaemon. +func init() { + logging.stderrThreshold = errorLog // Default stderrThreshold is ERROR. + logging.setVState(0, nil, false) + logging.logDir = "" + logging.logFile = "" + logging.logFileMaxSizeMB = 1800 + logging.toStderr = true + logging.alsoToStderr = false + logging.skipHeaders = false + logging.addDirHeader = false + logging.skipLogHeaders = false + go logging.flushDaemon() +} + +// InitFlags is for explicitly initializing the flags. +func InitFlags(flagset *flag.FlagSet) { + if flagset == nil { + flagset = flag.CommandLine + } + + flagset.StringVar(&logging.logDir, "log_dir", logging.logDir, "If non-empty, write log files in this directory") + flagset.StringVar(&logging.logFile, "log_file", logging.logFile, "If non-empty, use this log file") + flagset.Uint64Var(&logging.logFileMaxSizeMB, "log_file_max_size", logging.logFileMaxSizeMB, + "Defines the maximum size a log file can grow to. Unit is megabytes. "+ + "If the value is 0, the maximum file size is unlimited.") + flagset.BoolVar(&logging.toStderr, "logtostderr", logging.toStderr, "log to standard error instead of files") + flagset.BoolVar(&logging.alsoToStderr, "alsologtostderr", logging.alsoToStderr, "log to standard error as well as files") + flagset.Var(&logging.verbosity, "v", "number for the log level verbosity") + flagset.BoolVar(&logging.addDirHeader, "add_dir_header", logging.addDirHeader, "If true, adds the file directory to the header of the log messages") + flagset.BoolVar(&logging.skipHeaders, "skip_headers", logging.skipHeaders, "If true, avoid header prefixes in the log messages") + flagset.BoolVar(&logging.skipLogHeaders, "skip_log_headers", logging.skipLogHeaders, "If true, avoid headers when opening log files") + flagset.Var(&logging.stderrThreshold, "stderrthreshold", "logs at or above this threshold go to stderr") + flagset.Var(&logging.vmodule, "vmodule", "comma-separated list of pattern=N settings for file-filtered logging") + flagset.Var(&logging.traceLocation, "log_backtrace_at", "when logging hits line file:N, emit a stack trace") +} + +// Flush flushes all pending log I/O. +func Flush() { + logging.lockAndFlushAll() +} + +// loggingT collects all the global state of the logging setup. +type loggingT struct { + // Boolean flags. Not handled atomically because the flag.Value interface + // does not let us avoid the =true, and that shorthand is necessary for + // compatibility. TODO: does this matter enough to fix? Seems unlikely. + toStderr bool // The -logtostderr flag. + alsoToStderr bool // The -alsologtostderr flag. + + // Level flag. Handled atomically. + stderrThreshold severity // The -stderrthreshold flag. + + // freeList is a list of byte buffers, maintained under freeListMu. + freeList *buffer + // freeListMu maintains the free list. It is separate from the main mutex + // so buffers can be grabbed and printed to without holding the main lock, + // for better parallelization. + freeListMu sync.Mutex + + // mu protects the remaining elements of this structure and is + // used to synchronize logging. + mu sync.Mutex + // file holds writer for each of the log types. + file [numSeverity]flushSyncWriter + // pcs is used in V to avoid an allocation when computing the caller's PC. + pcs [1]uintptr + // vmap is a cache of the V Level for each V() call site, identified by PC. + // It is wiped whenever the vmodule flag changes state. + vmap map[uintptr]Level + // filterLength stores the length of the vmodule filter chain. If greater + // than zero, it means vmodule is enabled. It may be read safely + // using sync.LoadInt32, but is only modified under mu. + filterLength int32 + // traceLocation is the state of the -log_backtrace_at flag. + traceLocation traceLocation + // These flags are modified only under lock, although verbosity may be fetched + // safely using atomic.LoadInt32. + vmodule moduleSpec // The state of the -vmodule flag. + verbosity Level // V logging level, the value of the -v flag/ + + // If non-empty, overrides the choice of directory in which to write logs. + // See createLogDirs for the full list of possible destinations. + logDir string + + // If non-empty, specifies the path of the file to write logs. mutually exclusive + // with the log_dir option. + logFile string + + // When logFile is specified, this limiter makes sure the logFile won't exceeds a certain size. When exceeds, the + // logFile will be cleaned up. If this value is 0, no size limitation will be applied to logFile. + logFileMaxSizeMB uint64 + + // If true, do not add the prefix headers, useful when used with SetOutput + skipHeaders bool + + // If true, do not add the headers to log files + skipLogHeaders bool + + // If true, add the file directory to the header + addDirHeader bool + + // If set, all output will be redirected unconditionally to the provided logr.Logger + logr logr.Logger +} + +// buffer holds a byte Buffer for reuse. The zero value is ready for use. +type buffer struct { + bytes.Buffer + tmp [64]byte // temporary byte array for creating headers. + next *buffer +} + +var logging loggingT + +// setVState sets a consistent state for V logging. +// l.mu is held. +func (l *loggingT) setVState(verbosity Level, filter []modulePat, setFilter bool) { + // Turn verbosity off so V will not fire while we are in transition. + l.verbosity.set(0) + // Ditto for filter length. + atomic.StoreInt32(&l.filterLength, 0) + + // Set the new filters and wipe the pc->Level map if the filter has changed. + if setFilter { + l.vmodule.filter = filter + l.vmap = make(map[uintptr]Level) + } + + // Things are consistent now, so enable filtering and verbosity. + // They are enabled in order opposite to that in V. + atomic.StoreInt32(&l.filterLength, int32(len(filter))) + l.verbosity.set(verbosity) +} + +// getBuffer returns a new, ready-to-use buffer. +func (l *loggingT) getBuffer() *buffer { + l.freeListMu.Lock() + b := l.freeList + if b != nil { + l.freeList = b.next + } + l.freeListMu.Unlock() + if b == nil { + b = new(buffer) + } else { + b.next = nil + b.Reset() + } + return b +} + +// putBuffer returns a buffer to the free list. +func (l *loggingT) putBuffer(b *buffer) { + if b.Len() >= 256 { + // Let big buffers die a natural death. + return + } + l.freeListMu.Lock() + b.next = l.freeList + l.freeList = b + l.freeListMu.Unlock() +} + +var timeNow = time.Now // Stubbed out for testing. + +/* +header formats a log header as defined by the C++ implementation. +It returns a buffer containing the formatted header and the user's file and line number. +The depth specifies how many stack frames above lives the source line to be identified in the log message. + +Log lines have this form: + Lmmdd hh:mm:ss.uuuuuu threadid file:line] msg... +where the fields are defined as follows: + L A single character, representing the log level (eg 'I' for INFO) + mm The month (zero padded; ie May is '05') + dd The day (zero padded) + hh:mm:ss.uuuuuu Time in hours, minutes and fractional seconds + threadid The space-padded thread ID as returned by GetTID() + file The file name + line The line number + msg The user-supplied message +*/ +func (l *loggingT) header(s severity, depth int) (*buffer, string, int) { + _, file, line, ok := runtime.Caller(3 + depth) + if !ok { + file = "???" + line = 1 + } else { + if slash := strings.LastIndex(file, "/"); slash >= 0 { + path := file + file = path[slash+1:] + if l.addDirHeader { + if dirsep := strings.LastIndex(path[:slash], "/"); dirsep >= 0 { + file = path[dirsep+1:] + } + } + } + } + return l.formatHeader(s, file, line), file, line +} + +// formatHeader formats a log header using the provided file name and line number. +func (l *loggingT) formatHeader(s severity, file string, line int) *buffer { + now := timeNow() + if line < 0 { + line = 0 // not a real line number, but acceptable to someDigits + } + if s > fatalLog { + s = infoLog // for safety. + } + buf := l.getBuffer() + if l.skipHeaders { + return buf + } + + // Avoid Fprintf, for speed. The format is so simple that we can do it quickly by hand. + // It's worth about 3X. Fprintf is hard. + _, month, day := now.Date() + hour, minute, second := now.Clock() + // Lmmdd hh:mm:ss.uuuuuu threadid file:line] + buf.tmp[0] = severityChar[s] + buf.twoDigits(1, int(month)) + buf.twoDigits(3, day) + buf.tmp[5] = ' ' + buf.twoDigits(6, hour) + buf.tmp[8] = ':' + buf.twoDigits(9, minute) + buf.tmp[11] = ':' + buf.twoDigits(12, second) + buf.tmp[14] = '.' + buf.nDigits(6, 15, now.Nanosecond()/1000, '0') + buf.tmp[21] = ' ' + buf.nDigits(7, 22, pid, ' ') // TODO: should be TID + buf.tmp[29] = ' ' + buf.Write(buf.tmp[:30]) + buf.WriteString(file) + buf.tmp[0] = ':' + n := buf.someDigits(1, line) + buf.tmp[n+1] = ']' + buf.tmp[n+2] = ' ' + buf.Write(buf.tmp[:n+3]) + return buf +} + +// Some custom tiny helper functions to print the log header efficiently. + +const digits = "0123456789" + +// twoDigits formats a zero-prefixed two-digit integer at buf.tmp[i]. +func (buf *buffer) twoDigits(i, d int) { + buf.tmp[i+1] = digits[d%10] + d /= 10 + buf.tmp[i] = digits[d%10] +} + +// nDigits formats an n-digit integer at buf.tmp[i], +// padding with pad on the left. +// It assumes d >= 0. +func (buf *buffer) nDigits(n, i, d int, pad byte) { + j := n - 1 + for ; j >= 0 && d > 0; j-- { + buf.tmp[i+j] = digits[d%10] + d /= 10 + } + for ; j >= 0; j-- { + buf.tmp[i+j] = pad + } +} + +// someDigits formats a zero-prefixed variable-width integer at buf.tmp[i]. +func (buf *buffer) someDigits(i, d int) int { + // Print into the top, then copy down. We know there's space for at least + // a 10-digit number. + j := len(buf.tmp) + for { + j-- + buf.tmp[j] = digits[d%10] + d /= 10 + if d == 0 { + break + } + } + return copy(buf.tmp[i:], buf.tmp[j:]) +} + +func (l *loggingT) println(s severity, logr logr.InfoLogger, args ...interface{}) { + buf, file, line := l.header(s, 0) + // if logr is set, we clear the generated header as we rely on the backing + // logr implementation to print headers + if logr != nil { + l.putBuffer(buf) + buf = l.getBuffer() + } + fmt.Fprintln(buf, args...) + l.output(s, logr, buf, file, line, false) +} + +func (l *loggingT) print(s severity, logr logr.InfoLogger, args ...interface{}) { + l.printDepth(s, logr, 1, args...) +} + +func (l *loggingT) printDepth(s severity, logr logr.InfoLogger, depth int, args ...interface{}) { + buf, file, line := l.header(s, depth) + // if logr is set, we clear the generated header as we rely on the backing + // logr implementation to print headers + if logr != nil { + l.putBuffer(buf) + buf = l.getBuffer() + } + fmt.Fprint(buf, args...) + if buf.Bytes()[buf.Len()-1] != '\n' { + buf.WriteByte('\n') + } + l.output(s, logr, buf, file, line, false) +} + +func (l *loggingT) printf(s severity, logr logr.InfoLogger, format string, args ...interface{}) { + buf, file, line := l.header(s, 0) + // if logr is set, we clear the generated header as we rely on the backing + // logr implementation to print headers + if logr != nil { + l.putBuffer(buf) + buf = l.getBuffer() + } + fmt.Fprintf(buf, format, args...) + if buf.Bytes()[buf.Len()-1] != '\n' { + buf.WriteByte('\n') + } + l.output(s, logr, buf, file, line, false) +} + +// printWithFileLine behaves like print but uses the provided file and line number. If +// alsoLogToStderr is true, the log message always appears on standard error; it +// will also appear in the log file unless --logtostderr is set. +func (l *loggingT) printWithFileLine(s severity, logr logr.InfoLogger, file string, line int, alsoToStderr bool, args ...interface{}) { + buf := l.formatHeader(s, file, line) + // if logr is set, we clear the generated header as we rely on the backing + // logr implementation to print headers + if logr != nil { + l.putBuffer(buf) + buf = l.getBuffer() + } + fmt.Fprint(buf, args...) + if buf.Bytes()[buf.Len()-1] != '\n' { + buf.WriteByte('\n') + } + l.output(s, logr, buf, file, line, alsoToStderr) +} + +// printS if loggr is specified, no need to output with logging module. If +// err arguments is specified, will call logr.Error, or output to errorLog severity +func (l *loggingT) printS(err error, loggr logr.Logger, msg string, keysAndValues ...interface{}) { + if loggr != nil { + if err != nil { + loggr.Error(err, msg, keysAndValues) + } else { + loggr.Info(msg, keysAndValues) + } + return + } + b := &bytes.Buffer{} + b.WriteString(fmt.Sprintf("%q", msg)) + if err != nil { + b.WriteByte(' ') + b.WriteString(fmt.Sprintf("err=%q", err.Error())) + } + kvListFormat(b, keysAndValues...) + var s severity + if err == nil { + s = infoLog + } else { + s = errorLog + } + l.printDepth(s, logging.logr, 1, b) +} + +const missingValue = "(MISSING)" + +func kvListFormat(b *bytes.Buffer, keysAndValues ...interface{}) { + for i := 0; i < len(keysAndValues); i += 2 { + var v interface{} + k := keysAndValues[i] + if i+1 < len(keysAndValues) { + v = keysAndValues[i+1] + } else { + v = missingValue + } + b.WriteByte(' ') + if _, ok := v.(fmt.Stringer); ok { + b.WriteString(fmt.Sprintf("%s=%q", k, v)) + } else { + b.WriteString(fmt.Sprintf("%s=%#v", k, v)) + } + } +} + +// redirectBuffer is used to set an alternate destination for the logs +type redirectBuffer struct { + w io.Writer +} + +func (rb *redirectBuffer) Sync() error { + return nil +} + +func (rb *redirectBuffer) Flush() error { + return nil +} + +func (rb *redirectBuffer) Write(bytes []byte) (n int, err error) { + return rb.w.Write(bytes) +} + +// SetLogger will set the backing logr implementation for klog. +// If set, all log lines will be suppressed from the regular Output, and +// redirected to the logr implementation. +// All log lines include the 'severity', 'file' and 'line' values attached as +// structured logging values. +// Use as: +// ... +// klog.SetLogger(zapr.NewLogger(zapLog)) +func SetLogger(logr logr.Logger) { + logging.logr = logr +} + +// SetOutput sets the output destination for all severities +func SetOutput(w io.Writer) { + logging.mu.Lock() + defer logging.mu.Unlock() + for s := fatalLog; s >= infoLog; s-- { + rb := &redirectBuffer{ + w: w, + } + logging.file[s] = rb + } +} + +// SetOutputBySeverity sets the output destination for specific severity +func SetOutputBySeverity(name string, w io.Writer) { + logging.mu.Lock() + defer logging.mu.Unlock() + sev, ok := severityByName(name) + if !ok { + panic(fmt.Sprintf("SetOutputBySeverity(%q): unrecognized severity name", name)) + } + rb := &redirectBuffer{ + w: w, + } + logging.file[sev] = rb +} + +// output writes the data to the log files and releases the buffer. +func (l *loggingT) output(s severity, log logr.InfoLogger, buf *buffer, file string, line int, alsoToStderr bool) { + l.mu.Lock() + if l.traceLocation.isSet() { + if l.traceLocation.match(file, line) { + buf.Write(stacks(false)) + } + } + data := buf.Bytes() + if log != nil { + // TODO: set 'severity' and caller information as structured log info + // keysAndValues := []interface{}{"severity", severityName[s], "file", file, "line", line} + if s == errorLog { + l.logr.Error(nil, string(data)) + } else { + log.Info(string(data)) + } + } else if l.toStderr { + os.Stderr.Write(data) + } else { + if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() { + os.Stderr.Write(data) + } + + if logging.logFile != "" { + // Since we are using a single log file, all of the items in l.file array + // will point to the same file, so just use one of them to write data. + if l.file[infoLog] == nil { + if err := l.createFiles(infoLog); err != nil { + os.Stderr.Write(data) // Make sure the message appears somewhere. + l.exit(err) + } + } + l.file[infoLog].Write(data) + } else { + if l.file[s] == nil { + if err := l.createFiles(s); err != nil { + os.Stderr.Write(data) // Make sure the message appears somewhere. + l.exit(err) + } + } + + switch s { + case fatalLog: + l.file[fatalLog].Write(data) + fallthrough + case errorLog: + l.file[errorLog].Write(data) + fallthrough + case warningLog: + l.file[warningLog].Write(data) + fallthrough + case infoLog: + l.file[infoLog].Write(data) + } + } + } + if s == fatalLog { + // If we got here via Exit rather than Fatal, print no stacks. + if atomic.LoadUint32(&fatalNoStacks) > 0 { + l.mu.Unlock() + timeoutFlush(10 * time.Second) + os.Exit(1) + } + // Dump all goroutine stacks before exiting. + trace := stacks(true) + // Write the stack trace for all goroutines to the stderr. + if l.toStderr || l.alsoToStderr || s >= l.stderrThreshold.get() || alsoToStderr { + os.Stderr.Write(trace) + } + // Write the stack trace for all goroutines to the files. + logExitFunc = func(error) {} // If we get a write error, we'll still exit below. + for log := fatalLog; log >= infoLog; log-- { + if f := l.file[log]; f != nil { // Can be nil if -logtostderr is set. + f.Write(trace) + } + } + l.mu.Unlock() + timeoutFlush(10 * time.Second) + os.Exit(255) // C++ uses -1, which is silly because it's anded with 255 anyway. + } + l.putBuffer(buf) + l.mu.Unlock() + if stats := severityStats[s]; stats != nil { + atomic.AddInt64(&stats.lines, 1) + atomic.AddInt64(&stats.bytes, int64(len(data))) + } +} + +// timeoutFlush calls Flush and returns when it completes or after timeout +// elapses, whichever happens first. This is needed because the hooks invoked +// by Flush may deadlock when klog.Fatal is called from a hook that holds +// a lock. +func timeoutFlush(timeout time.Duration) { + done := make(chan bool, 1) + go func() { + Flush() // calls logging.lockAndFlushAll() + done <- true + }() + select { + case <-done: + case <-time.After(timeout): + fmt.Fprintln(os.Stderr, "klog: Flush took longer than", timeout) + } +} + +// stacks is a wrapper for runtime.Stack that attempts to recover the data for all goroutines. +func stacks(all bool) []byte { + // We don't know how big the traces are, so grow a few times if they don't fit. Start large, though. + n := 10000 + if all { + n = 100000 + } + var trace []byte + for i := 0; i < 5; i++ { + trace = make([]byte, n) + nbytes := runtime.Stack(trace, all) + if nbytes < len(trace) { + return trace[:nbytes] + } + n *= 2 + } + return trace +} + +// logExitFunc provides a simple mechanism to override the default behavior +// of exiting on error. Used in testing and to guarantee we reach a required exit +// for fatal logs. Instead, exit could be a function rather than a method but that +// would make its use clumsier. +var logExitFunc func(error) + +// exit is called if there is trouble creating or writing log files. +// It flushes the logs and exits the program; there's no point in hanging around. +// l.mu is held. +func (l *loggingT) exit(err error) { + fmt.Fprintf(os.Stderr, "log: exiting because of error: %s\n", err) + // If logExitFunc is set, we do that instead of exiting. + if logExitFunc != nil { + logExitFunc(err) + return + } + l.flushAll() + os.Exit(2) +} + +// syncBuffer joins a bufio.Writer to its underlying file, providing access to the +// file's Sync method and providing a wrapper for the Write method that provides log +// file rotation. There are conflicting methods, so the file cannot be embedded. +// l.mu is held for all its methods. +type syncBuffer struct { + logger *loggingT + *bufio.Writer + file *os.File + sev severity + nbytes uint64 // The number of bytes written to this file + maxbytes uint64 // The max number of bytes this syncBuffer.file can hold before cleaning up. +} + +func (sb *syncBuffer) Sync() error { + return sb.file.Sync() +} + +// CalculateMaxSize returns the real max size in bytes after considering the default max size and the flag options. +func CalculateMaxSize() uint64 { + if logging.logFile != "" { + if logging.logFileMaxSizeMB == 0 { + // If logFileMaxSizeMB is zero, we don't have limitations on the log size. + return math.MaxUint64 + } + // Flag logFileMaxSizeMB is in MB for user convenience. + return logging.logFileMaxSizeMB * 1024 * 1024 + } + // If "log_file" flag is not specified, the target file (sb.file) will be cleaned up when reaches a fixed size. + return MaxSize +} + +func (sb *syncBuffer) Write(p []byte) (n int, err error) { + if sb.nbytes+uint64(len(p)) >= sb.maxbytes { + if err := sb.rotateFile(time.Now(), false); err != nil { + sb.logger.exit(err) + } + } + n, err = sb.Writer.Write(p) + sb.nbytes += uint64(n) + if err != nil { + sb.logger.exit(err) + } + return +} + +// rotateFile closes the syncBuffer's file and starts a new one. +// The startup argument indicates whether this is the initial startup of klog. +// If startup is true, existing files are opened for appending instead of truncated. +func (sb *syncBuffer) rotateFile(now time.Time, startup bool) error { + if sb.file != nil { + sb.Flush() + sb.file.Close() + } + var err error + sb.file, _, err = create(severityName[sb.sev], now, startup) + sb.nbytes = 0 + if err != nil { + return err + } + + sb.Writer = bufio.NewWriterSize(sb.file, bufferSize) + + if sb.logger.skipLogHeaders { + return nil + } + + // Write header. + var buf bytes.Buffer + fmt.Fprintf(&buf, "Log file created at: %s\n", now.Format("2006/01/02 15:04:05")) + fmt.Fprintf(&buf, "Running on machine: %s\n", host) + fmt.Fprintf(&buf, "Binary: Built with %s %s for %s/%s\n", runtime.Compiler, runtime.Version(), runtime.GOOS, runtime.GOARCH) + fmt.Fprintf(&buf, "Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg\n") + n, err := sb.file.Write(buf.Bytes()) + sb.nbytes += uint64(n) + return err +} + +// bufferSize sizes the buffer associated with each log file. It's large +// so that log records can accumulate without the logging thread blocking +// on disk I/O. The flushDaemon will block instead. +const bufferSize = 256 * 1024 + +// createFiles creates all the log files for severity from sev down to infoLog. +// l.mu is held. +func (l *loggingT) createFiles(sev severity) error { + now := time.Now() + // Files are created in decreasing severity order, so as soon as we find one + // has already been created, we can stop. + for s := sev; s >= infoLog && l.file[s] == nil; s-- { + sb := &syncBuffer{ + logger: l, + sev: s, + maxbytes: CalculateMaxSize(), + } + if err := sb.rotateFile(now, true); err != nil { + return err + } + l.file[s] = sb + } + return nil +} + +const flushInterval = 5 * time.Second + +// flushDaemon periodically flushes the log file buffers. +func (l *loggingT) flushDaemon() { + for range time.NewTicker(flushInterval).C { + l.lockAndFlushAll() + } +} + +// lockAndFlushAll is like flushAll but locks l.mu first. +func (l *loggingT) lockAndFlushAll() { + l.mu.Lock() + l.flushAll() + l.mu.Unlock() +} + +// flushAll flushes all the logs and attempts to "sync" their data to disk. +// l.mu is held. +func (l *loggingT) flushAll() { + // Flush from fatal down, in case there's trouble flushing. + for s := fatalLog; s >= infoLog; s-- { + file := l.file[s] + if file != nil { + file.Flush() // ignore error + file.Sync() // ignore error + } + } +} + +// CopyStandardLogTo arranges for messages written to the Go "log" package's +// default logs to also appear in the Google logs for the named and lower +// severities. Subsequent changes to the standard log's default output location +// or format may break this behavior. +// +// Valid names are "INFO", "WARNING", "ERROR", and "FATAL". If the name is not +// recognized, CopyStandardLogTo panics. +func CopyStandardLogTo(name string) { + sev, ok := severityByName(name) + if !ok { + panic(fmt.Sprintf("log.CopyStandardLogTo(%q): unrecognized severity name", name)) + } + // Set a log format that captures the user's file and line: + // d.go:23: message + stdLog.SetFlags(stdLog.Lshortfile) + stdLog.SetOutput(logBridge(sev)) +} + +// logBridge provides the Write method that enables CopyStandardLogTo to connect +// Go's standard logs to the logs provided by this package. +type logBridge severity + +// Write parses the standard logging line and passes its components to the +// logger for severity(lb). +func (lb logBridge) Write(b []byte) (n int, err error) { + var ( + file = "???" + line = 1 + text string + ) + // Split "d.go:23: message" into "d.go", "23", and "message". + if parts := bytes.SplitN(b, []byte{':'}, 3); len(parts) != 3 || len(parts[0]) < 1 || len(parts[2]) < 1 { + text = fmt.Sprintf("bad log format: %s", b) + } else { + file = string(parts[0]) + text = string(parts[2][1:]) // skip leading space + line, err = strconv.Atoi(string(parts[1])) + if err != nil { + text = fmt.Sprintf("bad line number: %s", b) + line = 1 + } + } + // printWithFileLine with alsoToStderr=true, so standard log messages + // always appear on standard error. + logging.printWithFileLine(severity(lb), logging.logr, file, line, true, text) + return len(b), nil +} + +// setV computes and remembers the V level for a given PC +// when vmodule is enabled. +// File pattern matching takes the basename of the file, stripped +// of its .go suffix, and uses filepath.Match, which is a little more +// general than the *? matching used in C++. +// l.mu is held. +func (l *loggingT) setV(pc uintptr) Level { + fn := runtime.FuncForPC(pc) + file, _ := fn.FileLine(pc) + // The file is something like /a/b/c/d.go. We want just the d. + if strings.HasSuffix(file, ".go") { + file = file[:len(file)-3] + } + if slash := strings.LastIndex(file, "/"); slash >= 0 { + file = file[slash+1:] + } + for _, filter := range l.vmodule.filter { + if filter.match(file) { + l.vmap[pc] = filter.level + return filter.level + } + } + l.vmap[pc] = 0 + return 0 +} + +// Verbose is a boolean type that implements Infof (like Printf) etc. +// See the documentation of V for more information. +type Verbose struct { + enabled bool + logr logr.InfoLogger +} + +func newVerbose(level Level, b bool) Verbose { + if logging.logr == nil { + return Verbose{b, nil} + } + return Verbose{b, logging.logr.V(int(level))} +} + +// V reports whether verbosity at the call site is at least the requested level. +// The returned value is a struct of type Verbose, which implements Info, Infoln +// and Infof. These methods will write to the Info log if called. +// Thus, one may write either +// if glog.V(2).Enabled() { klog.Info("log this") } +// or +// klog.V(2).Info("log this") +// The second form is shorter but the first is cheaper if logging is off because it does +// not evaluate its arguments. +// +// Whether an individual call to V generates a log record depends on the setting of +// the -v and --vmodule flags; both are off by default. If the level in the call to +// V is at least the value of -v, or of -vmodule for the source file containing the +// call, the V call will log. +func V(level Level) Verbose { + // This function tries hard to be cheap unless there's work to do. + // The fast path is two atomic loads and compares. + + // Here is a cheap but safe test to see if V logging is enabled globally. + if logging.verbosity.get() >= level { + return newVerbose(level, true) + } + + // It's off globally but it vmodule may still be set. + // Here is another cheap but safe test to see if vmodule is enabled. + if atomic.LoadInt32(&logging.filterLength) > 0 { + // Now we need a proper lock to use the logging structure. The pcs field + // is shared so we must lock before accessing it. This is fairly expensive, + // but if V logging is enabled we're slow anyway. + logging.mu.Lock() + defer logging.mu.Unlock() + if runtime.Callers(2, logging.pcs[:]) == 0 { + return newVerbose(level, false) + } + v, ok := logging.vmap[logging.pcs[0]] + if !ok { + v = logging.setV(logging.pcs[0]) + } + return newVerbose(level, v >= level) + } + return newVerbose(level, false) +} + +// Enabled will return true if this log level is enabled, guarded by the value +// of v. +// See the documentation of V for usage. +func (v Verbose) Enabled() bool { + return v.enabled +} + +// Info is equivalent to the global Info function, guarded by the value of v. +// See the documentation of V for usage. +func (v Verbose) Info(args ...interface{}) { + if v.enabled { + logging.print(infoLog, v.logr, args...) + } +} + +// Infoln is equivalent to the global Infoln function, guarded by the value of v. +// See the documentation of V for usage. +func (v Verbose) Infoln(args ...interface{}) { + if v.enabled { + logging.println(infoLog, v.logr, args...) + } +} + +// Infof is equivalent to the global Infof function, guarded by the value of v. +// See the documentation of V for usage. +func (v Verbose) Infof(format string, args ...interface{}) { + if v.enabled { + logging.printf(infoLog, v.logr, format, args...) + } +} + +// InfoS is equivalent to the global InfoS function, guarded by the value of v. +// See the documentation of V for usage. +func (v Verbose) InfoS(msg string, keysAndValues ...interface{}) { + if v.enabled { + if v.logr != nil { + v.logr.Info(msg, keysAndValues) + return + } + logging.printS(nil, nil, msg, keysAndValues...) + } +} + +// Info logs to the INFO log. +// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. +func Info(args ...interface{}) { + logging.print(infoLog, logging.logr, args...) +} + +// InfoDepth acts as Info but uses depth to determine which call frame to log. +// InfoDepth(0, "msg") is the same as Info("msg"). +func InfoDepth(depth int, args ...interface{}) { + logging.printDepth(infoLog, logging.logr, depth, args...) +} + +// Infoln logs to the INFO log. +// Arguments are handled in the manner of fmt.Println; a newline is always appended. +func Infoln(args ...interface{}) { + logging.println(infoLog, logging.logr, args...) +} + +// Infof logs to the INFO log. +// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. +func Infof(format string, args ...interface{}) { + logging.printf(infoLog, logging.logr, format, args...) +} + +// InfoS structured logs to the INFO log. +// The msg argument used to add constant description to the log line. +// The key/value pairs would be join by "=" ; a newline is always appended. +// +// Basic examples: +// >> klog.InfoS("Pod status updated", "pod", "kubedns", "status", "ready") +// output: +// >> I1025 00:15:15.525108 1 controller_utils.go:116] "Pod status updated" pod="kubedns" status="ready" +func InfoS(msg string, keysAndValues ...interface{}) { + logging.printS(nil, logging.logr, msg, keysAndValues...) +} + +// Warning logs to the WARNING and INFO logs. +// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. +func Warning(args ...interface{}) { + logging.print(warningLog, logging.logr, args...) +} + +// WarningDepth acts as Warning but uses depth to determine which call frame to log. +// WarningDepth(0, "msg") is the same as Warning("msg"). +func WarningDepth(depth int, args ...interface{}) { + logging.printDepth(warningLog, logging.logr, depth, args...) +} + +// Warningln logs to the WARNING and INFO logs. +// Arguments are handled in the manner of fmt.Println; a newline is always appended. +func Warningln(args ...interface{}) { + logging.println(warningLog, logging.logr, args...) +} + +// Warningf logs to the WARNING and INFO logs. +// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. +func Warningf(format string, args ...interface{}) { + logging.printf(warningLog, logging.logr, format, args...) +} + +// Error logs to the ERROR, WARNING, and INFO logs. +// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. +func Error(args ...interface{}) { + logging.print(errorLog, logging.logr, args...) +} + +// ErrorDepth acts as Error but uses depth to determine which call frame to log. +// ErrorDepth(0, "msg") is the same as Error("msg"). +func ErrorDepth(depth int, args ...interface{}) { + logging.printDepth(errorLog, logging.logr, depth, args...) +} + +// Errorln logs to the ERROR, WARNING, and INFO logs. +// Arguments are handled in the manner of fmt.Println; a newline is always appended. +func Errorln(args ...interface{}) { + logging.println(errorLog, logging.logr, args...) +} + +// Errorf logs to the ERROR, WARNING, and INFO logs. +// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. +func Errorf(format string, args ...interface{}) { + logging.printf(errorLog, logging.logr, format, args...) +} + +// ErrorS structured logs to the ERROR, WARNING, and INFO logs. +// the err argument used as "err" field of log line. +// The msg argument used to add constant description to the log line. +// The key/value pairs would be join by "=" ; a newline is always appended. +// +// Basic examples: +// >> klog.ErrorS(err, "Failed to update pod status") +// output: +// >> E1025 00:15:15.525108 1 controller_utils.go:114] "Failed to update pod status" err="timeout" +func ErrorS(err error, msg string, keysAndValues ...interface{}) { + logging.printS(err, logging.logr, msg, keysAndValues...) +} + +// Fatal logs to the FATAL, ERROR, WARNING, and INFO logs, +// including a stack trace of all running goroutines, then calls os.Exit(255). +// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. +func Fatal(args ...interface{}) { + logging.print(fatalLog, logging.logr, args...) +} + +// FatalDepth acts as Fatal but uses depth to determine which call frame to log. +// FatalDepth(0, "msg") is the same as Fatal("msg"). +func FatalDepth(depth int, args ...interface{}) { + logging.printDepth(fatalLog, logging.logr, depth, args...) +} + +// Fatalln logs to the FATAL, ERROR, WARNING, and INFO logs, +// including a stack trace of all running goroutines, then calls os.Exit(255). +// Arguments are handled in the manner of fmt.Println; a newline is always appended. +func Fatalln(args ...interface{}) { + logging.println(fatalLog, logging.logr, args...) +} + +// Fatalf logs to the FATAL, ERROR, WARNING, and INFO logs, +// including a stack trace of all running goroutines, then calls os.Exit(255). +// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. +func Fatalf(format string, args ...interface{}) { + logging.printf(fatalLog, logging.logr, format, args...) +} + +// fatalNoStacks is non-zero if we are to exit without dumping goroutine stacks. +// It allows Exit and relatives to use the Fatal logs. +var fatalNoStacks uint32 + +// Exit logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). +// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. +func Exit(args ...interface{}) { + atomic.StoreUint32(&fatalNoStacks, 1) + logging.print(fatalLog, logging.logr, args...) +} + +// ExitDepth acts as Exit but uses depth to determine which call frame to log. +// ExitDepth(0, "msg") is the same as Exit("msg"). +func ExitDepth(depth int, args ...interface{}) { + atomic.StoreUint32(&fatalNoStacks, 1) + logging.printDepth(fatalLog, logging.logr, depth, args...) +} + +// Exitln logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). +func Exitln(args ...interface{}) { + atomic.StoreUint32(&fatalNoStacks, 1) + logging.println(fatalLog, logging.logr, args...) +} + +// Exitf logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). +// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. +func Exitf(format string, args ...interface{}) { + atomic.StoreUint32(&fatalNoStacks, 1) + logging.printf(fatalLog, logging.logr, format, args...) +} + +// ObjectRef references a kubernetes object +type ObjectRef struct { + Name string `json:"name"` + Namespace string `json:"namespace,omitempty"` +} + +func (ref ObjectRef) String() string { + if ref.Namespace != "" { + return fmt.Sprintf("%s/%s", ref.Namespace, ref.Name) + } + return ref.Name +} + +// KMetadata is a subset of the kubernetes k8s.io/apimachinery/pkg/apis/meta/v1.Object interface +// this interface may expand in the future, but will always be a subset of the +// kubernetes k8s.io/apimachinery/pkg/apis/meta/v1.Object interface +type KMetadata interface { + GetName() string + GetNamespace() string +} + +// KObj returns ObjectRef from ObjectMeta +func KObj(obj KMetadata) ObjectRef { + return ObjectRef{ + Name: obj.GetName(), + Namespace: obj.GetNamespace(), + } +} + +// KRef returns ObjectRef from name and namespace +func KRef(namespace, name string) ObjectRef { + return ObjectRef{ + Name: name, + Namespace: namespace, + } +} diff --git a/vendor/k8s.io/klog/v2/klog_file.go b/vendor/k8s.io/klog/v2/klog_file.go new file mode 100644 index 0000000000000..458456a4a5704 --- /dev/null +++ b/vendor/k8s.io/klog/v2/klog_file.go @@ -0,0 +1,158 @@ +// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/ +// +// Copyright 2013 Google Inc. All Rights Reserved. +// +// 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. + +// File I/O for logs. + +package klog + +import ( + "errors" + "fmt" + "os" + "os/user" + "path/filepath" + "runtime" + "strings" + "sync" + "time" +) + +// MaxSize is the maximum size of a log file in bytes. +var MaxSize uint64 = 1024 * 1024 * 1800 + +// logDirs lists the candidate directories for new log files. +var logDirs []string + +func createLogDirs() { + if logging.logDir != "" { + logDirs = append(logDirs, logging.logDir) + } + logDirs = append(logDirs, os.TempDir()) +} + +var ( + pid = os.Getpid() + program = filepath.Base(os.Args[0]) + host = "unknownhost" + userName = "unknownuser" +) + +func init() { + h, err := os.Hostname() + if err == nil { + host = shortHostname(h) + } + + // On Windows, the Go 'user' package requires netapi32.dll. + // This affects Windows Nano Server: + // https://github.com/golang/go/issues/21867 + // Fallback to using environment variables. + if runtime.GOOS == "windows" { + u := os.Getenv("USERNAME") + if len(u) == 0 { + return + } + // Sanitize the USERNAME since it may contain filepath separators. + u = strings.Replace(u, `\`, "_", -1) + + // user.Current().Username normally produces something like 'USERDOMAIN\USERNAME' + d := os.Getenv("USERDOMAIN") + if len(d) != 0 { + userName = d + "_" + u + } else { + userName = u + } + } else { + current, err := user.Current() + if err == nil { + userName = current.Username + } + } +} + +// shortHostname returns its argument, truncating at the first period. +// For instance, given "www.google.com" it returns "www". +func shortHostname(hostname string) string { + if i := strings.Index(hostname, "."); i >= 0 { + return hostname[:i] + } + return hostname +} + +// logName returns a new log file name containing tag, with start time t, and +// the name for the symlink for tag. +func logName(tag string, t time.Time) (name, link string) { + name = fmt.Sprintf("%s.%s.%s.log.%s.%04d%02d%02d-%02d%02d%02d.%d", + program, + host, + userName, + tag, + t.Year(), + t.Month(), + t.Day(), + t.Hour(), + t.Minute(), + t.Second(), + pid) + return name, program + "." + tag +} + +var onceLogDirs sync.Once + +// create creates a new log file and returns the file and its filename, which +// contains tag ("INFO", "FATAL", etc.) and t. If the file is created +// successfully, create also attempts to update the symlink for that tag, ignoring +// errors. +// The startup argument indicates whether this is the initial startup of klog. +// If startup is true, existing files are opened for appending instead of truncated. +func create(tag string, t time.Time, startup bool) (f *os.File, filename string, err error) { + if logging.logFile != "" { + f, err := openOrCreate(logging.logFile, startup) + if err == nil { + return f, logging.logFile, nil + } + return nil, "", fmt.Errorf("log: unable to create log: %v", err) + } + onceLogDirs.Do(createLogDirs) + if len(logDirs) == 0 { + return nil, "", errors.New("log: no log dirs") + } + name, link := logName(tag, t) + var lastErr error + for _, dir := range logDirs { + fname := filepath.Join(dir, name) + f, err := openOrCreate(fname, startup) + if err == nil { + symlink := filepath.Join(dir, link) + os.Remove(symlink) // ignore err + os.Symlink(name, symlink) // ignore err + return f, fname, nil + } + lastErr = err + } + return nil, "", fmt.Errorf("log: cannot create log: %v", lastErr) +} + +// The startup argument indicates whether this is the initial startup of klog. +// If startup is true, existing files are opened for appending instead of truncated. +func openOrCreate(name string, startup bool) (*os.File, error) { + if startup { + f, err := os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) + return f, err + } + f, err := os.Create(name) + return f, err +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 2abc42958c9f2..1c03bc331abd9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -275,7 +275,7 @@ github.com/golang/protobuf/ptypes/timestamp github.com/golang/snappy # github.com/google/btree v1.0.0 github.com/google/btree -# github.com/google/go-cmp v0.3.1 +# github.com/google/go-cmp v0.4.0 github.com/google/go-cmp/cmp github.com/google/go-cmp/cmp/internal/diff github.com/google/go-cmp/cmp/internal/flags @@ -655,6 +655,7 @@ golang.org/x/tools/go/packages golang.org/x/tools/go/types/objectpath golang.org/x/tools/go/types/typeutil golang.org/x/tools/go/vcs +golang.org/x/tools/imports golang.org/x/tools/internal/analysisinternal golang.org/x/tools/internal/event golang.org/x/tools/internal/event/core @@ -1164,6 +1165,13 @@ k8s.io/component-base/metrics/prometheus/restclient k8s.io/component-base/version # k8s.io/csi-translation-lib v0.18.1 => k8s.io/csi-translation-lib v0.18.1 k8s.io/csi-translation-lib/plugins +# k8s.io/gengo v0.0.0-20200710205751-c0d492a0f3ca +## explicit +k8s.io/gengo/args +k8s.io/gengo/generator +k8s.io/gengo/namer +k8s.io/gengo/parser +k8s.io/gengo/types # k8s.io/helm v2.9.0+incompatible ## explicit k8s.io/helm/pkg/strvals @@ -1171,6 +1179,9 @@ k8s.io/helm/pkg/strvals ## explicit k8s.io/klog k8s.io/klog/klogr +# k8s.io/klog/v2 v2.0.0 +## explicit +k8s.io/klog/v2 # k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c k8s.io/kube-openapi/pkg/common k8s.io/kube-openapi/pkg/util/proto From f72dac180d8c386ddbe54a103cf4d07a71022c79 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Sun, 26 Jul 2020 22:26:47 -0700 Subject: [PATCH 4/8] Switch to new fitasks marker --- upup/pkg/fi/assettasks/copydockerimage.go | 2 +- upup/pkg/fi/assettasks/copyfile.go | 2 +- upup/pkg/fi/cloudup/alitasks/disk.go | 4 ++-- upup/pkg/fi/cloudup/alitasks/eip_natgateway_association.go | 2 +- upup/pkg/fi/cloudup/alitasks/launchconfiguration.go | 3 +-- upup/pkg/fi/cloudup/alitasks/loadbalancer.go | 3 +-- upup/pkg/fi/cloudup/alitasks/loadbalancerlistener.go | 2 +- upup/pkg/fi/cloudup/alitasks/natgateway.go | 2 +- upup/pkg/fi/cloudup/alitasks/rampolicy.go | 3 +-- upup/pkg/fi/cloudup/alitasks/ramrole.go | 3 +-- upup/pkg/fi/cloudup/alitasks/scalinggroup.go | 3 +-- upup/pkg/fi/cloudup/alitasks/securitygroup.go | 2 +- upup/pkg/fi/cloudup/alitasks/securitygrouprule.go | 3 +-- upup/pkg/fi/cloudup/alitasks/sshkey.go | 2 +- upup/pkg/fi/cloudup/alitasks/vpc.go | 2 +- upup/pkg/fi/cloudup/alitasks/vswitch.go | 2 +- upup/pkg/fi/cloudup/alitasks/vswitchSNAT.go | 2 +- upup/pkg/fi/cloudup/awstasks/dhcp_options.go | 2 +- upup/pkg/fi/cloudup/awstasks/dnsname.go | 2 +- upup/pkg/fi/cloudup/awstasks/dnszone.go | 2 +- upup/pkg/fi/cloudup/awstasks/ebsvolume.go | 2 +- upup/pkg/fi/cloudup/awstasks/elastic_ip.go | 3 +-- .../fi/cloudup/awstasks/external_load_balancer_attachment.go | 2 +- .../fi/cloudup/awstasks/external_target_group_attachment.go | 2 +- upup/pkg/fi/cloudup/awstasks/iaminstanceprofile.go | 2 +- upup/pkg/fi/cloudup/awstasks/iaminstanceprofilerole.go | 2 +- upup/pkg/fi/cloudup/awstasks/iamoidcprovider.go | 2 +- upup/pkg/fi/cloudup/awstasks/iamrole.go | 2 +- upup/pkg/fi/cloudup/awstasks/iamrolepolicy.go | 2 +- upup/pkg/fi/cloudup/awstasks/internetgateway.go | 2 +- upup/pkg/fi/cloudup/awstasks/load_balancer.go | 2 +- upup/pkg/fi/cloudup/awstasks/load_balancer_attachment.go | 2 +- upup/pkg/fi/cloudup/awstasks/natgateway.go | 2 +- upup/pkg/fi/cloudup/awstasks/route.go | 2 +- upup/pkg/fi/cloudup/awstasks/routetable.go | 2 +- upup/pkg/fi/cloudup/awstasks/routetableassociation.go | 2 +- upup/pkg/fi/cloudup/awstasks/securitygroup.go | 2 +- upup/pkg/fi/cloudup/awstasks/securitygrouprule.go | 2 +- upup/pkg/fi/cloudup/awstasks/sshkey.go | 2 +- upup/pkg/fi/cloudup/awstasks/subnet.go | 2 +- upup/pkg/fi/cloudup/awstasks/vpc.go | 2 +- upup/pkg/fi/cloudup/awstasks/vpc_dhcpoptions_association.go | 2 +- upup/pkg/fi/cloudup/awstasks/vpccidrblock.go | 2 +- upup/pkg/fi/cloudup/dotasks/droplet.go | 2 +- upup/pkg/fi/cloudup/dotasks/loadbalancer.go | 2 +- upup/pkg/fi/cloudup/dotasks/volume.go | 2 +- upup/pkg/fi/cloudup/gcetasks/address.go | 2 +- upup/pkg/fi/cloudup/gcetasks/disk.go | 2 +- upup/pkg/fi/cloudup/gcetasks/firewallrule.go | 2 +- upup/pkg/fi/cloudup/gcetasks/forwardingrule.go | 2 +- upup/pkg/fi/cloudup/gcetasks/instance.go | 2 +- upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go | 2 +- upup/pkg/fi/cloudup/gcetasks/instancetemplate.go | 2 +- upup/pkg/fi/cloudup/gcetasks/network.go | 2 +- upup/pkg/fi/cloudup/gcetasks/storagebucketacl.go | 2 +- upup/pkg/fi/cloudup/gcetasks/storagebucketiam.go | 2 +- upup/pkg/fi/cloudup/gcetasks/storageobjectacl.go | 2 +- upup/pkg/fi/cloudup/gcetasks/subnet.go | 2 +- upup/pkg/fi/cloudup/gcetasks/targetpool.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/floatingip.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/instance.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/lb.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/lblistener.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/lbpool.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/network.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/poolassociation.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/port.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/router.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/routerinterface.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/securitygroup.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/servergroup.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/sshkey.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/subnet.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/volume.go | 2 +- upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go | 2 +- upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go | 2 +- upup/pkg/fi/cloudup/spotinsttasks/ocean.go | 2 +- upup/pkg/fi/fitasks/keypair.go | 2 +- upup/pkg/fi/fitasks/managedfile.go | 2 +- upup/pkg/fi/fitasks/mirrorkeystore.go | 2 +- upup/pkg/fi/fitasks/mirrorsecrets.go | 2 +- upup/pkg/fi/fitasks/secret.go | 2 +- 82 files changed, 83 insertions(+), 90 deletions(-) diff --git a/upup/pkg/fi/assettasks/copydockerimage.go b/upup/pkg/fi/assettasks/copydockerimage.go index 9fe81323af014..94837011cde96 100644 --- a/upup/pkg/fi/assettasks/copydockerimage.go +++ b/upup/pkg/fi/assettasks/copydockerimage.go @@ -25,7 +25,7 @@ import ( // CopyDockerImage copies a docker image from a source registry, to a target registry, // typically used for highly secure clusters. -//go:generate fitask -type=CopyDockerImage +// +kops:fitask type CopyDockerImage struct { Name *string SourceImage *string diff --git a/upup/pkg/fi/assettasks/copyfile.go b/upup/pkg/fi/assettasks/copyfile.go index 0b8ea1986e0eb..035c51b596409 100644 --- a/upup/pkg/fi/assettasks/copyfile.go +++ b/upup/pkg/fi/assettasks/copyfile.go @@ -32,7 +32,7 @@ import ( // CopyFile copies an from a source file repository, to a target repository, // typically used for highly secure clusters. -//go:generate fitask -type=CopyFile +// +kops:fitask type CopyFile struct { Name *string SourceFile *string diff --git a/upup/pkg/fi/cloudup/alitasks/disk.go b/upup/pkg/fi/cloudup/alitasks/disk.go index edfb7a13f5709..231cdb0ba54b9 100644 --- a/upup/pkg/fi/cloudup/alitasks/disk.go +++ b/upup/pkg/fi/cloudup/alitasks/disk.go @@ -28,13 +28,13 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -// Disk represents a ALI Cloud Disk -//go:generate fitask -type=Disk const ( DiskResource = "disk" DiskType = ecs.DiskTypeAllData ) +// Disk represents an ALI Cloud Disk. +// +kops:fitask type Disk struct { Lifecycle *fi.Lifecycle Name *string diff --git a/upup/pkg/fi/cloudup/alitasks/eip_natgateway_association.go b/upup/pkg/fi/cloudup/alitasks/eip_natgateway_association.go index d7593fc6c3aa4..bbe8511d17eca 100644 --- a/upup/pkg/fi/cloudup/alitasks/eip_natgateway_association.go +++ b/upup/pkg/fi/cloudup/alitasks/eip_natgateway_association.go @@ -31,7 +31,7 @@ const ( NatType = "Nat" ) -//go:generate fitask -type=EIP +// +kops:fitask type EIP struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/alitasks/launchconfiguration.go b/upup/pkg/fi/cloudup/alitasks/launchconfiguration.go index 5ae9fea6801f5..c1bc1bc7e4704 100644 --- a/upup/pkg/fi/cloudup/alitasks/launchconfiguration.go +++ b/upup/pkg/fi/cloudup/alitasks/launchconfiguration.go @@ -36,8 +36,6 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=LaunchConfiguration - const dateFormat = "2006-01-02T15:04Z" // defaultRetainLaunchConfigurationCount is the number of launch configurations (matching the name prefix) that we should @@ -53,6 +51,7 @@ func RetainLaunchConfigurationCount() int { } // LaunchConfiguration is the specification for a launch configuration +// +kops:fitask type LaunchConfiguration struct { Lifecycle *fi.Lifecycle ID *string diff --git a/upup/pkg/fi/cloudup/alitasks/loadbalancer.go b/upup/pkg/fi/cloudup/alitasks/loadbalancer.go index acafe82881cf9..e6a19f695db3b 100644 --- a/upup/pkg/fi/cloudup/alitasks/loadbalancer.go +++ b/upup/pkg/fi/cloudup/alitasks/loadbalancer.go @@ -30,8 +30,7 @@ import ( ) // LoadBalancer represents a ALI Cloud LoadBalancer -//go:generate fitask -type=LoadBalancer - +// +kops:fitask type LoadBalancer struct { Name *string LoadbalancerId *string diff --git a/upup/pkg/fi/cloudup/alitasks/loadbalancerlistener.go b/upup/pkg/fi/cloudup/alitasks/loadbalancerlistener.go index 3dd869559828e..3e20cb37d278a 100644 --- a/upup/pkg/fi/cloudup/alitasks/loadbalancerlistener.go +++ b/upup/pkg/fi/cloudup/alitasks/loadbalancerlistener.go @@ -30,7 +30,7 @@ import ( const ListenerRunningStatus = "running" -//go:generate fitask -type=LoadBalancerListener +// +kops:fitask type LoadBalancerListener struct { LoadBalancer *LoadBalancer Name *string diff --git a/upup/pkg/fi/cloudup/alitasks/natgateway.go b/upup/pkg/fi/cloudup/alitasks/natgateway.go index 5a52b6166e638..cc92065a4a52a 100644 --- a/upup/pkg/fi/cloudup/alitasks/natgateway.go +++ b/upup/pkg/fi/cloudup/alitasks/natgateway.go @@ -27,7 +27,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=NatGateway +// +kops:fitask type NatGateway struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/alitasks/rampolicy.go b/upup/pkg/fi/cloudup/alitasks/rampolicy.go index df9f16a46e896..0835202aa3400 100644 --- a/upup/pkg/fi/cloudup/alitasks/rampolicy.go +++ b/upup/pkg/fi/cloudup/alitasks/rampolicy.go @@ -29,8 +29,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=RAMPolicy - +// +kops:fitask type RAMPolicy struct { Lifecycle *fi.Lifecycle Name *string diff --git a/upup/pkg/fi/cloudup/alitasks/ramrole.go b/upup/pkg/fi/cloudup/alitasks/ramrole.go index 7565055fd3fba..fa60576624253 100644 --- a/upup/pkg/fi/cloudup/alitasks/ramrole.go +++ b/upup/pkg/fi/cloudup/alitasks/ramrole.go @@ -29,8 +29,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=RAMRole - +// +kops:fitask type RAMRole struct { ID *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/alitasks/scalinggroup.go b/upup/pkg/fi/cloudup/alitasks/scalinggroup.go index 7d8acc5b8e317..028c40c91dd06 100644 --- a/upup/pkg/fi/cloudup/alitasks/scalinggroup.go +++ b/upup/pkg/fi/cloudup/alitasks/scalinggroup.go @@ -30,8 +30,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=ScalingGroup - +// +kops:fitask type ScalingGroup struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/alitasks/securitygroup.go b/upup/pkg/fi/cloudup/alitasks/securitygroup.go index b1f744f10eacc..0aa0d629e6d51 100644 --- a/upup/pkg/fi/cloudup/alitasks/securitygroup.go +++ b/upup/pkg/fi/cloudup/alitasks/securitygroup.go @@ -29,9 +29,9 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=SecurityGroup const SecurityResource = "securitygroup" +// +kops:fitask type SecurityGroup struct { Name *string SecurityGroupId *string diff --git a/upup/pkg/fi/cloudup/alitasks/securitygrouprule.go b/upup/pkg/fi/cloudup/alitasks/securitygrouprule.go index b197bbd3802ba..046bea7335bdc 100644 --- a/upup/pkg/fi/cloudup/alitasks/securitygrouprule.go +++ b/upup/pkg/fi/cloudup/alitasks/securitygrouprule.go @@ -29,8 +29,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=SecurityGroupRule - +// +kops:fitask type SecurityGroupRule struct { Name *string IpProtocol *string diff --git a/upup/pkg/fi/cloudup/alitasks/sshkey.go b/upup/pkg/fi/cloudup/alitasks/sshkey.go index c7c0b5672fa20..e3332b64a8edc 100644 --- a/upup/pkg/fi/cloudup/alitasks/sshkey.go +++ b/upup/pkg/fi/cloudup/alitasks/sshkey.go @@ -30,7 +30,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=SSHKey +// +kops:fitask type SSHKey struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/alitasks/vpc.go b/upup/pkg/fi/cloudup/alitasks/vpc.go index 387c22875b328..847fe1caa9be7 100644 --- a/upup/pkg/fi/cloudup/alitasks/vpc.go +++ b/upup/pkg/fi/cloudup/alitasks/vpc.go @@ -27,7 +27,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=VPC +// +kops:fitask type VPC struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/alitasks/vswitch.go b/upup/pkg/fi/cloudup/alitasks/vswitch.go index 9471a804374bc..a3bc16dfff016 100644 --- a/upup/pkg/fi/cloudup/alitasks/vswitch.go +++ b/upup/pkg/fi/cloudup/alitasks/vswitch.go @@ -28,7 +28,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=VSwitch +// +kops:fitask type VSwitch struct { Name *string VSwitchId *string diff --git a/upup/pkg/fi/cloudup/alitasks/vswitchSNAT.go b/upup/pkg/fi/cloudup/alitasks/vswitchSNAT.go index e783bf2412b2f..8db86fb6ae543 100644 --- a/upup/pkg/fi/cloudup/alitasks/vswitchSNAT.go +++ b/upup/pkg/fi/cloudup/alitasks/vswitchSNAT.go @@ -28,7 +28,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=VSwitchSNAT +// +kops:fitask type VSwitchSNAT struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/dhcp_options.go b/upup/pkg/fi/cloudup/awstasks/dhcp_options.go index b15378d4b33a3..0ab4bb4f5aa9d 100644 --- a/upup/pkg/fi/cloudup/awstasks/dhcp_options.go +++ b/upup/pkg/fi/cloudup/awstasks/dhcp_options.go @@ -30,7 +30,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=DHCPOptions +// +kops:fitask type DHCPOptions struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/dnsname.go b/upup/pkg/fi/cloudup/awstasks/dnsname.go index a7995e69de30f..eef3e0208ec6e 100644 --- a/upup/pkg/fi/cloudup/awstasks/dnsname.go +++ b/upup/pkg/fi/cloudup/awstasks/dnsname.go @@ -30,7 +30,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=DNSName +// +kops:fitask type DNSName struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/dnszone.go b/upup/pkg/fi/cloudup/awstasks/dnszone.go index 00416857800ab..715e5bd4e9337 100644 --- a/upup/pkg/fi/cloudup/awstasks/dnszone.go +++ b/upup/pkg/fi/cloudup/awstasks/dnszone.go @@ -34,7 +34,7 @@ import ( ) // DNSZone is a zone object in a dns provider -//go:generate fitask -type=DNSZone +// +kops:fitask type DNSZone struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/ebsvolume.go b/upup/pkg/fi/cloudup/awstasks/ebsvolume.go index 450d2aa0b304c..ab988da5acd2f 100644 --- a/upup/pkg/fi/cloudup/awstasks/ebsvolume.go +++ b/upup/pkg/fi/cloudup/awstasks/ebsvolume.go @@ -28,7 +28,7 @@ import ( "k8s.io/klog" ) -//go:generate fitask -type=EBSVolume +// +kops:fitask type EBSVolume struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/elastic_ip.go b/upup/pkg/fi/cloudup/awstasks/elastic_ip.go index 56ae839cfaedd..90e1f65c5e33f 100644 --- a/upup/pkg/fi/cloudup/awstasks/elastic_ip.go +++ b/upup/pkg/fi/cloudup/awstasks/elastic_ip.go @@ -29,9 +29,8 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=ElasticIP - // ElasticIP manages an AWS Address (ElasticIP) +// +kops:fitask type ElasticIP struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/external_load_balancer_attachment.go b/upup/pkg/fi/cloudup/awstasks/external_load_balancer_attachment.go index ec8dfc2639788..ad78a29ff6305 100644 --- a/upup/pkg/fi/cloudup/awstasks/external_load_balancer_attachment.go +++ b/upup/pkg/fi/cloudup/awstasks/external_load_balancer_attachment.go @@ -28,7 +28,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=ExternalLoadBalancerAttachment +// +kops:fitask type ExternalLoadBalancerAttachment struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/external_target_group_attachment.go b/upup/pkg/fi/cloudup/awstasks/external_target_group_attachment.go index 088fda6c5af13..aa3efb2a53e15 100644 --- a/upup/pkg/fi/cloudup/awstasks/external_target_group_attachment.go +++ b/upup/pkg/fi/cloudup/awstasks/external_target_group_attachment.go @@ -29,7 +29,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=ExternalTargetGroupAttachment +// +kops:fitask type ExternalTargetGroupAttachment struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/iaminstanceprofile.go b/upup/pkg/fi/cloudup/awstasks/iaminstanceprofile.go index 2af9b2f4882b7..9badd59cdc55f 100644 --- a/upup/pkg/fi/cloudup/awstasks/iaminstanceprofile.go +++ b/upup/pkg/fi/cloudup/awstasks/iaminstanceprofile.go @@ -31,7 +31,7 @@ import ( "k8s.io/klog" ) -//go:generate fitask -type=IAMInstanceProfile +// +kops:fitask type IAMInstanceProfile struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/iaminstanceprofilerole.go b/upup/pkg/fi/cloudup/awstasks/iaminstanceprofilerole.go index dc91ea08f629c..19c71b8a8b016 100644 --- a/upup/pkg/fi/cloudup/awstasks/iaminstanceprofilerole.go +++ b/upup/pkg/fi/cloudup/awstasks/iaminstanceprofilerole.go @@ -29,7 +29,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=IAMInstanceProfileRole +// +kops:fitask type IAMInstanceProfileRole struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/iamoidcprovider.go b/upup/pkg/fi/cloudup/awstasks/iamoidcprovider.go index 8a62550403fcd..879eba3e97684 100644 --- a/upup/pkg/fi/cloudup/awstasks/iamoidcprovider.go +++ b/upup/pkg/fi/cloudup/awstasks/iamoidcprovider.go @@ -29,7 +29,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=IAMOIDCProvider +// +kops:fitask type IAMOIDCProvider struct { Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/iamrole.go b/upup/pkg/fi/cloudup/awstasks/iamrole.go index a2b36e29ddf14..f2d01714f14e3 100644 --- a/upup/pkg/fi/cloudup/awstasks/iamrole.go +++ b/upup/pkg/fi/cloudup/awstasks/iamrole.go @@ -35,7 +35,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=IAMRole +// +kops:fitask type IAMRole struct { ID *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/iamrolepolicy.go b/upup/pkg/fi/cloudup/awstasks/iamrolepolicy.go index 6d597cd8a0368..837a220ce77f2 100644 --- a/upup/pkg/fi/cloudup/awstasks/iamrolepolicy.go +++ b/upup/pkg/fi/cloudup/awstasks/iamrolepolicy.go @@ -34,7 +34,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=IAMRolePolicy +// +kops:fitask type IAMRolePolicy struct { ID *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/internetgateway.go b/upup/pkg/fi/cloudup/awstasks/internetgateway.go index dddcc813ee9c2..828629cf84285 100644 --- a/upup/pkg/fi/cloudup/awstasks/internetgateway.go +++ b/upup/pkg/fi/cloudup/awstasks/internetgateway.go @@ -27,7 +27,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=InternetGateway +// +kops:fitask type InternetGateway struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/load_balancer.go b/upup/pkg/fi/cloudup/awstasks/load_balancer.go index 32dd88b02b77e..d443c18e6fb97 100644 --- a/upup/pkg/fi/cloudup/awstasks/load_balancer.go +++ b/upup/pkg/fi/cloudup/awstasks/load_balancer.go @@ -36,7 +36,7 @@ import ( // LoadBalancer manages an ELB. We find the existing ELB using the Name tag. -//go:generate fitask -type=LoadBalancer +// +kops:fitask type LoadBalancer struct { // We use the Name tag to find the existing ELB, because we are (more or less) unrestricted when // it comes to tag values, but the LoadBalancerName is length limited diff --git a/upup/pkg/fi/cloudup/awstasks/load_balancer_attachment.go b/upup/pkg/fi/cloudup/awstasks/load_balancer_attachment.go index ad610e5500069..8edefa3b3118e 100644 --- a/upup/pkg/fi/cloudup/awstasks/load_balancer_attachment.go +++ b/upup/pkg/fi/cloudup/awstasks/load_balancer_attachment.go @@ -29,7 +29,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=LoadBalancerAttachment +// +kops:fitask type LoadBalancerAttachment struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/natgateway.go b/upup/pkg/fi/cloudup/awstasks/natgateway.go index ec1b708b7d100..4dabf98294661 100644 --- a/upup/pkg/fi/cloudup/awstasks/natgateway.go +++ b/upup/pkg/fi/cloudup/awstasks/natgateway.go @@ -29,7 +29,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=NatGateway +// +kops:fitask type NatGateway struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/route.go b/upup/pkg/fi/cloudup/awstasks/route.go index fe6fa2f93f4c7..bdeec2822cc05 100644 --- a/upup/pkg/fi/cloudup/awstasks/route.go +++ b/upup/pkg/fi/cloudup/awstasks/route.go @@ -28,7 +28,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=Route +// +kops:fitask type Route struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/routetable.go b/upup/pkg/fi/cloudup/awstasks/routetable.go index 04c248b618028..0f4db5b589701 100644 --- a/upup/pkg/fi/cloudup/awstasks/routetable.go +++ b/upup/pkg/fi/cloudup/awstasks/routetable.go @@ -28,7 +28,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=RouteTable +// +kops:fitask type RouteTable struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/routetableassociation.go b/upup/pkg/fi/cloudup/awstasks/routetableassociation.go index 061f178047bec..45101badde858 100644 --- a/upup/pkg/fi/cloudup/awstasks/routetableassociation.go +++ b/upup/pkg/fi/cloudup/awstasks/routetableassociation.go @@ -28,7 +28,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=RouteTableAssociation +// +kops:fitask type RouteTableAssociation struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/securitygroup.go b/upup/pkg/fi/cloudup/awstasks/securitygroup.go index bf52b18132c9b..beedba37fa434 100644 --- a/upup/pkg/fi/cloudup/awstasks/securitygroup.go +++ b/upup/pkg/fi/cloudup/awstasks/securitygroup.go @@ -30,7 +30,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=SecurityGroup +// +kops:fitask type SecurityGroup struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/securitygrouprule.go b/upup/pkg/fi/cloudup/awstasks/securitygrouprule.go index 5cfa895b724a8..44c76557935db 100644 --- a/upup/pkg/fi/cloudup/awstasks/securitygrouprule.go +++ b/upup/pkg/fi/cloudup/awstasks/securitygrouprule.go @@ -31,7 +31,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=SecurityGroupRule +// +kops:fitask type SecurityGroupRule struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/sshkey.go b/upup/pkg/fi/cloudup/awstasks/sshkey.go index 4bb78c697d4b9..393fe0a8694a6 100644 --- a/upup/pkg/fi/cloudup/awstasks/sshkey.go +++ b/upup/pkg/fi/cloudup/awstasks/sshkey.go @@ -31,7 +31,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=SSHKey +// +kops:fitask type SSHKey struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/subnet.go b/upup/pkg/fi/cloudup/awstasks/subnet.go index 55a087e785003..8c6377d4e3c1f 100644 --- a/upup/pkg/fi/cloudup/awstasks/subnet.go +++ b/upup/pkg/fi/cloudup/awstasks/subnet.go @@ -29,7 +29,7 @@ import ( "k8s.io/kops/upup/pkg/fi/utils" ) -//go:generate fitask -type=Subnet +// +kops:fitask type Subnet struct { Name *string diff --git a/upup/pkg/fi/cloudup/awstasks/vpc.go b/upup/pkg/fi/cloudup/awstasks/vpc.go index 222014b353fd9..a5eb495ecd01e 100644 --- a/upup/pkg/fi/cloudup/awstasks/vpc.go +++ b/upup/pkg/fi/cloudup/awstasks/vpc.go @@ -30,7 +30,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=VPC +// +kops:fitask type VPC struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/vpc_dhcpoptions_association.go b/upup/pkg/fi/cloudup/awstasks/vpc_dhcpoptions_association.go index 0e8767f82c1a8..606e06340dc12 100644 --- a/upup/pkg/fi/cloudup/awstasks/vpc_dhcpoptions_association.go +++ b/upup/pkg/fi/cloudup/awstasks/vpc_dhcpoptions_association.go @@ -27,7 +27,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=VPCDHCPOptionsAssociation +// +kops:fitask type VPCDHCPOptionsAssociation struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/vpccidrblock.go b/upup/pkg/fi/cloudup/awstasks/vpccidrblock.go index 9ec84c31f4c29..37b35e01aa92b 100644 --- a/upup/pkg/fi/cloudup/awstasks/vpccidrblock.go +++ b/upup/pkg/fi/cloudup/awstasks/vpccidrblock.go @@ -26,7 +26,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=VPCCIDRBlock +// +kops:fitask type VPCCIDRBlock struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/dotasks/droplet.go b/upup/pkg/fi/cloudup/dotasks/droplet.go index 1e667b6b50074..fc04f92c0055d 100644 --- a/upup/pkg/fi/cloudup/dotasks/droplet.go +++ b/upup/pkg/fi/cloudup/dotasks/droplet.go @@ -29,9 +29,9 @@ import ( _ "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=Droplet // Droplet represents a group of droplets. In the future it // will be managed by the Machines API +// +kops:fitask type Droplet struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/dotasks/loadbalancer.go b/upup/pkg/fi/cloudup/dotasks/loadbalancer.go index 94353c810f055..12f91c4c1d914 100644 --- a/upup/pkg/fi/cloudup/dotasks/loadbalancer.go +++ b/upup/pkg/fi/cloudup/dotasks/loadbalancer.go @@ -32,7 +32,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/do" ) -//go:generate fitask -type=LoadBalancer +// +kops:fitask type LoadBalancer struct { Name *string ID *string diff --git a/upup/pkg/fi/cloudup/dotasks/volume.go b/upup/pkg/fi/cloudup/dotasks/volume.go index a15575f2c2f8f..da6ab7240696c 100644 --- a/upup/pkg/fi/cloudup/dotasks/volume.go +++ b/upup/pkg/fi/cloudup/dotasks/volume.go @@ -29,7 +29,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=Volume +// +kops:fitask type Volume struct { Name *string ID *string diff --git a/upup/pkg/fi/cloudup/gcetasks/address.go b/upup/pkg/fi/cloudup/gcetasks/address.go index 593dea1c3300f..69661d38007cc 100644 --- a/upup/pkg/fi/cloudup/gcetasks/address.go +++ b/upup/pkg/fi/cloudup/gcetasks/address.go @@ -26,7 +26,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=Address +// +kops:fitask type Address struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/gcetasks/disk.go b/upup/pkg/fi/cloudup/gcetasks/disk.go index 8dc21cc306cf5..d3eb2c7bd99e8 100644 --- a/upup/pkg/fi/cloudup/gcetasks/disk.go +++ b/upup/pkg/fi/cloudup/gcetasks/disk.go @@ -28,7 +28,7 @@ import ( ) // Disk represents a GCE PD -//go:generate fitask -type=Disk +// +kops:fitask type Disk struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/gcetasks/firewallrule.go b/upup/pkg/fi/cloudup/gcetasks/firewallrule.go index 12a18f7efdceb..23826c35305ed 100644 --- a/upup/pkg/fi/cloudup/gcetasks/firewallrule.go +++ b/upup/pkg/fi/cloudup/gcetasks/firewallrule.go @@ -27,7 +27,7 @@ import ( ) // FirewallRule represents a GCE firewall rules -//go:generate fitask -type=FirewallRule +// +kops:fitask type FirewallRule struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/gcetasks/forwardingrule.go b/upup/pkg/fi/cloudup/gcetasks/forwardingrule.go index ea58737c549fd..e90e727418233 100644 --- a/upup/pkg/fi/cloudup/gcetasks/forwardingrule.go +++ b/upup/pkg/fi/cloudup/gcetasks/forwardingrule.go @@ -27,7 +27,7 @@ import ( ) // ForwardingRule represents a GCE ForwardingRule -//go:generate fitask -type=ForwardingRule +// +kops:fitask type ForwardingRule struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/gcetasks/instance.go b/upup/pkg/fi/cloudup/gcetasks/instance.go index 802c7b42b7622..7e3b28869ae1e 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instance.go +++ b/upup/pkg/fi/cloudup/gcetasks/instance.go @@ -30,7 +30,7 @@ import ( var scopeAliases map[string]string -//go:generate fitask -type=Instance +// +kops:fitask type Instance struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go b/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go index d93906f767f8d..28f6037e03347 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go +++ b/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go @@ -26,7 +26,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=InstanceGroupManager +// +kops:fitask type InstanceGroupManager struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go b/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go index 1143cbe2e384a..eb81a73cd8f5c 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go +++ b/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go @@ -36,7 +36,7 @@ import ( const InstanceTemplateNamePrefixMaxLength = 32 // InstanceTemplate represents a GCE InstanceTemplate -//go:generate fitask -type=InstanceTemplate +// +kops:fitask type InstanceTemplate struct { Name *string diff --git a/upup/pkg/fi/cloudup/gcetasks/network.go b/upup/pkg/fi/cloudup/gcetasks/network.go index 96c6ad17df322..3f611e0aaa0e3 100644 --- a/upup/pkg/fi/cloudup/gcetasks/network.go +++ b/upup/pkg/fi/cloudup/gcetasks/network.go @@ -27,7 +27,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=Network +// +kops:fitask type Network struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/gcetasks/storagebucketacl.go b/upup/pkg/fi/cloudup/gcetasks/storagebucketacl.go index 3362ee08b6897..71233321a9fbe 100644 --- a/upup/pkg/fi/cloudup/gcetasks/storagebucketacl.go +++ b/upup/pkg/fi/cloudup/gcetasks/storagebucketacl.go @@ -27,7 +27,7 @@ import ( ) // StorageBucketAcl represents an ACL rule on a google cloud storage bucket -//go:generate fitask -type=StorageBucketAcl +// +kops:fitask type StorageBucketAcl struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/gcetasks/storagebucketiam.go b/upup/pkg/fi/cloudup/gcetasks/storagebucketiam.go index 90b733379cc2b..def3a25fc6d19 100644 --- a/upup/pkg/fi/cloudup/gcetasks/storagebucketiam.go +++ b/upup/pkg/fi/cloudup/gcetasks/storagebucketiam.go @@ -27,7 +27,7 @@ import ( ) // StorageBucketIam represents an IAM policy on a google cloud storage bucket -//go:generate fitask -type=StorageBucketIam +// +kops:fitask type StorageBucketIam struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/gcetasks/storageobjectacl.go b/upup/pkg/fi/cloudup/gcetasks/storageobjectacl.go index 829d07f072502..472cbdfc2f10c 100644 --- a/upup/pkg/fi/cloudup/gcetasks/storageobjectacl.go +++ b/upup/pkg/fi/cloudup/gcetasks/storageobjectacl.go @@ -27,7 +27,7 @@ import ( ) // StorageObjectAcl represents an ACL rule on a google cloud storage object -//go:generate fitask -type=StorageObjectAcl +// +kops:fitask type StorageObjectAcl struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/gcetasks/subnet.go b/upup/pkg/fi/cloudup/gcetasks/subnet.go index d0a720c38be10..8fb81f70234c3 100644 --- a/upup/pkg/fi/cloudup/gcetasks/subnet.go +++ b/upup/pkg/fi/cloudup/gcetasks/subnet.go @@ -27,7 +27,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=Subnet +// +kops:fitask type Subnet struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/gcetasks/targetpool.go b/upup/pkg/fi/cloudup/gcetasks/targetpool.go index 0fc3b8f96d7e6..f55631eb8286d 100644 --- a/upup/pkg/fi/cloudup/gcetasks/targetpool.go +++ b/upup/pkg/fi/cloudup/gcetasks/targetpool.go @@ -27,7 +27,7 @@ import ( ) // TargetPool represents a GCE TargetPool -//go:generate fitask -type=TargetPool +// +kops:fitask type TargetPool struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/openstacktasks/floatingip.go b/upup/pkg/fi/cloudup/openstacktasks/floatingip.go index 2e33aaa0f230a..3d11177f1bb43 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/floatingip.go +++ b/upup/pkg/fi/cloudup/openstacktasks/floatingip.go @@ -28,7 +28,7 @@ import ( "k8s.io/kops/util/pkg/vfs" ) -//go:generate fitask -type=FloatingIP +// +kops:fitask type FloatingIP struct { Name *string ID *string diff --git a/upup/pkg/fi/cloudup/openstacktasks/instance.go b/upup/pkg/fi/cloudup/openstacktasks/instance.go index 60c1d32088b73..8578386bbb639 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/instance.go +++ b/upup/pkg/fi/cloudup/openstacktasks/instance.go @@ -30,7 +30,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) -//go:generate fitask -type=Instance +// +kops:fitask type Instance struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/openstacktasks/lb.go b/upup/pkg/fi/cloudup/openstacktasks/lb.go index 232abe0df0613..67379d650831a 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/lb.go +++ b/upup/pkg/fi/cloudup/openstacktasks/lb.go @@ -31,7 +31,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) -//go:generate fitask -type=LB +// +kops:fitask type LB struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/openstacktasks/lblistener.go b/upup/pkg/fi/cloudup/openstacktasks/lblistener.go index f577cd4b22379..74372749da646 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/lblistener.go +++ b/upup/pkg/fi/cloudup/openstacktasks/lblistener.go @@ -27,7 +27,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) -//go:generate fitask -type=LBListener +// +kops:fitask type LBListener struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/openstacktasks/lbpool.go b/upup/pkg/fi/cloudup/openstacktasks/lbpool.go index cba651660b4c7..84db970260761 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/lbpool.go +++ b/upup/pkg/fi/cloudup/openstacktasks/lbpool.go @@ -25,7 +25,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) -//go:generate fitask -type=LBPool +// +kops:fitask type LBPool struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/openstacktasks/network.go b/upup/pkg/fi/cloudup/openstacktasks/network.go index 9a6e2fc5ac65e..a13ab07473b24 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/network.go +++ b/upup/pkg/fi/cloudup/openstacktasks/network.go @@ -25,7 +25,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) -//go:generate fitask -type=Network +// +kops:fitask type Network struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/openstacktasks/poolassociation.go b/upup/pkg/fi/cloudup/openstacktasks/poolassociation.go index e388068b2bbb5..44df6ef063488 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/poolassociation.go +++ b/upup/pkg/fi/cloudup/openstacktasks/poolassociation.go @@ -29,7 +29,7 @@ import ( "k8s.io/kops/util/pkg/vfs" ) -//go:generate fitask -type=PoolAssociation +// +kops:fitask type PoolAssociation struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/openstacktasks/port.go b/upup/pkg/fi/cloudup/openstacktasks/port.go index fa935fb88ff53..0b0751d3579ae 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/port.go +++ b/upup/pkg/fi/cloudup/openstacktasks/port.go @@ -26,7 +26,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) -//go:generate fitask -type=Port +// +kops:fitask type Port struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/openstacktasks/router.go b/upup/pkg/fi/cloudup/openstacktasks/router.go index 1ab2780f12050..34de6f1d44cce 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/router.go +++ b/upup/pkg/fi/cloudup/openstacktasks/router.go @@ -25,7 +25,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) -//go:generate fitask -type=Router +// +kops:fitask type Router struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/openstacktasks/routerinterface.go b/upup/pkg/fi/cloudup/openstacktasks/routerinterface.go index ffb54ecc168ba..9213f746fcd55 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/routerinterface.go +++ b/upup/pkg/fi/cloudup/openstacktasks/routerinterface.go @@ -26,7 +26,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) -//go:generate fitask -type=RouterInterface +// +kops:fitask type RouterInterface struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/openstacktasks/securitygroup.go b/upup/pkg/fi/cloudup/openstacktasks/securitygroup.go index dec4b34dc48f6..117b30d4a8cf5 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/securitygroup.go +++ b/upup/pkg/fi/cloudup/openstacktasks/securitygroup.go @@ -28,7 +28,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) -//go:generate fitask -type=SecurityGroup +// +kops:fitask type SecurityGroup struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/openstacktasks/servergroup.go b/upup/pkg/fi/cloudup/openstacktasks/servergroup.go index 2d00d1c3160fb..c2cc874f4a31b 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/servergroup.go +++ b/upup/pkg/fi/cloudup/openstacktasks/servergroup.go @@ -27,7 +27,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) -//go:generate fitask -type=ServerGroup +// +kops:fitask type ServerGroup struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/openstacktasks/sshkey.go b/upup/pkg/fi/cloudup/openstacktasks/sshkey.go index 09c33a7637a38..f8921a8127532 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/sshkey.go +++ b/upup/pkg/fi/cloudup/openstacktasks/sshkey.go @@ -28,7 +28,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) -//go:generate fitask -type=SSHKey +// +kops:fitask type SSHKey struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/openstacktasks/subnet.go b/upup/pkg/fi/cloudup/openstacktasks/subnet.go index 266b1486b7c19..d140235db0cff 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/subnet.go +++ b/upup/pkg/fi/cloudup/openstacktasks/subnet.go @@ -26,7 +26,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) -//go:generate fitask -type=Subnet +// +kops:fitask type Subnet struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/openstacktasks/volume.go b/upup/pkg/fi/cloudup/openstacktasks/volume.go index 26c573b78a0e8..40147d55b337f 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/volume.go +++ b/upup/pkg/fi/cloudup/openstacktasks/volume.go @@ -25,7 +25,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) -//go:generate fitask -type=Volume +// +kops:fitask type Volume struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go b/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go index 0a56c6f77cb39..d9a7822ca8626 100644 --- a/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go +++ b/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go @@ -39,7 +39,7 @@ import ( "k8s.io/kops/upup/pkg/fi/utils" ) -//go:generate fitask -type=Elastigroup +// +kops:fitask type Elastigroup struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go b/upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go index 260a4e62d45b5..ad47ac6faf5b5 100644 --- a/upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go +++ b/upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go @@ -34,7 +34,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=LaunchSpec +// +kops:fitask type LaunchSpec struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/spotinsttasks/ocean.go b/upup/pkg/fi/cloudup/spotinsttasks/ocean.go index 0007ec382a628..7f9b1c61f030b 100644 --- a/upup/pkg/fi/cloudup/spotinsttasks/ocean.go +++ b/upup/pkg/fi/cloudup/spotinsttasks/ocean.go @@ -36,7 +36,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) -//go:generate fitask -type=Ocean +// +kops:fitask type Ocean struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/fitasks/keypair.go b/upup/pkg/fi/fitasks/keypair.go index 65a3b2082dc8f..26153ef07e361 100644 --- a/upup/pkg/fi/fitasks/keypair.go +++ b/upup/pkg/fi/fitasks/keypair.go @@ -28,7 +28,7 @@ import ( "k8s.io/kops/upup/pkg/fi" ) -//go:generate fitask -type=Keypair +// +kops:fitask type Keypair struct { // Name is the name of the keypair Name *string diff --git a/upup/pkg/fi/fitasks/managedfile.go b/upup/pkg/fi/fitasks/managedfile.go index 03928f29fd04e..c22ca78e6bced 100644 --- a/upup/pkg/fi/fitasks/managedfile.go +++ b/upup/pkg/fi/fitasks/managedfile.go @@ -27,7 +27,7 @@ import ( "k8s.io/kops/util/pkg/vfs" ) -//go:generate fitask -type=ManagedFile +// +kops:fitask type ManagedFile struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/fitasks/mirrorkeystore.go b/upup/pkg/fi/fitasks/mirrorkeystore.go index bc0da51ad1f2d..dd634ca85726f 100644 --- a/upup/pkg/fi/fitasks/mirrorkeystore.go +++ b/upup/pkg/fi/fitasks/mirrorkeystore.go @@ -22,7 +22,7 @@ import ( "k8s.io/kops/util/pkg/vfs" ) -//go:generate fitask -type=MirrorKeystore +// +kops:fitask type MirrorKeystore struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/fitasks/mirrorsecrets.go b/upup/pkg/fi/fitasks/mirrorsecrets.go index 976ffb349c3cf..2a1c1f578431e 100644 --- a/upup/pkg/fi/fitasks/mirrorsecrets.go +++ b/upup/pkg/fi/fitasks/mirrorsecrets.go @@ -23,7 +23,7 @@ import ( "k8s.io/kops/util/pkg/vfs" ) -//go:generate fitask -type=MirrorSecrets +// +kops:fitask type MirrorSecrets struct { Name *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/fitasks/secret.go b/upup/pkg/fi/fitasks/secret.go index 6b1bd11c37bcf..6ffe73dfa8514 100644 --- a/upup/pkg/fi/fitasks/secret.go +++ b/upup/pkg/fi/fitasks/secret.go @@ -22,7 +22,7 @@ import ( "k8s.io/kops/upup/pkg/fi" ) -//go:generate fitask -type=Secret +// +kops:fitask type Secret struct { Name *string Lifecycle *fi.Lifecycle From 63cb1a16ab704564770730fe06611f82b79ecc4c Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Sun, 26 Jul 2020 23:03:48 -0700 Subject: [PATCH 5/8] make codegen --- upup/pkg/fi/assettasks/copydockerimage_fitask.go | 6 ++++-- upup/pkg/fi/assettasks/copyfile_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/disk_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/eip_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/launchconfiguration_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/loadbalancer_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/loadbalancerlistener_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/natgateway_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/rampolicy_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/ramrole_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/scalinggroup_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/securitygroup_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/securitygrouprule_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/sshkey_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/vpc_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/vswitch_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/alitasks/vswitchsnat_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/dhcpoptions_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/dnsname_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/dnszone_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/ebsvolume_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/elasticip_fitask.go | 6 ++++-- .../awstasks/externalloadbalancerattachment_fitask.go | 6 ++++-- .../awstasks/externaltargetgroupattachment_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/iaminstanceprofile_fitask.go | 6 ++++-- .../fi/cloudup/awstasks/iaminstanceprofilerole_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/iamoidcprovider_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/iamrole_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/iamrolepolicy_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/internetgateway_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/loadbalancer_fitask.go | 6 ++++-- .../fi/cloudup/awstasks/loadbalancerattachment_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/natgateway_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/route_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/routetable_fitask.go | 6 ++++-- .../pkg/fi/cloudup/awstasks/routetableassociation_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/securitygroup_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/securitygrouprule_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/sshkey_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/subnet_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/vpc_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/vpccidrblock_fitask.go | 6 ++++-- .../fi/cloudup/awstasks/vpcdhcpoptionsassociation_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/dotasks/droplet_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/dotasks/loadbalancer_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/dotasks/volume_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/gcetasks/address_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/gcetasks/disk_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/gcetasks/firewallrule_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/gcetasks/forwardingrule_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/gcetasks/instance_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/gcetasks/instancegroupmanager_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/gcetasks/instancetemplate_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/gcetasks/network_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/gcetasks/storagebucketacl_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/gcetasks/storagebucketiam_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/gcetasks/storageobjectacl_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/gcetasks/subnet_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/gcetasks/targetpool_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/openstacktasks/floatingip_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/openstacktasks/instance_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/openstacktasks/lb_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/openstacktasks/lblistener_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/openstacktasks/lbpool_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/openstacktasks/network_fitask.go | 6 ++++-- .../pkg/fi/cloudup/openstacktasks/poolassociation_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/openstacktasks/port_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/openstacktasks/router_fitask.go | 6 ++++-- .../pkg/fi/cloudup/openstacktasks/routerinterface_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/openstacktasks/securitygroup_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/openstacktasks/servergroup_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/openstacktasks/sshkey_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/openstacktasks/subnet_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/openstacktasks/volume_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/spotinsttasks/BUILD.bazel | 2 +- upup/pkg/fi/cloudup/spotinsttasks/elastigroup_fitask.go | 6 ++++-- .../{launch_spec_fitask.go => launchspec_fitask.go} | 6 ++++-- upup/pkg/fi/cloudup/spotinsttasks/ocean_fitask.go | 6 ++++-- upup/pkg/fi/fitasks/keypair_fitask.go | 6 ++++-- upup/pkg/fi/fitasks/managedfile_fitask.go | 6 ++++-- upup/pkg/fi/fitasks/mirrorkeystore_fitask.go | 6 ++++-- upup/pkg/fi/fitasks/mirrorsecrets_fitask.go | 6 ++++-- upup/pkg/fi/fitasks/secret_fitask.go | 6 ++++-- 83 files changed, 329 insertions(+), 165 deletions(-) rename upup/pkg/fi/cloudup/spotinsttasks/{launch_spec_fitask.go => launchspec_fitask.go} (94%) diff --git a/upup/pkg/fi/assettasks/copydockerimage_fitask.go b/upup/pkg/fi/assettasks/copydockerimage_fitask.go index 4407441b178d3..28d907c8425f5 100644 --- a/upup/pkg/fi/assettasks/copydockerimage_fitask.go +++ b/upup/pkg/fi/assettasks/copydockerimage_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=CopyDockerImage"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package assettasks diff --git a/upup/pkg/fi/assettasks/copyfile_fitask.go b/upup/pkg/fi/assettasks/copyfile_fitask.go index 2757f7880a6de..a82861f8662ca 100644 --- a/upup/pkg/fi/assettasks/copyfile_fitask.go +++ b/upup/pkg/fi/assettasks/copyfile_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=CopyFile"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package assettasks diff --git a/upup/pkg/fi/cloudup/alitasks/disk_fitask.go b/upup/pkg/fi/cloudup/alitasks/disk_fitask.go index 77850f0f4f566..a88ae6ca4ea9c 100644 --- a/upup/pkg/fi/cloudup/alitasks/disk_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/disk_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Disk"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/eip_fitask.go b/upup/pkg/fi/cloudup/alitasks/eip_fitask.go index 7fcb35bb1c059..8ee1fd83cac03 100644 --- a/upup/pkg/fi/cloudup/alitasks/eip_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/eip_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=EIP"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/launchconfiguration_fitask.go b/upup/pkg/fi/cloudup/alitasks/launchconfiguration_fitask.go index c41874c3f9e7a..f59e225a28fe9 100644 --- a/upup/pkg/fi/cloudup/alitasks/launchconfiguration_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/launchconfiguration_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=LaunchConfiguration"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/loadbalancer_fitask.go b/upup/pkg/fi/cloudup/alitasks/loadbalancer_fitask.go index 6c41e08446a4b..9acef440ef61a 100644 --- a/upup/pkg/fi/cloudup/alitasks/loadbalancer_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/loadbalancer_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=LoadBalancer"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/loadbalancerlistener_fitask.go b/upup/pkg/fi/cloudup/alitasks/loadbalancerlistener_fitask.go index 0731e7663d112..76ca0c6957b5d 100644 --- a/upup/pkg/fi/cloudup/alitasks/loadbalancerlistener_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/loadbalancerlistener_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=LoadBalancerListener"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/natgateway_fitask.go b/upup/pkg/fi/cloudup/alitasks/natgateway_fitask.go index bf9577b743acd..f419ac0b964b2 100644 --- a/upup/pkg/fi/cloudup/alitasks/natgateway_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/natgateway_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=NatGateway"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/rampolicy_fitask.go b/upup/pkg/fi/cloudup/alitasks/rampolicy_fitask.go index 93523ac4da821..a61fc9406263d 100644 --- a/upup/pkg/fi/cloudup/alitasks/rampolicy_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/rampolicy_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=RAMPolicy"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/ramrole_fitask.go b/upup/pkg/fi/cloudup/alitasks/ramrole_fitask.go index bf1f9a3c76aaa..cb80b58067caa 100644 --- a/upup/pkg/fi/cloudup/alitasks/ramrole_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/ramrole_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=RAMRole"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/scalinggroup_fitask.go b/upup/pkg/fi/cloudup/alitasks/scalinggroup_fitask.go index bf81b63c39f78..ea8c762cb2dac 100644 --- a/upup/pkg/fi/cloudup/alitasks/scalinggroup_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/scalinggroup_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=ScalingGroup"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/securitygroup_fitask.go b/upup/pkg/fi/cloudup/alitasks/securitygroup_fitask.go index 085bfc69ede9e..9c5f89bad6471 100644 --- a/upup/pkg/fi/cloudup/alitasks/securitygroup_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/securitygroup_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=SecurityGroup"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/securitygrouprule_fitask.go b/upup/pkg/fi/cloudup/alitasks/securitygrouprule_fitask.go index aef7b6fbfda2c..ce0b3c8cfee31 100644 --- a/upup/pkg/fi/cloudup/alitasks/securitygrouprule_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/securitygrouprule_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=SecurityGroupRule"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/sshkey_fitask.go b/upup/pkg/fi/cloudup/alitasks/sshkey_fitask.go index 9dadf680888b2..6412e87597b4a 100644 --- a/upup/pkg/fi/cloudup/alitasks/sshkey_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/sshkey_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=SSHKey"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/vpc_fitask.go b/upup/pkg/fi/cloudup/alitasks/vpc_fitask.go index c14b86c9137f0..b36e768c72b1e 100644 --- a/upup/pkg/fi/cloudup/alitasks/vpc_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/vpc_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=VPC"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/vswitch_fitask.go b/upup/pkg/fi/cloudup/alitasks/vswitch_fitask.go index c6aaab312ee9f..5f78fcdf5253a 100644 --- a/upup/pkg/fi/cloudup/alitasks/vswitch_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/vswitch_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=VSwitch"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/alitasks/vswitchsnat_fitask.go b/upup/pkg/fi/cloudup/alitasks/vswitchsnat_fitask.go index bcd274afabf99..4b91af4fdaf7e 100644 --- a/upup/pkg/fi/cloudup/alitasks/vswitchsnat_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/vswitchsnat_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=VSwitchSNAT"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/awstasks/dhcpoptions_fitask.go b/upup/pkg/fi/cloudup/awstasks/dhcpoptions_fitask.go index 6db7fc416ddef..62c9a07265640 100644 --- a/upup/pkg/fi/cloudup/awstasks/dhcpoptions_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/dhcpoptions_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=DHCPOptions"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/dnsname_fitask.go b/upup/pkg/fi/cloudup/awstasks/dnsname_fitask.go index 6d3a690b986be..2595634611480 100644 --- a/upup/pkg/fi/cloudup/awstasks/dnsname_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/dnsname_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=DNSName"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/dnszone_fitask.go b/upup/pkg/fi/cloudup/awstasks/dnszone_fitask.go index ad595e12ed72e..4249f9d8eadd0 100644 --- a/upup/pkg/fi/cloudup/awstasks/dnszone_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/dnszone_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=DNSZone"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/ebsvolume_fitask.go b/upup/pkg/fi/cloudup/awstasks/ebsvolume_fitask.go index 14dc9ea0e0ca1..fe6c0e8a04810 100644 --- a/upup/pkg/fi/cloudup/awstasks/ebsvolume_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/ebsvolume_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=EBSVolume"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/elasticip_fitask.go b/upup/pkg/fi/cloudup/awstasks/elasticip_fitask.go index cb78f09596d9d..30942eda07d3d 100644 --- a/upup/pkg/fi/cloudup/awstasks/elasticip_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/elasticip_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=ElasticIP"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/externalloadbalancerattachment_fitask.go b/upup/pkg/fi/cloudup/awstasks/externalloadbalancerattachment_fitask.go index 5737b0ec989bb..013e2ad083079 100644 --- a/upup/pkg/fi/cloudup/awstasks/externalloadbalancerattachment_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/externalloadbalancerattachment_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=ExternalLoadBalancerAttachment"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/externaltargetgroupattachment_fitask.go b/upup/pkg/fi/cloudup/awstasks/externaltargetgroupattachment_fitask.go index 6be7c35a72761..8def9a9e497b6 100644 --- a/upup/pkg/fi/cloudup/awstasks/externaltargetgroupattachment_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/externaltargetgroupattachment_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=ExternalTargetGroupAttachment"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/iaminstanceprofile_fitask.go b/upup/pkg/fi/cloudup/awstasks/iaminstanceprofile_fitask.go index f853f5d3982ed..971937c1f175f 100644 --- a/upup/pkg/fi/cloudup/awstasks/iaminstanceprofile_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/iaminstanceprofile_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=IAMInstanceProfile"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/iaminstanceprofilerole_fitask.go b/upup/pkg/fi/cloudup/awstasks/iaminstanceprofilerole_fitask.go index 70ba47425ef22..bc57357ed9ce3 100644 --- a/upup/pkg/fi/cloudup/awstasks/iaminstanceprofilerole_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/iaminstanceprofilerole_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=IAMInstanceProfileRole"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/iamoidcprovider_fitask.go b/upup/pkg/fi/cloudup/awstasks/iamoidcprovider_fitask.go index 0de426bf49e74..f3c099586dd3b 100644 --- a/upup/pkg/fi/cloudup/awstasks/iamoidcprovider_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/iamoidcprovider_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=IAMOIDCProvider ."; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/iamrole_fitask.go b/upup/pkg/fi/cloudup/awstasks/iamrole_fitask.go index 23a8e2264d60d..8359eb4433c07 100644 --- a/upup/pkg/fi/cloudup/awstasks/iamrole_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/iamrole_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=IAMRole"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/iamrolepolicy_fitask.go b/upup/pkg/fi/cloudup/awstasks/iamrolepolicy_fitask.go index c739eb831e220..57b203a4860d5 100644 --- a/upup/pkg/fi/cloudup/awstasks/iamrolepolicy_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/iamrolepolicy_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=IAMRolePolicy"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/internetgateway_fitask.go b/upup/pkg/fi/cloudup/awstasks/internetgateway_fitask.go index ae88e752bbd47..cf8258b99e375 100644 --- a/upup/pkg/fi/cloudup/awstasks/internetgateway_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/internetgateway_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=InternetGateway"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/loadbalancer_fitask.go b/upup/pkg/fi/cloudup/awstasks/loadbalancer_fitask.go index 3f687729827f2..bc3adb1610b45 100644 --- a/upup/pkg/fi/cloudup/awstasks/loadbalancer_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/loadbalancer_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=LoadBalancer"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/loadbalancerattachment_fitask.go b/upup/pkg/fi/cloudup/awstasks/loadbalancerattachment_fitask.go index 7ec2606a5bd43..dbf91c8f5446b 100644 --- a/upup/pkg/fi/cloudup/awstasks/loadbalancerattachment_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/loadbalancerattachment_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=LoadBalancerAttachment"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/natgateway_fitask.go b/upup/pkg/fi/cloudup/awstasks/natgateway_fitask.go index 47954ec0612fc..fc4612b1ec889 100644 --- a/upup/pkg/fi/cloudup/awstasks/natgateway_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/natgateway_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=NatGateway"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/route_fitask.go b/upup/pkg/fi/cloudup/awstasks/route_fitask.go index 56ac94ea20d56..217fe074e12c1 100644 --- a/upup/pkg/fi/cloudup/awstasks/route_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/route_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Route"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/routetable_fitask.go b/upup/pkg/fi/cloudup/awstasks/routetable_fitask.go index f4cecfa0210cb..c442310468fdf 100644 --- a/upup/pkg/fi/cloudup/awstasks/routetable_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/routetable_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=RouteTable"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/routetableassociation_fitask.go b/upup/pkg/fi/cloudup/awstasks/routetableassociation_fitask.go index 5dc15052dd975..78a8a2d30a842 100644 --- a/upup/pkg/fi/cloudup/awstasks/routetableassociation_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/routetableassociation_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=RouteTableAssociation"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/securitygroup_fitask.go b/upup/pkg/fi/cloudup/awstasks/securitygroup_fitask.go index f747fb706caaa..e5abc14d0dd93 100644 --- a/upup/pkg/fi/cloudup/awstasks/securitygroup_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/securitygroup_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=SecurityGroup"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/securitygrouprule_fitask.go b/upup/pkg/fi/cloudup/awstasks/securitygrouprule_fitask.go index 78dc7d40df0e9..864b1ef8140b3 100644 --- a/upup/pkg/fi/cloudup/awstasks/securitygrouprule_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/securitygrouprule_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=SecurityGroupRule"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/sshkey_fitask.go b/upup/pkg/fi/cloudup/awstasks/sshkey_fitask.go index 8fdc8d2baa1a3..a355f268845db 100644 --- a/upup/pkg/fi/cloudup/awstasks/sshkey_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/sshkey_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=SSHKey"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/subnet_fitask.go b/upup/pkg/fi/cloudup/awstasks/subnet_fitask.go index c19062f4f4f25..71f7dfbaa84a7 100644 --- a/upup/pkg/fi/cloudup/awstasks/subnet_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/subnet_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Subnet"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/vpc_fitask.go b/upup/pkg/fi/cloudup/awstasks/vpc_fitask.go index 5661e673d8d40..8c6fdc741e3b9 100644 --- a/upup/pkg/fi/cloudup/awstasks/vpc_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/vpc_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=VPC"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/vpccidrblock_fitask.go b/upup/pkg/fi/cloudup/awstasks/vpccidrblock_fitask.go index 3154ff7f9a952..d3be8842efc89 100644 --- a/upup/pkg/fi/cloudup/awstasks/vpccidrblock_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/vpccidrblock_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=VPCCIDRBlock"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/vpcdhcpoptionsassociation_fitask.go b/upup/pkg/fi/cloudup/awstasks/vpcdhcpoptionsassociation_fitask.go index 79dfc6488ce8a..99321df2b32c6 100644 --- a/upup/pkg/fi/cloudup/awstasks/vpcdhcpoptionsassociation_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/vpcdhcpoptionsassociation_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=VPCDHCPOptionsAssociation"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/dotasks/droplet_fitask.go b/upup/pkg/fi/cloudup/dotasks/droplet_fitask.go index 50aa9d21bb1f5..20b10a1f06723 100644 --- a/upup/pkg/fi/cloudup/dotasks/droplet_fitask.go +++ b/upup/pkg/fi/cloudup/dotasks/droplet_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Droplet"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package dotasks diff --git a/upup/pkg/fi/cloudup/dotasks/loadbalancer_fitask.go b/upup/pkg/fi/cloudup/dotasks/loadbalancer_fitask.go index f1e0ce7b4bcfd..7144341d55e18 100644 --- a/upup/pkg/fi/cloudup/dotasks/loadbalancer_fitask.go +++ b/upup/pkg/fi/cloudup/dotasks/loadbalancer_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=LoadBalancer"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package dotasks diff --git a/upup/pkg/fi/cloudup/dotasks/volume_fitask.go b/upup/pkg/fi/cloudup/dotasks/volume_fitask.go index cfcb0a2408da7..5c7bc743fcb65 100644 --- a/upup/pkg/fi/cloudup/dotasks/volume_fitask.go +++ b/upup/pkg/fi/cloudup/dotasks/volume_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Volume"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package dotasks diff --git a/upup/pkg/fi/cloudup/gcetasks/address_fitask.go b/upup/pkg/fi/cloudup/gcetasks/address_fitask.go index a3c62e2857051..13b53b8e22390 100644 --- a/upup/pkg/fi/cloudup/gcetasks/address_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/address_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Address"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package gcetasks diff --git a/upup/pkg/fi/cloudup/gcetasks/disk_fitask.go b/upup/pkg/fi/cloudup/gcetasks/disk_fitask.go index caa6ddda0ef0e..fb0dd790b10a0 100644 --- a/upup/pkg/fi/cloudup/gcetasks/disk_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/disk_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Disk"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package gcetasks diff --git a/upup/pkg/fi/cloudup/gcetasks/firewallrule_fitask.go b/upup/pkg/fi/cloudup/gcetasks/firewallrule_fitask.go index 7d60679ae7609..484e8d43cea9f 100644 --- a/upup/pkg/fi/cloudup/gcetasks/firewallrule_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/firewallrule_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=FirewallRule"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package gcetasks diff --git a/upup/pkg/fi/cloudup/gcetasks/forwardingrule_fitask.go b/upup/pkg/fi/cloudup/gcetasks/forwardingrule_fitask.go index 08530a07a872f..824555ff9b59a 100644 --- a/upup/pkg/fi/cloudup/gcetasks/forwardingrule_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/forwardingrule_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=ForwardingRule"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package gcetasks diff --git a/upup/pkg/fi/cloudup/gcetasks/instance_fitask.go b/upup/pkg/fi/cloudup/gcetasks/instance_fitask.go index d4bf46c7c5063..219d62ac01e28 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instance_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/instance_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Instance"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package gcetasks diff --git a/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager_fitask.go b/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager_fitask.go index 90368efc1be68..3fe5d3088ccbc 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=InstanceGroupManager"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package gcetasks diff --git a/upup/pkg/fi/cloudup/gcetasks/instancetemplate_fitask.go b/upup/pkg/fi/cloudup/gcetasks/instancetemplate_fitask.go index a3667a2a608fa..c4b23e8b3f57a 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instancetemplate_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/instancetemplate_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=InstanceTemplate"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package gcetasks diff --git a/upup/pkg/fi/cloudup/gcetasks/network_fitask.go b/upup/pkg/fi/cloudup/gcetasks/network_fitask.go index 9856a5e35d61c..bf7ba7fbaf19d 100644 --- a/upup/pkg/fi/cloudup/gcetasks/network_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/network_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Network"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package gcetasks diff --git a/upup/pkg/fi/cloudup/gcetasks/storagebucketacl_fitask.go b/upup/pkg/fi/cloudup/gcetasks/storagebucketacl_fitask.go index 29e403e71ae90..d01f9e7aad150 100644 --- a/upup/pkg/fi/cloudup/gcetasks/storagebucketacl_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/storagebucketacl_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=StorageBucketAcl"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package gcetasks diff --git a/upup/pkg/fi/cloudup/gcetasks/storagebucketiam_fitask.go b/upup/pkg/fi/cloudup/gcetasks/storagebucketiam_fitask.go index a6fb1a43f4681..a02a0206e441f 100644 --- a/upup/pkg/fi/cloudup/gcetasks/storagebucketiam_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/storagebucketiam_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=StorageBucketIam"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package gcetasks diff --git a/upup/pkg/fi/cloudup/gcetasks/storageobjectacl_fitask.go b/upup/pkg/fi/cloudup/gcetasks/storageobjectacl_fitask.go index d6b36fbd54d12..8f4d676a63cb0 100644 --- a/upup/pkg/fi/cloudup/gcetasks/storageobjectacl_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/storageobjectacl_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=StorageObjectAcl"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package gcetasks diff --git a/upup/pkg/fi/cloudup/gcetasks/subnet_fitask.go b/upup/pkg/fi/cloudup/gcetasks/subnet_fitask.go index 80e1c6097de8b..ebc9ea68d359d 100644 --- a/upup/pkg/fi/cloudup/gcetasks/subnet_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/subnet_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Subnet"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package gcetasks diff --git a/upup/pkg/fi/cloudup/gcetasks/targetpool_fitask.go b/upup/pkg/fi/cloudup/gcetasks/targetpool_fitask.go index 53afe9d1e84e4..98d7e02f3c664 100644 --- a/upup/pkg/fi/cloudup/gcetasks/targetpool_fitask.go +++ b/upup/pkg/fi/cloudup/gcetasks/targetpool_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=TargetPool"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package gcetasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/floatingip_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/floatingip_fitask.go index 22d91ce063766..f82ec81b20a4f 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/floatingip_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/floatingip_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=FloatingIP"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/instance_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/instance_fitask.go index 726e95522cd3a..40832880534d5 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/instance_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/instance_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Instance"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/lb_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/lb_fitask.go index 37d81a40d8b62..95acb05f0eb82 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/lb_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/lb_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=LB"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/lblistener_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/lblistener_fitask.go index 92591bec6f2b0..35f806db44c46 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/lblistener_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/lblistener_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=LBListener"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/lbpool_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/lbpool_fitask.go index 3ecf3f4985c69..6ddd6244cc8de 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/lbpool_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/lbpool_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=LBPool"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/network_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/network_fitask.go index 67e97708c7a43..b340983e26fe5 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/network_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/network_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Network"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/poolassociation_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/poolassociation_fitask.go index f75f56d67d142..08d12ba1ffe09 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/poolassociation_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/poolassociation_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=PoolAssociation"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/port_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/port_fitask.go index 221a4ccb96ebe..4bbc38b48ce30 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/port_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/port_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Port"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/router_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/router_fitask.go index 22adfc2ea97e8..ace9b06ee5094 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/router_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/router_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Router"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/routerinterface_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/routerinterface_fitask.go index 78dccfbb83507..75894ceade614 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/routerinterface_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/routerinterface_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=RouterInterface"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/securitygroup_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/securitygroup_fitask.go index b19e3fb8c6859..06221704f72f9 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/securitygroup_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/securitygroup_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=SecurityGroup"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/servergroup_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/servergroup_fitask.go index 304fc7bc47c43..82bb78ea31af6 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/servergroup_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/servergroup_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=ServerGroup"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/sshkey_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/sshkey_fitask.go index 1d898a65814a9..f360b1a090ba4 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/sshkey_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/sshkey_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=SSHKey"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/subnet_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/subnet_fitask.go index 8659aa34ddc6a..028036c7daccc 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/subnet_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/subnet_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Subnet"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/openstacktasks/volume_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/volume_fitask.go index c918e8fb56843..1cdc920fb292b 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/volume_fitask.go +++ b/upup/pkg/fi/cloudup/openstacktasks/volume_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Volume"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package openstacktasks diff --git a/upup/pkg/fi/cloudup/spotinsttasks/BUILD.bazel b/upup/pkg/fi/cloudup/spotinsttasks/BUILD.bazel index a7ce8ea301908..55e95ed2bc59b 100644 --- a/upup/pkg/fi/cloudup/spotinsttasks/BUILD.bazel +++ b/upup/pkg/fi/cloudup/spotinsttasks/BUILD.bazel @@ -6,7 +6,7 @@ go_library( "elastigroup.go", "elastigroup_fitask.go", "launch_spec.go", - "launch_spec_fitask.go", + "launchspec_fitask.go", "ocean.go", "ocean_fitask.go", ], diff --git a/upup/pkg/fi/cloudup/spotinsttasks/elastigroup_fitask.go b/upup/pkg/fi/cloudup/spotinsttasks/elastigroup_fitask.go index 4017e92dcd4b3..7877682d55349 100644 --- a/upup/pkg/fi/cloudup/spotinsttasks/elastigroup_fitask.go +++ b/upup/pkg/fi/cloudup/spotinsttasks/elastigroup_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Elastigroup"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package spotinsttasks diff --git a/upup/pkg/fi/cloudup/spotinsttasks/launch_spec_fitask.go b/upup/pkg/fi/cloudup/spotinsttasks/launchspec_fitask.go similarity index 94% rename from upup/pkg/fi/cloudup/spotinsttasks/launch_spec_fitask.go rename to upup/pkg/fi/cloudup/spotinsttasks/launchspec_fitask.go index 2676b41ac52b4..96f149be62acb 100644 --- a/upup/pkg/fi/cloudup/spotinsttasks/launch_spec_fitask.go +++ b/upup/pkg/fi/cloudup/spotinsttasks/launchspec_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=LaunchSpec"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package spotinsttasks diff --git a/upup/pkg/fi/cloudup/spotinsttasks/ocean_fitask.go b/upup/pkg/fi/cloudup/spotinsttasks/ocean_fitask.go index f7da22c986f52..8c3806dafd308 100644 --- a/upup/pkg/fi/cloudup/spotinsttasks/ocean_fitask.go +++ b/upup/pkg/fi/cloudup/spotinsttasks/ocean_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Ocean"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package spotinsttasks diff --git a/upup/pkg/fi/fitasks/keypair_fitask.go b/upup/pkg/fi/fitasks/keypair_fitask.go index c84fbe92c11d6..ee4ce02812cf3 100644 --- a/upup/pkg/fi/fitasks/keypair_fitask.go +++ b/upup/pkg/fi/fitasks/keypair_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Keypair"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package fitasks diff --git a/upup/pkg/fi/fitasks/managedfile_fitask.go b/upup/pkg/fi/fitasks/managedfile_fitask.go index 84f632284ba27..08fee36b80bd1 100644 --- a/upup/pkg/fi/fitasks/managedfile_fitask.go +++ b/upup/pkg/fi/fitasks/managedfile_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=ManagedFile"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package fitasks diff --git a/upup/pkg/fi/fitasks/mirrorkeystore_fitask.go b/upup/pkg/fi/fitasks/mirrorkeystore_fitask.go index fb2ebfaa87069..d3fdefe638873 100644 --- a/upup/pkg/fi/fitasks/mirrorkeystore_fitask.go +++ b/upup/pkg/fi/fitasks/mirrorkeystore_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=MirrorKeystore"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package fitasks diff --git a/upup/pkg/fi/fitasks/mirrorsecrets_fitask.go b/upup/pkg/fi/fitasks/mirrorsecrets_fitask.go index 0b9d5cbcb8ab5..749358dc57ccd 100644 --- a/upup/pkg/fi/fitasks/mirrorsecrets_fitask.go +++ b/upup/pkg/fi/fitasks/mirrorsecrets_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=MirrorSecrets"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package fitasks diff --git a/upup/pkg/fi/fitasks/secret_fitask.go b/upup/pkg/fi/fitasks/secret_fitask.go index e04d302c7befb..7eec1bf877aad 100644 --- a/upup/pkg/fi/fitasks/secret_fitask.go +++ b/upup/pkg/fi/fitasks/secret_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Secret"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package fitasks From b9b9bce43d57ea5f13aae926f876a50ebf6e61f9 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Mon, 27 Jul 2020 11:13:03 -0700 Subject: [PATCH 6/8] SecurityGroupRule boilerplate is not automatically generated --- .../pkg/fi/cloudup/openstacktasks/BUILD.bazel | 1 - .../openstacktasks/securitygrouprule.go | 50 ++++++++++++ .../securitygrouprule_fitask.go | 76 ------------------- 3 files changed, 50 insertions(+), 77 deletions(-) delete mode 100644 upup/pkg/fi/cloudup/openstacktasks/securitygrouprule_fitask.go diff --git a/upup/pkg/fi/cloudup/openstacktasks/BUILD.bazel b/upup/pkg/fi/cloudup/openstacktasks/BUILD.bazel index 0a7f6230f08b6..1bcb509a2ecbc 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/BUILD.bazel +++ b/upup/pkg/fi/cloudup/openstacktasks/BUILD.bazel @@ -26,7 +26,6 @@ go_library( "securitygroup.go", "securitygroup_fitask.go", "securitygrouprule.go", - "securitygrouprule_fitask.go", "servergroup.go", "servergroup_fitask.go", "sshkey.go", diff --git a/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go b/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go index bd151be50b514..d0cee2ffc606c 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go +++ b/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go @@ -17,6 +17,7 @@ limitations under the License. package openstacktasks import ( + "encoding/json" "fmt" sgr "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules" @@ -175,3 +176,52 @@ func (_ *SecurityGroupRule) RenderOpenstack(t *openstack.OpenstackAPITarget, a, klog.V(2).Infof("Openstack task SecurityGroupRule::RenderOpenstack did nothing") return nil } + +// JSON marshalling boilerplate +type realSecurityGroupRule SecurityGroupRule + +// UnmarshalJSON implements conversion to JSON, supporting an alternate specification of the object as a string +func (o *SecurityGroupRule) UnmarshalJSON(data []byte) error { + var jsonName string + if err := json.Unmarshal(data, &jsonName); err == nil { + o.ID = &jsonName + return nil + } + + var r realSecurityGroupRule + if err := json.Unmarshal(data, &r); err != nil { + return err + } + *o = SecurityGroupRule(r) + return nil +} + +var _ fi.HasLifecycle = &SecurityGroupRule{} + +// GetLifecycle returns the Lifecycle of the object, implementing fi.HasLifecycle +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.HasLifecycle = &SecurityGroupRule{} + +// GetName returns the Name of the object, implementing fi.HasName +func (o *SecurityGroupRule) GetName() *string { + name := o.String() + return &name +} + +// SetName sets the Name of the object, implementing fi.SetName +func (o *SecurityGroupRule) SetName(name string) { + // o.ID = &name +} + +// String is the stringer function for the task, producing readable output using fi.TaskAsString +func (o *SecurityGroupRule) String() string { + return fi.TaskAsString(o) +} diff --git a/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule_fitask.go b/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule_fitask.go deleted file mode 100644 index 4f7fb3bcee4f5..0000000000000 --- a/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule_fitask.go +++ /dev/null @@ -1,76 +0,0 @@ -/* -Copyright 2019 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. -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. -*/ - -// Code generated by ""fitask" -type=SecurityGroup"; DO NOT EDIT - -package openstacktasks - -import ( - "encoding/json" - - "k8s.io/kops/upup/pkg/fi" -) - -// SecurityGroup - -// JSON marshalling boilerplate -type realSecurityGroupRule SecurityGroupRule - -// UnmarshalJSON implements conversion to JSON, supporting an alternate specification of the object as a string -func (o *SecurityGroupRule) UnmarshalJSON(data []byte) error { - var jsonName string - if err := json.Unmarshal(data, &jsonName); err == nil { - o.ID = &jsonName - return nil - } - - var r realSecurityGroupRule - if err := json.Unmarshal(data, &r); err != nil { - return err - } - *o = SecurityGroupRule(r) - return nil -} - -var _ fi.HasLifecycle = &SecurityGroup{} - -// GetLifecycle returns the Lifecycle of the object, implementing fi.HasLifecycle -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.HasLifecycle = &SecurityGroupRule{} - -// GetName returns the Name of the object, implementing fi.HasName -func (o *SecurityGroupRule) GetName() *string { - name := o.String() - return &name -} - -// SetName sets the Name of the object, implementing fi.SetName -func (o *SecurityGroupRule) SetName(name string) { - // o.ID = &name -} - -// String is the stringer function for the task, producing readable output using fi.TaskAsString -func (o *SecurityGroupRule) String() string { - return fi.TaskAsString(o) -} From d27e805099779c9b3d5b7e5dc16d9d0a653a89f0 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Sun, 26 Jul 2020 23:37:45 -0700 Subject: [PATCH 7/8] Add missing fitask markers --- upup/pkg/fi/cloudup/alitasks/loadbalanceracl.go | 1 + upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go | 1 + upup/pkg/fi/cloudup/awstasks/instance.go | 1 + upup/pkg/fi/cloudup/awstasks/launchconfiguration.go | 1 + 4 files changed, 4 insertions(+) diff --git a/upup/pkg/fi/cloudup/alitasks/loadbalanceracl.go b/upup/pkg/fi/cloudup/alitasks/loadbalanceracl.go index 8f783c3f362a1..1f71592a613dc 100644 --- a/upup/pkg/fi/cloudup/alitasks/loadbalanceracl.go +++ b/upup/pkg/fi/cloudup/alitasks/loadbalanceracl.go @@ -30,6 +30,7 @@ import ( "k8s.io/kops/upup/pkg/fi/cloudup/terraform" ) +// +kops:fitask type LoadBalancerACL struct { ID *string Name *string diff --git a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go index 97a9f9274e16a..a176b767a0d4c 100644 --- a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go +++ b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go @@ -39,6 +39,7 @@ import ( const CloudTagInstanceGroupRolePrefix = "k8s.io/role/" // AutoscalingGroup provdes the definition for a autoscaling group in aws +// +kops:fitask type AutoscalingGroup struct { // Name is the name of the ASG Name *string diff --git a/upup/pkg/fi/cloudup/awstasks/instance.go b/upup/pkg/fi/cloudup/awstasks/instance.go index 1c34193cfce7b..fe0fa07ab3c2d 100644 --- a/upup/pkg/fi/cloudup/awstasks/instance.go +++ b/upup/pkg/fi/cloudup/awstasks/instance.go @@ -34,6 +34,7 @@ import ( const MaxUserDataSize = 16384 // Instance defines the instance specification +// +kops:fitask type Instance struct { ID *string Lifecycle *fi.Lifecycle diff --git a/upup/pkg/fi/cloudup/awstasks/launchconfiguration.go b/upup/pkg/fi/cloudup/awstasks/launchconfiguration.go index 7f8921bf7866f..ba3d42b67aba7 100644 --- a/upup/pkg/fi/cloudup/awstasks/launchconfiguration.go +++ b/upup/pkg/fi/cloudup/awstasks/launchconfiguration.go @@ -51,6 +51,7 @@ func RetainLaunchConfigurationCount() int { } // LaunchConfiguration is the specification for a launch configuration +// +kops:fitask type LaunchConfiguration struct { // Name is the name of the configuration Name *string From 8292cacd3c60c94e9140e51d5854def8a038d9f5 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Sun, 26 Jul 2020 23:40:46 -0700 Subject: [PATCH 8/8] make codegen --- upup/pkg/fi/cloudup/alitasks/loadbalanceracl_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/autoscalinggroup_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/instance_fitask.go | 6 ++++-- upup/pkg/fi/cloudup/awstasks/launchconfiguration_fitask.go | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/upup/pkg/fi/cloudup/alitasks/loadbalanceracl_fitask.go b/upup/pkg/fi/cloudup/alitasks/loadbalanceracl_fitask.go index c34299fe127aa..aa279f32d1e20 100644 --- a/upup/pkg/fi/cloudup/alitasks/loadbalanceracl_fitask.go +++ b/upup/pkg/fi/cloudup/alitasks/loadbalanceracl_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=LoadBalancerACL"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package alitasks diff --git a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup_fitask.go b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup_fitask.go index 7356b09bffca2..545938d1db4c0 100644 --- a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=AutoscalingGroup"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/instance_fitask.go b/upup/pkg/fi/cloudup/awstasks/instance_fitask.go index bd285ebe50cdf..cee8ace3125c7 100644 --- a/upup/pkg/fi/cloudup/awstasks/instance_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/instance_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=Instance"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks diff --git a/upup/pkg/fi/cloudup/awstasks/launchconfiguration_fitask.go b/upup/pkg/fi/cloudup/awstasks/launchconfiguration_fitask.go index 6f807024c6589..18a46ca2ac33c 100644 --- a/upup/pkg/fi/cloudup/awstasks/launchconfiguration_fitask.go +++ b/upup/pkg/fi/cloudup/awstasks/launchconfiguration_fitask.go @@ -1,5 +1,7 @@ +// +build !ignore_autogenerated + /* -Copyright 2019 The Kubernetes Authors. +Copyright 2020 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. @@ -14,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by ""fitask" -type=LaunchConfiguration"; DO NOT EDIT +// Code generated by fitask. DO NOT EDIT. package awstasks