-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into maven/access2
- Loading branch information
Showing
2 changed files
with
77 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Open Component Model contributors. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package wget | ||
|
||
import ( | ||
"github.com/open-component-model/ocm/pkg/cobrautils/flagsets" | ||
"github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/options" | ||
"github.com/open-component-model/ocm/pkg/mime" | ||
) | ||
|
||
func ConfigHandler() flagsets.ConfigOptionTypeSetHandler { | ||
return flagsets.NewConfigOptionTypeSetHandler( | ||
Type, AddConfig, | ||
options.URLOption, | ||
options.MediatypeOption, | ||
options.HTTPHeaderOption, | ||
options.HTTPVerbOption, | ||
options.HTTPBodyOption, | ||
options.HTTPRedirectOption, | ||
) | ||
} | ||
|
||
func AddConfig(opts flagsets.ConfigOptions, config flagsets.Config) error { | ||
flagsets.AddFieldByOptionP(opts, options.URLOption, config, "url") | ||
flagsets.AddFieldByOptionP(opts, options.MediatypeOption, config, "mediaType") | ||
flagsets.AddFieldByOptionP(opts, options.HTTPHeaderOption, config, "header") | ||
flagsets.AddFieldByOptionP(opts, options.HTTPVerbOption, config, "verb") | ||
flagsets.AddFieldByOptionP(opts, options.HTTPBodyOption, config, "body") | ||
flagsets.AddFieldByOptionP(opts, options.HTTPRedirectOption, config, "noredirect") | ||
return nil | ||
} | ||
|
||
var usage = ` | ||
This method implements access to resources stored on an http server. | ||
` | ||
|
||
var formatV1 = ` | ||
The <code>url</code> is the url pointing to the http endpoint from which a resource is | ||
downloaded. The <code>mimeType</code> can be used to specify the MIME type of the | ||
resource. | ||
This blob type specification supports the following fields: | ||
- **<code>url</code>** *string* | ||
This REQUIRED property describes the url from which the resource is to be | ||
downloaded. | ||
- **<code>mediaType</code> *string* | ||
This OPTIONAL property describes the media type of the resource to be | ||
downloaded. If omitted, ocm tries to read the mediaType from the Content-Type header | ||
of the http response. If the mediaType cannot be set from the Content-Type header as well, | ||
ocm tries to deduct the mediaType from the URL. If that is not possible either, the default | ||
media type is defaulted to ` + mime.MIME_OCTET + `. | ||
- **<code>header</code>** *map[string][]string* | ||
This OPTIONAL property describes the http headers to be set in the http request to the server. | ||
- **<code>verb</code>** *string* | ||
This OPTIONAL property describes the http verb (also known as http request method) for the http | ||
request. If omitted, the http verb is defaulted to GET. | ||
- **<code>body</code>** *[]byte* | ||
This OPTIONAL property describes the http body to be included in the request. | ||
- **<code>noredirect<code>** *bool* | ||
This OPTIONAL property describes whether http redirects should be disabled. If omitted, | ||
it is defaulted to false (so, per default, redirects are enabled). | ||
` |
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