diff --git a/LICENSES b/LICENSES index c075adc804f..ffab14a768c 100644 --- a/LICENSES +++ b/LICENSES @@ -40,7 +40,6 @@ github.com/containerd/containerd,https://github.com/containerd/containerd/blob/v github.com/coreos/go-semver/semver,https://github.com/coreos/go-semver/blob/v0.3.0/LICENSE,Apache-2.0 github.com/coreos/go-systemd/v22,https://github.com/coreos/go-systemd/blob/v22.3.2/LICENSE,Apache-2.0 github.com/cpu/goacmedns,https://github.com/cpu/goacmedns/blob/v0.1.1/LICENSE,MIT -github.com/cpuguy83/go-md2man/v2/md2man,https://github.com/cpuguy83/go-md2man/blob/v2.0.2/LICENSE.md,MIT github.com/cyphar/filepath-securejoin,https://github.com/cyphar/filepath-securejoin/blob/v0.2.3/LICENSE,BSD-3-Clause github.com/davecgh/go-spew/spew,https://github.com/davecgh/go-spew/blob/v1.1.1/LICENSE,ISC github.com/digitalocean/godo,https://github.com/digitalocean/godo/blob/v1.93.0/LICENSE.txt,MIT diff --git a/go.mod b/go.mod index c95d5fbe303..3a0c73fc499 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,6 @@ require ( github.com/hashicorp/vault/sdk v0.6.2 github.com/kr/pretty v0.3.1 github.com/miekg/dns v1.1.50 - github.com/mitchellh/go-homedir v1.1.0 github.com/munnerz/crd-schema-fuzz v1.0.0 github.com/onsi/ginkgo/v2 v2.7.0 github.com/onsi/gomega v1.24.2 @@ -92,7 +91,6 @@ require ( github.com/containerd/containerd v1.6.18 // indirect github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/cyphar/filepath-securejoin v0.2.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/docker/cli v20.10.21+incompatible // indirect @@ -175,6 +173,7 @@ require ( github.com/mattn/go-runewidth v0.0.13 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.0.0 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect diff --git a/go.sum b/go.sum index b1f6bc7919e..5bd41a1b05c 100644 --- a/go.sum +++ b/go.sum @@ -205,7 +205,6 @@ github.com/cpu/goacmedns v0.1.1/go.mod h1:MuaouqEhPAHxsbqjgnck5zeghuwBP1dLnPoobe github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 00000000000..4b72d54703b --- /dev/null +++ b/tools/README.md @@ -0,0 +1,4 @@ +This directory used to contain a Golang script which stopped being used. + +We've left the other script in this directory in case it's being used in a script somewhere, but it's just a wrapper +and we might remove this whole directory in the future. diff --git a/tools/cobra/main.go b/tools/cobra/main.go deleted file mode 100644 index 413baf74881..00000000000 --- a/tools/cobra/main.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright 2020 The cert-manager 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 main - -import ( - "errors" - "fmt" - "os" - "path/filepath" - - "github.com/mitchellh/go-homedir" - "github.com/spf13/cobra" - "github.com/spf13/cobra/doc" - "github.com/spf13/pflag" - - acmesolvercmd "github.com/cert-manager/cert-manager/cmd/acmesolver/app" - cainjectorapp "github.com/cert-manager/cert-manager/cmd/cainjector/app" - controllerapp "github.com/cert-manager/cert-manager/cmd/controller/app" - ctlcmd "github.com/cert-manager/cert-manager/cmd/ctl/cmd" - webhookcmd "github.com/cert-manager/cert-manager/cmd/webhook/app" -) - -func main() { - if err := run(os.Args); err != nil { - fmt.Fprintf(os.Stderr, "error: %s\n", err) - os.Exit(1) - } - - os.Exit(0) -} - -func run(args []string) error { - if len(args) != 2 { - return errors.New("expecting single output directory argument") - } - - // remove all global flags that are imported in - pflag.CommandLine = nil - - root, err := homedir.Expand(args[1]) - if err != nil { - return err - } - - if err := ensureDirectory(root); err != nil { - return err - } - - for _, c := range []*cobra.Command{ - cainjectorapp.NewCommandStartInjectorController(nil, nil, nil), - controllerapp.NewCommandStartCertManagerController(nil), - ctlcmd.NewCertManagerCtlCommand(nil, nil, nil, nil), - webhookcmd.NewServerCommand(nil), - acmesolvercmd.NewACMESolverCommand(nil), - } { - dir := filepath.Join(root, c.Use) - - if err := ensureDirectory(dir); err != nil { - return err - } - - if err := doc.GenMarkdownTree(c, dir); err != nil { - return err - } - } - - return nil -} - -func ensureDirectory(dir string) error { - s, err := os.Stat(dir) - if err != nil { - if os.IsNotExist(err) { - return os.Mkdir(dir, os.FileMode(0755)) - } - return err - } - - if !s.IsDir() { - return fmt.Errorf("path it not directory: %s", dir) - } - - return nil -} diff --git a/tools/cobra/main_test.go b/tools/cobra/main_test.go deleted file mode 100644 index 257f275cf25..00000000000 --- a/tools/cobra/main_test.go +++ /dev/null @@ -1,70 +0,0 @@ -/* -Copyright 2020 The cert-manager 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 main - -import ( - "os" - "path/filepath" - "testing" -) - -func TestRun(t *testing.T) { - rootDir, err := os.MkdirTemp(os.TempDir(), "cert-manager-cobra") - if err != nil { - t.Fatal(err) - } - defer func() { - if err := os.RemoveAll(rootDir); err != nil { - t.Fatal(err) - } - }() - - tests := map[string]struct { - input []string - expDirs []string - expErr bool - }{ - "if no arguments given should error": { - input: []string{"cobra"}, - expErr: true, - }, - "if two arguments given should error": { - input: []string{"cobra", "foo", "bar"}, - expErr: true, - }, - "if directory given, should write docs": { - input: []string{"cobra", filepath.Join(rootDir, "foo")}, - expDirs: []string{"foo/ca-injector", "foo/cert-manager-controller", "foo/cmctl"}, - }, - } - - for name, test := range tests { - t.Run(name, func(t *testing.T) { - err := run(test.input) - if test.expErr != (err != nil) { - t.Errorf("got unexpected error, exp=%t got=%v", - test.expErr, err) - } - - for _, dir := range test.expDirs { - if _, err := os.Stat(filepath.Join(rootDir, dir)); err != nil { - t.Errorf("stat error on expected directory: %s", err) - } - } - }) - } -}