forked from kubernetes-sigs/external-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support reading manifest url from files (kubernetes-sigs#429)
* Support reading manifest url from files Addressing some technical debt: - Introduce indexscanner.ReadPlugin(io.ReadCloser) - Make ReadPluginFromFile use that to simplify - Move validation.ValidatePlugin from several places to ReadPlugin() method - Add missing "preserves ENOENT" error for ReadPluginFromFile - Fix verify-gofmt.sh reference (now gone) in run-tests.sh Adding new stuff: - introduce --manifest-url that is mut.ex. with --manifest and positional args - add unit tests for url fetching - add integration tests for --manifest-url argument behavior Signed-off-by: Ahmet Alp Balkan <[email protected]> * fix TestKrewInstall_ManifestArgsAreMutuallyExclusive Signed-off-by: Ahmet Alp Balkan <[email protected]> * close() -> shutdown() Signed-off-by: Ahmet Alp Balkan <[email protected]>
- Loading branch information
1 parent
02ceef2
commit 68c452b
Showing
10 changed files
with
184 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// 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 cmd | ||
|
||
import ( | ||
"net/http" | ||
"net/http/httptest" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func Test_readPluginFromURL(t *testing.T) { | ||
server := httptest.NewServer(http.FileServer(http.Dir(filepath.Join("../../../integration_test/testdata")))) | ||
defer server.Close() | ||
|
||
tests := []struct { | ||
name string | ||
url string | ||
wantName string | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "successful request", | ||
url: server.URL + "/konfig.yaml", | ||
wantName: "konfig", | ||
}, | ||
{ | ||
name: "invalid server", | ||
url: "http://example.invalid:80/foo.yaml", | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "bad response", | ||
url: server.URL + "/404.yaml", | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := readPluginFromURL(tt.url) | ||
if (err != nil) != tt.wantErr { | ||
t.Fatalf("readPluginFromURL() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if got.Name != tt.wantName { | ||
t.Fatalf("readPluginFromURL() returned name=%v; want=%v", got.Name, tt.wantName) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.