Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linter again v7 #3287

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58
version: v1.61
args: -v --exclude-dirs cf --exclude-dirs fixtures --exclude-dirs plugin --exclude-dirs command/plugin
format:
name: Run go fmt
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ tmp/
fixtures/.cf

#Compiled Plugins
fixtures/plugins/test_1
fixtures/plugins/test_2
fixtures/plugins/empty_plugin
fixtures/plugins/test_1/test_1
fixtures/plugins/test_2/test_2
fixtures/plugins/empty_plugin/empty_plugin
fixtures/config/plugin-config/.cf/plugins/test_1
fixtures/config/plugin-config/.cf/plugins/test_2
fixtures/config/plugin-config/.cf/plugins/empty_plugin
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ units-plugin: install-test-deps

ifeq ($(OS),Windows_NT)
units-non-plugin: install-test-deps
@rm -f $(wildcard fixtures/plugins/*.exe)
@rm -f $(wildcard fixtures/plugins/*/*.exe)
@ginkgo version
CF_HOME=$(CURDIR)/fixtures CF_USERNAME="" CF_PASSWORD="" $(ginkgo_units) \
-skip-package integration,plugin,cf\actors\plugin,cf\commands\plugin,cf\actors\plugin,util\randomword
else
units-non-plugin: install-test-deps
@rm -f $(wildcard fixtures/plugins/*.exe)
@rm -f $(wildcard fixtures/plugins/*/*.exe)
@ginkgo version
CF_HOME=$(CURDIR)/fixtures CF_USERNAME="" CF_PASSWORD="" $(ginkgo_units) \
-skip-package integration,plugin,cf/actors/plugin,cf/commands/plugin,cf/actors/plugin,util/randomword
Expand Down
22 changes: 10 additions & 12 deletions cf/commands/plugin/install_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package plugin_test

import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"runtime"
"strings"
"sync"

"code.cloudfoundry.org/cli/cf/actors/pluginrepo/pluginrepofakes"
Expand Down Expand Up @@ -81,23 +79,23 @@ var _ = Describe("Install", func() {
if err != nil {
panic(err)
}
test_1 = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_1.exe")
test_2 = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_2.exe")
test_1 = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_1", "test_1.exe")
test_2 = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_2", "test_2.exe")
test_curDir = filepath.Join("test_1.exe")
test_with_help = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_with_help.exe")
test_with_orgs = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_with_orgs.exe")
test_with_orgs_short_name = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_with_orgs_short_name.exe")
aliasConflicts = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "alias_conflicts.exe")
test_with_help = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_with_help", "test_with_help.exe")
test_with_orgs = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_with_orgs", "test_with_orgs.exe")
test_with_orgs_short_name = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_with_orgs_short_name", "test_with_orgs_short_name.exe")
aliasConflicts = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "alias_conflicts", "alias_conflicts.exe")

homeDir, err = ioutil.TempDir(os.TempDir(), "plugins")
homeDir, err = os.MkdirTemp(os.TempDir(), "plugins")
Expect(err).ToNot(HaveOccurred())

pluginDir = filepath.Join(homeDir, ".cf", "plugins")
pluginConfig.GetPluginPathReturns(pluginDir)

curDir, err = os.Getwd()
Expect(err).ToNot(HaveOccurred())
pluginFile, err = ioutil.TempFile("./", "test_plugin")
pluginFile, err = os.CreateTemp("./", "test_plugin")
Expect(err).ToNot(HaveOccurred())

if runtime.GOOS != "windows" {
Expand Down Expand Up @@ -542,7 +540,7 @@ var _ = Describe("Install", func() {
runCommand(filepath.Join(curDir, pluginFile.Name()), "-f")
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Installing plugin"},
[]string{"The file ", strings.Trim(pluginFile.Name(), "./"), "already exists"},
[]string{"The file", filepath.Clean(pluginFile.Name()), "already exists"},
[]string{"FAILED"},
))
})
Expand All @@ -560,7 +558,7 @@ var _ = Describe("Install", func() {
curDir, err := os.Getwd()
Expect(err).ToNot(HaveOccurred())

err = os.Chdir("../../../fixtures/plugins")
err = os.Chdir("../../../fixtures/plugins/test_1")
Expect(err).ToNot(HaveOccurred())

runCommand(test_curDir, "-f")
Expand Down
18 changes: 9 additions & 9 deletions cf/commands/plugin/plugin_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ func TestPlugin(t *testing.T) {

RegisterFailHandler(Fail)

pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_help")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_orgs")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_orgs_short_name")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_push")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_push_short_name")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_1")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_2")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "empty_plugin")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "alias_conflicts")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_with_help"), "test_with_help")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_with_orgs"), "test_with_orgs")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_with_orgs_short_name"), "test_with_orgs_short_name")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_with_push"), "test_with_push")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_with_push_short_name"), "test_with_push_short_name")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_1"), "test_1")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_2"), "test_2")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "empty_plugin"), "empty_plugin")
pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "alias_conflicts"), "alias_conflicts")

RunSpecs(t, "Plugin Suite")
}
4 changes: 2 additions & 2 deletions cf/commands/plugin/plugins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var _ = Describe("Plugins", func() {
It("computes and prints the sha1 checksum of the binary", func() {
config.PluginsReturns(map[string]pluginconfig.PluginMetadata{
"Test1": {
Location: "../../../fixtures/plugins/test_1.go",
Location: "../../../fixtures/plugins/test_1/test_1.go",
Version: plugin.VersionType{Major: 1, Minor: 2, Build: 3},
Commands: []plugin.Command{
{Name: "test_1_cmd1", HelpText: "help text for test_1_cmd1"},
Expand Down Expand Up @@ -157,7 +157,7 @@ var _ = Describe("Plugins", func() {

It("does not list the plugin when it provides no available commands", func() {
config.PluginsReturns(map[string]pluginconfig.PluginMetadata{
"EmptyPlugin": {Location: "../../../fixtures/plugins/empty_plugin.exe"},
"EmptyPlugin": {Location: "../../../fixtures/plugins/empty_plugin/empty_plugin.exe"},
})

runCommand()
Expand Down
7 changes: 3 additions & 4 deletions cf/commands/plugin/uninstall_plugin_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package plugin_test

import (
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -41,7 +40,7 @@ var _ = Describe("Uninstall", func() {
requirementsFactory = new(requirementsfakes.FakeFactory)

var err error
fakePluginRepoDir, err = ioutil.TempDir("", "plugins")
fakePluginRepoDir, err = os.MkdirTemp("", "plugins")
Expect(err).ToNot(HaveOccurred())

fixtureDir := filepath.Join("..", "..", "..", "fixtures", "plugins")
Expand All @@ -50,8 +49,8 @@ var _ = Describe("Uninstall", func() {
err = os.MkdirAll(pluginDir, 0700)
Expect(err).NotTo(HaveOccurred())

fileutils.CopyPathToPath(filepath.Join(fixtureDir, "test_1.exe"), filepath.Join(pluginDir, "test_1.exe"))
fileutils.CopyPathToPath(filepath.Join(fixtureDir, "test_2.exe"), filepath.Join(pluginDir, "test_2.exe"))
fileutils.CopyPathToPath(filepath.Join(fixtureDir, "test_1", "test_1.exe"), filepath.Join(pluginDir, "test_1.exe"))
fileutils.CopyPathToPath(filepath.Join(fixtureDir, "test_2", "test_2.exe"), filepath.Join(pluginDir, "test_2.exe"))

confighelpers.PluginRepoDir = func() string {
return fakePluginRepoDir
Expand Down
6 changes: 3 additions & 3 deletions cf/configuration/pluginconfig/plugin_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var _ = Describe("PluginConfig", func() {
}

metadata = PluginMetadata{
Location: "../../../fixtures/plugins/test_1.exe",
Location: "../../../fixtures/plugins/test_1/test_1.exe",
Commands: commands1,
}
})
Expand All @@ -110,9 +110,9 @@ var _ = Describe("PluginConfig", func() {
})

It("returns a list of plugin executables and their location", func() {
Expect(plugins["Test1"].Location).To(Equal("../../../fixtures/plugins/test_1.exe"))
Expect(plugins["Test1"].Location).To(Equal("../../../fixtures/plugins/test_1/test_1.exe"))
Expect(plugins["Test1"].Commands).To(Equal(commands1))
Expect(plugins["Test2"].Location).To(Equal("../../../fixtures/plugins/test_2.exe"))
Expect(plugins["Test2"].Location).To(Equal("../../../fixtures/plugins/test_2/test_2.exe"))
Expect(plugins["Test2"].Commands).To(Equal(commands2))
})
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"Plugins": {
"Test1":{
"Location":"../../fixtures/plugins/test_1.exe",
"Location":"../../fixtures/plugins/test_1/test_1.exe",
"Commands":[
{"Name":"test1_cmd1","Alias":"test1_cmd1_alias","HelpText":"help text for test1 cmd1"},
{"Name":"test1_cmd2","HelpText":"help text for test1 cmd2"}
]
},
"Test2":{
"Location":"../../fixtures/plugins/test_2.exe",
"Location":"../../fixtures/plugins/test_2/test_2.exe",
"Commands":[
{"Name":"test2_cmd1","Alias":"tc1","HelpText":"help text for test2 cmd1"},
{"Name":"test2_cmd2","HelpText":"help text for test2 cmd2"},
Expand Down
4 changes: 2 additions & 2 deletions fixtures/config/plugin-config/.cf/plugins/config.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"Plugins": {
"Test1":{
"Location":"../../../fixtures/plugins/test_1.exe",
"Location":"../../../fixtures/plugins/test_1/test_1.exe",
"Commands":[
{"Name":"test_1_cmd1","HelpText":"help text for test1 cmd1"},
{"Name":"test_1_cmd2","HelpText":"help text for test1 cmd2"}
]
},
"Test2":{
"Location":"../../../fixtures/plugins/test_2.exe",
"Location":"../../../fixtures/plugins/test_2/test_2.exe",
"Commands":[
{"Name":"test_2_cmd1","HelpText":"help text for test2 cmd1"},
{"Name":"test_2_cmd2","HelpText":"help text for test2 cmd2"}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions integration/helpers/curl.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
. "github.com/onsi/gomega/gexec"
)

// Curl runs a 'cf curl' command with a URL format string, allowing props to be
// Curlf runs a 'cf curl' command with a URL format string, allowing props to be
// interpolated into the URL string with fmt.Sprintf. The JSON response is
// unmarshaled into given obj.
func Curl(obj interface{}, url string, props ...interface{}) {
func Curlf(obj interface{}, url string, props ...interface{}) {
session := CF("curl", fmt.Sprintf(url, props...))
Eventually(session).Should(Exit(0))
rawJSON := strings.TrimSpace(string(session.Out.Contents()))
Expand Down
4 changes: 2 additions & 2 deletions integration/helpers/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (r Route) GUID() string {
var domainReceiver struct {
Domains []resources.Domain `json:"resources"`
}
Curl(&domainReceiver, "/v3/domains?names=%s", r.Domain)
Curlf(&domainReceiver, "/v3/domains?names=%s", r.Domain)
Expect(domainReceiver.Domains).To(HaveLen(1))

query := []string{fmt.Sprintf("domain_guids=%s", domainReceiver.Domains[0].GUID)}
Expand All @@ -138,7 +138,7 @@ func (r Route) GUID() string {
var routeReceiver struct {
Routes []resources.Route `json:"resources"`
}
Curl(&routeReceiver, "/v3/routes?%s", strings.Join(query, "&"))
Curlf(&routeReceiver, "/v3/routes?%s", strings.Join(query, "&"))
Expect(routeReceiver.Routes).To(HaveLen(1))

return routeReceiver.Routes[0].GUID
Expand Down
2 changes: 1 addition & 1 deletion integration/helpers/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func SkipIfNoRoutingAPI() {
var response struct {
RoutingEndpoint string `json:"routing_endpoint"`
}
Curl(&response, "/v2/info")
Curlf(&response, "/v2/info")

if response.RoutingEndpoint == "" {
Skip("Test requires routing endpoint on /v2/info")
Expand Down
2 changes: 1 addition & 1 deletion integration/v6/isolated/app_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ applications:
} `json:"resources"`
}

helpers.Curl(&AppInfo, "/v3/apps?names=%s", appName)
helpers.Curlf(&AppInfo, "/v3/apps?names=%s", appName)
appGUID = AppInfo.Resources[0].GUID
})

Expand Down
6 changes: 3 additions & 3 deletions integration/v6/isolated/create_shared_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ var _ = Describe("create-shared-domain command", func() {
}
}

helpers.Curl(&sharedDomainResponse, "/v2/shared_domains?q=name:%s", domainName)
helpers.Curlf(&sharedDomainResponse, "/v2/shared_domains?q=name:%s", domainName)
Expect(sharedDomainResponse.Resources).To(HaveLen(1))
isInternal := sharedDomainResponse.Resources[0].Entity.Internal
Expect(isInternal).To(BeTrue())
Expand Down Expand Up @@ -162,13 +162,13 @@ var _ = Describe("create-shared-domain command", func() {
}
}

helpers.Curl(&sharedDomainResponse, "/v2/shared_domains?q=name:%s", domainName)
helpers.Curlf(&sharedDomainResponse, "/v2/shared_domains?q=name:%s", domainName)
Expect(sharedDomainResponse.Resources).To(HaveLen(1))
currentRouterGroupGUID := sharedDomainResponse.Resources[0].Entity.RouterGroupGUID

var routerGroupListResponse []struct{ GUID string }

helpers.Curl(&routerGroupListResponse, "/routing/v1/router_groups?name=%s", routerGroupName)
helpers.Curlf(&routerGroupListResponse, "/routing/v1/router_groups?name=%s", routerGroupName)
Expect(routerGroupListResponse).To(HaveLen(1))
expectedRouterGroupGUID := routerGroupListResponse[0].GUID
Expect(currentRouterGroupGUID).Should(Equal(expectedRouterGroupGUID))
Expand Down
2 changes: 1 addition & 1 deletion integration/v7/isolated/app_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ applications:
} `json:"resources"`
}

helpers.Curl(&AppInfo, "/v3/apps?names=%s", appName)
helpers.Curlf(&AppInfo, "/v3/apps?names=%s", appName)
appGUID = AppInfo.Resources[0].GUID
})

Expand Down
6 changes: 3 additions & 3 deletions integration/v7/push/droplet_flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ var _ = Describe("--droplet flag", func() {
GUID string `json:"guid"`
}

currentDropletEndpoint := fmt.Sprintf("v3/apps/%s/droplets/current", originalAppGUID)
const droppletEndpointFormat = "v3/apps/%s/droplets/current"

helpers.Curl(&routeResponse, currentDropletEndpoint)
helpers.Curlf(&routeResponse, droppletEndpointFormat, originalAppGUID)
preUploadDropletGUID := routeResponse.GUID

session := helpers.CF(PushCommandName, originalApp, "--droplet", dropletPath, "--no-start")
Expand All @@ -104,7 +104,7 @@ var _ = Describe("--droplet flag", func() {
Eventually(session).Should(Say(`requested state:\s+stopped`))
Eventually(session).Should(Exit(0))

helpers.Curl(&routeResponse, currentDropletEndpoint)
helpers.Curlf(&routeResponse, droppletEndpointFormat, originalAppGUID)
postUploadDropletGUID := routeResponse.GUID

Expect(preUploadDropletGUID).To(Not(Equal(postUploadDropletGUID)))
Expand Down
Loading
Loading