forked from uyuni-project/uyuni-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontainerConfig.go
More file actions
40 lines (33 loc) · 1.45 KB
/
Copy pathcontainerConfig.go
File metadata and controls
40 lines (33 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SPDX-FileCopyrightText: 2026 SUSE LLC
//
// SPDX-License-Identifier: Apache-2.0
package proxy
import (
"errors"
"github.com/rs/zerolog/log"
"github.com/uyuni-project/uyuni-tools/shared/api"
. "github.com/uyuni-project/uyuni-tools/shared/l10n"
"github.com/uyuni-project/uyuni-tools/shared/utils"
)
const containerConfigEndpoint = "proxy/containerConfig"
const containerConfigAPIEndpoint = "api.proxy.container_config"
// ContainerConfig computes and downloads the configuration file for proxy containers with generated certificates.
func ContainerConfig(client *api.APIClient, request ProxyConfigRequest) (*[]int8, error) {
return executeRequest(client, ProxyConfigRequestToMap(request))
}
// ContainerConfigGenerate computes and downloads the configuration file for proxy containers.
func ContainerConfigGenerate(client *api.APIClient, request ProxyConfigGenerateRequest) (*[]int8, error) {
return executeRequest(client, ProxyConfigGenerateRequestToMap(request))
}
// common method to execute the request.
func executeRequest(client *api.APIClient, data map[string]interface{}) (*[]int8, error) {
log.Trace().Msgf("Creating proxy configuration file with data: %v...", data)
res, err := api.PostChecked[[]int8](client, containerConfigEndpoint, containerConfigAPIEndpoint, data)
if err != nil {
return nil, utils.Errorf(err, L("failed to create proxy configuration file"))
}
if !res.Success {
return nil, errors.New(res.Message)
}
return &res.Result, nil
}