@@ -27,6 +27,7 @@ import (
27
27
"os"
28
28
"strings"
29
29
30
+ "github.com/vladimirvivien/gexe/http"
30
31
apierrors "k8s.io/apimachinery/pkg/api/errors"
31
32
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
32
33
"k8s.io/apimachinery/pkg/runtime"
@@ -83,7 +84,7 @@ func DecodeEachFile(ctx context.Context, fsys fs.FS, pattern string, handlerFn H
83
84
return nil
84
85
}
85
86
86
- // DecodeAllFiles resolves files at the filesystem matching the pattern, decoding JSON or YAML files. Supports multi-document files.
87
+ // DecodeAllFiles resolves files at the filesystem matching the pattern, decoding JSON or YAML files. Supports multi-document files.
87
88
// Falls back to the unstructured.Unstructured type if a matching type cannot be found for the Kind.
88
89
// Options may be provided to configure the behavior of the decoder.
89
90
func DecodeAllFiles (ctx context.Context , fsys fs.FS , pattern string , options ... DecodeOption ) ([]k8s.Object , error ) {
@@ -140,7 +141,7 @@ func DecodeEach(ctx context.Context, manifest io.Reader, handlerFn HandlerFunc,
140
141
return nil
141
142
}
142
143
143
- // DecodeAll is a stream of documents of any Kind using either the innate typing of the scheme.
144
+ // DecodeAll is a stream of documents of any Kind using either the innate typing of the scheme.
144
145
// Falls back to the unstructured.Unstructured type if a matching type cannot be found for the Kind.
145
146
// Options may be provided to configure the behavior of the decoder.
146
147
func DecodeAll (ctx context.Context , manifest io.Reader , options ... DecodeOption ) ([]k8s.Object , error ) {
@@ -217,6 +218,18 @@ func DecodeFile(fsys fs.FS, manifestPath string, obj k8s.Object, options ...Deco
217
218
return Decode (f , obj , options ... )
218
219
}
219
220
221
+ // DecodeURL decodes a document from the URL of any Kind using either the innate typing of the scheme.
222
+ // Falls back to the unstructured.Unstructured type if a matching type cannot be found for the Kind.
223
+ func DecodeURL (ctx context.Context , url string , handlerFn HandlerFunc , options ... DecodeOption ) error {
224
+ resp := http .Get (url ).Do ()
225
+ if resp .Err () != nil {
226
+ return resp .Err ()
227
+ }
228
+ defer resp .Body ().Close ()
229
+
230
+ return DecodeEach (ctx , resp .Body (), handlerFn , options ... )
231
+ }
232
+
220
233
// DecodeString decodes a single-document YAML or JSON string into the provided object. Patches are applied
221
234
// after decoding to the object to update the loaded resource.
222
235
func DecodeString (rawManifest string , obj k8s.Object , options ... DecodeOption ) error {
0 commit comments