diff options
Diffstat (limited to 'pkg/api')
-rw-r--r-- | pkg/api/handlers/compat/images_build.go | 26 | ||||
-rw-r--r-- | pkg/api/handlers/decoder.go | 10 | ||||
-rw-r--r-- | pkg/api/handlers/libpod/play.go | 10 | ||||
-rw-r--r-- | pkg/api/handlers/libpod/secrets.go | 8 | ||||
-rw-r--r-- | pkg/api/server/server.go | 21 |
5 files changed, 37 insertions, 38 deletions
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 0f85aa717..f0d07f492 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -72,25 +72,26 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { query := struct { AddHosts string `schema:"extrahosts"` AdditionalCapabilities string `schema:"addcaps"` + AllPlatforms bool `schema:"allplatforms"` Annotations string `schema:"annotations"` AppArmor string `schema:"apparmor"` - AllPlatforms bool `schema:"allplatforms"` BuildArgs string `schema:"buildargs"` CacheFrom string `schema:"cachefrom"` + CgroupParent string `schema:"cgroupparent"` // nolint Compression uint64 `schema:"compression"` ConfigureNetwork string `schema:"networkmode"` - CpuPeriod uint64 `schema:"cpuperiod"` // nolint - CpuQuota int64 `schema:"cpuquota"` // nolint - CpuSetCpus string `schema:"cpusetcpus"` // nolint - CpuSetMems string `schema:"cpusetmems"` // nolint - CpuShares uint64 `schema:"cpushares"` // nolint - CgroupParent string `schema:"cgroupparent"` // nolint + CpuPeriod uint64 `schema:"cpuperiod"` // nolint + CpuQuota int64 `schema:"cpuquota"` // nolint + CpuSetCpus string `schema:"cpusetcpus"` // nolint + CpuSetMems string `schema:"cpusetmems"` // nolint + CpuShares uint64 `schema:"cpushares"` // nolint DNSOptions string `schema:"dnsoptions"` DNSSearch string `schema:"dnssearch"` DNSServers string `schema:"dnsservers"` Devices string `schema:"devices"` Dockerfile string `schema:"dockerfile"` DropCapabilities string `schema:"dropcaps"` + Envs []string `schema:"setenv"` Excludes string `schema:"excludes"` ForceRm bool `schema:"forcerm"` From string `schema:"from"` @@ -108,6 +109,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { Memory int64 `schema:"memory"` NamespaceOptions string `schema:"nsoptions"` NoCache bool `schema:"nocache"` + OSFeatures []string `schema:"osfeature"` + OSVersion string `schema:"osversion"` OutputFormat string `schema:"outputformat"` Platform []string `schema:"platform"` Pull bool `schema:"pull"` @@ -117,16 +120,16 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { Rm bool `schema:"rm"` RusageLogFile string `schema:"rusagelogfile"` Seccomp string `schema:"seccomp"` + Secrets string `schema:"secrets"` SecurityOpt string `schema:"securityopt"` ShmSize int `schema:"shmsize"` Squash bool `schema:"squash"` + TLSVerify bool `schema:"tlsVerify"` Tags []string `schema:"t"` Target string `schema:"target"` Timestamp int64 `schema:"timestamp"` - TLSVerify bool `schema:"tlsVerify"` Ulimits string `schema:"ulimits"` UnsetEnvs []string `schema:"unsetenv"` - Secrets string `schema:"secrets"` }{ Dockerfile: "Dockerfile", IdentityLabel: true, @@ -544,6 +547,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { ContextDirectory: contextDirectory, Devices: devices, DropCapabilities: dropCaps, + Envs: query.Envs, Err: auxout, Excludes: excludes, ForceRmIntermediateCtrs: query.ForceRm, @@ -558,6 +562,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { MaxPullPushRetries: 3, NamespaceOptions: nsoptions, NoCache: query.NoCache, + OSFeatures: query.OSFeatures, + OSVersion: query.OSVersion, Out: stdout, Output: output, OutputFormat: format, @@ -569,8 +575,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { ReportWriter: reporter, RusageLogFile: query.RusageLogFile, Squash: query.Squash, - Target: query.Target, SystemContext: systemContext, + Target: query.Target, UnsetEnvs: query.UnsetEnvs, } diff --git a/pkg/api/handlers/decoder.go b/pkg/api/handlers/decoder.go index 5e8f12960..fbe03d97b 100644 --- a/pkg/api/handlers/decoder.go +++ b/pkg/api/handlers/decoder.go @@ -21,6 +21,7 @@ func NewAPIDecoder() *schema.Decoder { d.RegisterConverter(map[string][]string{}, convertURLValuesString) d.RegisterConverter(time.Time{}, convertTimeString) d.RegisterConverter(define.ContainerStatus(0), convertContainerStatusString) + d.RegisterConverter(map[string]string{}, convertStringMap) var Signal syscall.Signal d.RegisterConverter(Signal, convertSignal) @@ -48,6 +49,15 @@ func convertURLValuesString(query string) reflect.Value { return reflect.ValueOf(f) } +func convertStringMap(query string) reflect.Value { + res := make(map[string]string) + err := json.Unmarshal([]byte(query), &res) + if err != nil { + logrus.Infof("convertStringMap: Failed to Unmarshal %s: %s", query, err.Error()) + } + return reflect.ValueOf(res) +} + func convertContainerStatusString(query string) reflect.Value { result, err := define.StringToContainerStatus(query) if err != nil { diff --git a/pkg/api/handlers/libpod/play.go b/pkg/api/handlers/libpod/play.go index ca9ada761..b71afc28c 100644 --- a/pkg/api/handlers/libpod/play.go +++ b/pkg/api/handlers/libpod/play.go @@ -70,6 +70,16 @@ func PlayKube(w http.ResponseWriter, r *http.Request) { password = authConf.Password } + logDriver := query.LogDriver + if logDriver == "" { + config, err := runtime.GetConfig() + if err != nil { + utils.Error(w, http.StatusInternalServerError, err) + return + } + query.LogDriver = config.Containers.LogDriver + } + containerEngine := abi.ContainerEngine{Libpod: runtime} options := entities.PlayKubeOptions{ Annotations: query.Annotations, diff --git a/pkg/api/handlers/libpod/secrets.go b/pkg/api/handlers/libpod/secrets.go index 8708e630c..3ea2c2ea8 100644 --- a/pkg/api/handlers/libpod/secrets.go +++ b/pkg/api/handlers/libpod/secrets.go @@ -1,9 +1,7 @@ package libpod import ( - "encoding/json" "net/http" - "reflect" "github.com/containers/podman/v4/libpod" "github.com/containers/podman/v4/pkg/api/handlers/utils" @@ -20,12 +18,6 @@ func CreateSecret(w http.ResponseWriter, r *http.Request) { decoder = r.Context().Value(api.DecoderKey).(*schema.Decoder) ) - decoder.RegisterConverter(map[string]string{}, func(str string) reflect.Value { - res := make(map[string]string) - json.Unmarshal([]byte(str), &res) - return reflect.ValueOf(res) - }) - query := struct { Name string `schema:"name"` Driver string `schema:"driver"` diff --git a/pkg/api/server/server.go b/pkg/api/server/server.go index a906a01f1..7f5537fb4 100644 --- a/pkg/api/server/server.go +++ b/pkg/api/server/server.go @@ -20,7 +20,6 @@ import ( "github.com/containers/podman/v4/pkg/api/server/idle" "github.com/containers/podman/v4/pkg/api/types" "github.com/containers/podman/v4/pkg/domain/entities" - "github.com/coreos/go-systemd/v22/activation" "github.com/coreos/go-systemd/v22/daemon" "github.com/gorilla/mux" "github.com/gorilla/schema" @@ -65,25 +64,7 @@ func NewServerWithSettings(runtime *libpod.Runtime, listener net.Listener, opts } func newServer(runtime *libpod.Runtime, listener net.Listener, opts entities.ServiceOptions) (*APIServer, error) { - // If listener not provided try socket activation protocol - if listener == nil { - if _, found := os.LookupEnv("LISTEN_PID"); !found { - return nil, fmt.Errorf("no service listener provided and socket activation protocol is not active") - } - - listeners, err := activation.Listeners() - if err != nil { - return nil, fmt.Errorf("cannot retrieve file descriptors from systemd: %w", err) - } - if len(listeners) != 1 { - return nil, fmt.Errorf("wrong number of file descriptors for socket activation protocol (%d != 1)", len(listeners)) - } - listener = listeners[0] - // note that activation.Listeners() return nil when it cannot listen on the fd (i.e. udp connection) - if listener == nil { - return nil, fmt.Errorf("unexpected fd received from systemd: cannot listen on it") - } - } + logrus.Infof("API service listening on %q. URI: %q", listener.Addr(), runtime.RemoteURI()) if opts.CorsHeaders == "" { logrus.Debug("CORS Headers were not set") } else { |