diff options
Diffstat (limited to 'pkg/api')
50 files changed, 1711 insertions, 1306 deletions
diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go index e3d51fadf..616f0a138 100644 --- a/pkg/api/handlers/compat/containers.go +++ b/pkg/api/handlers/compat/containers.go @@ -369,26 +369,28 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error return nil, err } - return &handlers.Container{Container: types.Container{ - ID: l.ID(), - Names: []string{fmt.Sprintf("/%s", l.Name())}, - Image: imageName, - ImageID: "sha256:" + imageID, - Command: strings.Join(l.Command(), " "), - Created: l.CreatedTime().Unix(), - Ports: ports, - SizeRw: sizeRW, - SizeRootFs: sizeRootFs, - Labels: l.Labels(), - State: stateStr, - Status: status, - HostConfig: struct { - NetworkMode string `json:",omitempty"` - }{ - "host"}, - NetworkSettings: &networkSettings, - Mounts: mounts, - }, + return &handlers.Container{ + Container: types.Container{ + ID: l.ID(), + Names: []string{fmt.Sprintf("/%s", l.Name())}, + Image: imageName, + ImageID: "sha256:" + imageID, + Command: strings.Join(l.Command(), " "), + Created: l.CreatedTime().Unix(), + Ports: ports, + SizeRw: sizeRW, + SizeRootFs: sizeRootFs, + Labels: l.Labels(), + State: stateStr, + Status: status, + HostConfig: struct { + NetworkMode string `json:",omitempty"` + }{ + "host", + }, + NetworkSettings: &networkSettings, + Mounts: mounts, + }, ContainerCreateConfig: types.ContainerCreateConfig{}, }, nil } diff --git a/pkg/api/handlers/compat/containers_create.go b/pkg/api/handlers/compat/containers_create.go index cd592a975..b9b7f6708 100644 --- a/pkg/api/handlers/compat/containers_create.go +++ b/pkg/api/handlers/compat/containers_create.go @@ -2,18 +2,29 @@ package compat import ( "encoding/json" + "fmt" + "net" "net/http" + "os" + "path/filepath" + "strconv" + "strings" - "github.com/containers/podman/v4/cmd/podman/common" + "github.com/containers/common/libnetwork/types" + "github.com/containers/common/pkg/cgroups" + "github.com/containers/common/pkg/config" "github.com/containers/podman/v4/libpod" + "github.com/containers/podman/v4/libpod/define" "github.com/containers/podman/v4/pkg/api/handlers" "github.com/containers/podman/v4/pkg/api/handlers/utils" api "github.com/containers/podman/v4/pkg/api/types" "github.com/containers/podman/v4/pkg/domain/entities" "github.com/containers/podman/v4/pkg/domain/infra/abi" + "github.com/containers/podman/v4/pkg/rootless" "github.com/containers/podman/v4/pkg/specgen" "github.com/containers/podman/v4/pkg/specgenutil" "github.com/containers/storage" + "github.com/docker/docker/api/types/mount" "github.com/gorilla/schema" "github.com/pkg/errors" ) @@ -70,7 +81,7 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) { } // Take body structure and convert to cliopts - cliOpts, args, err := common.ContainerCreateToContainerCLIOpts(body, rtc) + cliOpts, args, err := cliOpts(body, rtc) if err != nil { utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "make cli opts()")) return @@ -107,3 +118,456 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) { } utils.WriteResponse(w, http.StatusCreated, createResponse) } + +func stringMaptoArray(m map[string]string) []string { + a := make([]string, 0, len(m)) + for k, v := range m { + a = append(a, fmt.Sprintf("%s=%s", k, v)) + } + return a +} + +// cliOpts converts a compat input struct to cliopts +func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.ContainerCreateOptions, []string, error) { + var ( + capAdd []string + cappDrop []string + entrypoint *string + init bool + specPorts []types.PortMapping + ) + + if cc.HostConfig.Init != nil { + init = *cc.HostConfig.Init + } + + // Iterate devices and convert to CLI expected string + devices := make([]string, 0, len(cc.HostConfig.Devices)) + for _, dev := range cc.HostConfig.Devices { + devices = append(devices, fmt.Sprintf("%s:%s:%s", dev.PathOnHost, dev.PathInContainer, dev.CgroupPermissions)) + } + + // iterate blkreaddevicebps + readBps := make([]string, 0, len(cc.HostConfig.BlkioDeviceReadBps)) + for _, dev := range cc.HostConfig.BlkioDeviceReadBps { + readBps = append(readBps, dev.String()) + } + + // iterate blkreaddeviceiops + readIops := make([]string, 0, len(cc.HostConfig.BlkioDeviceReadIOps)) + for _, dev := range cc.HostConfig.BlkioDeviceReadIOps { + readIops = append(readIops, dev.String()) + } + + // iterate blkwritedevicebps + writeBps := make([]string, 0, len(cc.HostConfig.BlkioDeviceWriteBps)) + for _, dev := range cc.HostConfig.BlkioDeviceWriteBps { + writeBps = append(writeBps, dev.String()) + } + + // iterate blkwritedeviceiops + writeIops := make([]string, 0, len(cc.HostConfig.BlkioDeviceWriteIOps)) + for _, dev := range cc.HostConfig.BlkioDeviceWriteIOps { + writeIops = append(writeIops, dev.String()) + } + + // entrypoint + // can be a string or slice. if it is a slice, we need to + // marshall it to json; otherwise it should just be the string + // value + if len(cc.Config.Entrypoint) > 0 { + entrypoint = &cc.Config.Entrypoint[0] + if len(cc.Config.Entrypoint) > 1 { + b, err := json.Marshal(cc.Config.Entrypoint) + if err != nil { + return nil, nil, err + } + jsonString := string(b) + entrypoint = &jsonString + } + } + + // expose ports + expose := make([]string, 0, len(cc.Config.ExposedPorts)) + for p := range cc.Config.ExposedPorts { + expose = append(expose, fmt.Sprintf("%s/%s", p.Port(), p.Proto())) + } + + // mounts type=tmpfs/bind,source=...,target=...=,opt=val + volSources := make(map[string]bool) + volDestinations := make(map[string]bool) + mounts := make([]string, 0, len(cc.HostConfig.Mounts)) + var builder strings.Builder + for _, m := range cc.HostConfig.Mounts { + addField(&builder, "type", string(m.Type)) + addField(&builder, "source", m.Source) + addField(&builder, "target", m.Target) + + // Store source/dest so we don't add duplicates if a volume is + // also mentioned in cc.Volumes. + // Which Docker Compose v2.0 does, for unclear reasons... + volSources[m.Source] = true + volDestinations[m.Target] = true + + if m.ReadOnly { + addField(&builder, "ro", "true") + } + addField(&builder, "consistency", string(m.Consistency)) + // Map any specialized mount options that intersect between *Options and cli options + switch m.Type { + case mount.TypeBind: + if m.BindOptions != nil { + addField(&builder, "bind-propagation", string(m.BindOptions.Propagation)) + addField(&builder, "bind-nonrecursive", strconv.FormatBool(m.BindOptions.NonRecursive)) + } + case mount.TypeTmpfs: + if m.TmpfsOptions != nil { + addField(&builder, "tmpfs-size", strconv.FormatInt(m.TmpfsOptions.SizeBytes, 10)) + addField(&builder, "tmpfs-mode", strconv.FormatUint(uint64(m.TmpfsOptions.Mode), 8)) + } + case mount.TypeVolume: + // All current VolumeOpts are handled above + // See vendor/github.com/containers/common/pkg/parse/parse.go:ValidateVolumeOpts() + } + mounts = append(mounts, builder.String()) + builder.Reset() + } + + // dns + dns := make([]net.IP, 0, len(cc.HostConfig.DNS)) + for _, d := range cc.HostConfig.DNS { + dns = append(dns, net.ParseIP(d)) + } + + // publish + for port, pbs := range cc.HostConfig.PortBindings { + for _, pb := range pbs { + var hostport int + var err error + if pb.HostPort != "" { + hostport, err = strconv.Atoi(pb.HostPort) + } + if err != nil { + return nil, nil, err + } + tmpPort := types.PortMapping{ + HostIP: pb.HostIP, + ContainerPort: uint16(port.Int()), + HostPort: uint16(hostport), + Range: 0, + Protocol: port.Proto(), + } + specPorts = append(specPorts, tmpPort) + } + } + + // netMode + nsmode, networks, netOpts, err := specgen.ParseNetworkFlag([]string{string(cc.HostConfig.NetworkMode)}) + if err != nil { + return nil, nil, err + } + + // network + // Note: we cannot emulate compat exactly here. we only allow specifics of networks to be + // defined when there is only one network. + netInfo := entities.NetOptions{ + AddHosts: cc.HostConfig.ExtraHosts, + DNSOptions: cc.HostConfig.DNSOptions, + DNSSearch: cc.HostConfig.DNSSearch, + DNSServers: dns, + Network: nsmode, + PublishPorts: specPorts, + NetworkOptions: netOpts, + } + + // network names + switch { + case len(cc.NetworkingConfig.EndpointsConfig) > 0: + endpointsConfig := cc.NetworkingConfig.EndpointsConfig + networks := make(map[string]types.PerNetworkOptions, len(endpointsConfig)) + for netName, endpoint := range endpointsConfig { + netOpts := types.PerNetworkOptions{} + if endpoint != nil { + netOpts.Aliases = endpoint.Aliases + + // if IP address is provided + if len(endpoint.IPAddress) > 0 { + staticIP := net.ParseIP(endpoint.IPAddress) + if staticIP == nil { + return nil, nil, errors.Errorf("failed to parse the ip address %q", endpoint.IPAddress) + } + netOpts.StaticIPs = append(netOpts.StaticIPs, staticIP) + } + + if endpoint.IPAMConfig != nil { + // if IPAMConfig.IPv4Address is provided + if len(endpoint.IPAMConfig.IPv4Address) > 0 { + staticIP := net.ParseIP(endpoint.IPAMConfig.IPv4Address) + if staticIP == nil { + return nil, nil, errors.Errorf("failed to parse the ipv4 address %q", endpoint.IPAMConfig.IPv4Address) + } + netOpts.StaticIPs = append(netOpts.StaticIPs, staticIP) + } + // if IPAMConfig.IPv6Address is provided + if len(endpoint.IPAMConfig.IPv6Address) > 0 { + staticIP := net.ParseIP(endpoint.IPAMConfig.IPv6Address) + if staticIP == nil { + return nil, nil, errors.Errorf("failed to parse the ipv6 address %q", endpoint.IPAMConfig.IPv6Address) + } + netOpts.StaticIPs = append(netOpts.StaticIPs, staticIP) + } + } + // If MAC address is provided + if len(endpoint.MacAddress) > 0 { + staticMac, err := net.ParseMAC(endpoint.MacAddress) + if err != nil { + return nil, nil, errors.Errorf("failed to parse the mac address %q", endpoint.MacAddress) + } + netOpts.StaticMAC = types.HardwareAddr(staticMac) + } + } + + networks[netName] = netOpts + } + + netInfo.Networks = networks + case len(cc.HostConfig.NetworkMode) > 0: + netInfo.Networks = networks + } + + parsedTmp := make([]string, 0, len(cc.HostConfig.Tmpfs)) + for path, options := range cc.HostConfig.Tmpfs { + finalString := path + if options != "" { + finalString += ":" + options + } + parsedTmp = append(parsedTmp, finalString) + } + + // Note: several options here are marked as "don't need". this is based + // on speculation by Matt and I. We think that these come into play later + // like with start. We believe this is just a difference in podman/compat + cliOpts := entities.ContainerCreateOptions{ + // Attach: nil, // don't need? + Authfile: "", + CapAdd: append(capAdd, cc.HostConfig.CapAdd...), + CapDrop: append(cappDrop, cc.HostConfig.CapDrop...), + CgroupParent: cc.HostConfig.CgroupParent, + CIDFile: cc.HostConfig.ContainerIDFile, + CPUPeriod: uint64(cc.HostConfig.CPUPeriod), + CPUQuota: cc.HostConfig.CPUQuota, + CPURTPeriod: uint64(cc.HostConfig.CPURealtimePeriod), + CPURTRuntime: cc.HostConfig.CPURealtimeRuntime, + CPUShares: uint64(cc.HostConfig.CPUShares), + // CPUS: 0, // don't need? + CPUSetCPUs: cc.HostConfig.CpusetCpus, + CPUSetMems: cc.HostConfig.CpusetMems, + // Detach: false, // don't need + // DetachKeys: "", // don't need + Devices: devices, + DeviceCgroupRule: nil, + DeviceReadBPs: readBps, + DeviceReadIOPs: readIops, + DeviceWriteBPs: writeBps, + DeviceWriteIOPs: writeIops, + Entrypoint: entrypoint, + Env: cc.Config.Env, + Expose: expose, + GroupAdd: cc.HostConfig.GroupAdd, + Hostname: cc.Config.Hostname, + ImageVolume: "bind", + Init: init, + Interactive: cc.Config.OpenStdin, + IPC: string(cc.HostConfig.IpcMode), + Label: stringMaptoArray(cc.Config.Labels), + LogDriver: cc.HostConfig.LogConfig.Type, + LogOptions: stringMaptoArray(cc.HostConfig.LogConfig.Config), + Name: cc.Name, + OOMScoreAdj: &cc.HostConfig.OomScoreAdj, + Arch: "", + OS: "", + Variant: "", + PID: string(cc.HostConfig.PidMode), + PIDsLimit: cc.HostConfig.PidsLimit, + Privileged: cc.HostConfig.Privileged, + PublishAll: cc.HostConfig.PublishAllPorts, + Quiet: false, + ReadOnly: cc.HostConfig.ReadonlyRootfs, + ReadOnlyTmpFS: true, // podman default + Rm: cc.HostConfig.AutoRemove, + SecurityOpt: cc.HostConfig.SecurityOpt, + StopSignal: cc.Config.StopSignal, + StorageOpts: stringMaptoArray(cc.HostConfig.StorageOpt), + Sysctl: stringMaptoArray(cc.HostConfig.Sysctls), + Systemd: "true", // podman default + TmpFS: parsedTmp, + TTY: cc.Config.Tty, + UnsetEnv: cc.UnsetEnv, + UnsetEnvAll: cc.UnsetEnvAll, + User: cc.Config.User, + UserNS: string(cc.HostConfig.UsernsMode), + UTS: string(cc.HostConfig.UTSMode), + Mount: mounts, + VolumesFrom: cc.HostConfig.VolumesFrom, + Workdir: cc.Config.WorkingDir, + Net: &netInfo, + HealthInterval: define.DefaultHealthCheckInterval, + HealthRetries: define.DefaultHealthCheckRetries, + HealthTimeout: define.DefaultHealthCheckTimeout, + HealthStartPeriod: define.DefaultHealthCheckStartPeriod, + } + if !rootless.IsRootless() { + var ulimits []string + if len(cc.HostConfig.Ulimits) > 0 { + for _, ul := range cc.HostConfig.Ulimits { + ulimits = append(ulimits, ul.String()) + } + cliOpts.Ulimit = ulimits + } + } + if cc.HostConfig.Resources.NanoCPUs > 0 { + if cliOpts.CPUPeriod != 0 || cliOpts.CPUQuota != 0 { + return nil, nil, errors.Errorf("NanoCpus conflicts with CpuPeriod and CpuQuota") + } + cliOpts.CPUPeriod = 100000 + cliOpts.CPUQuota = cc.HostConfig.Resources.NanoCPUs / 10000 + } + + // volumes + for _, vol := range cc.HostConfig.Binds { + cliOpts.Volume = append(cliOpts.Volume, vol) + // Extract the destination so we don't add duplicate mounts in + // the volumes phase. + splitVol := strings.SplitN(vol, ":", 3) + switch len(splitVol) { + case 1: + volDestinations[vol] = true + default: + volSources[splitVol[0]] = true + volDestinations[splitVol[1]] = true + } + } + // Anonymous volumes are added differently from other volumes, in their + // own special field, for reasons known only to Docker. Still use the + // format of `-v` so we can just append them in there. + // Unfortunately, these may be duplicates of existing mounts in Binds. + // So... We need to catch that. + // This also handles volumes duplicated between cc.HostConfig.Mounts and + // cc.Volumes, as seen in compose v2.0. + for vol := range cc.Volumes { + if _, ok := volDestinations[filepath.Clean(vol)]; ok { + continue + } + cliOpts.Volume = append(cliOpts.Volume, vol) + } + // Make mount points for compat volumes + for vol := range volSources { + // This might be a named volume. + // Assume it is if it's not an absolute path. + if !filepath.IsAbs(vol) { + continue + } + // If volume already exists, there is nothing to do + if _, err := os.Stat(vol); err == nil { + continue + } + if err := os.MkdirAll(vol, 0o755); err != nil { + if !os.IsExist(err) { + return nil, nil, errors.Wrapf(err, "error making volume mountpoint for volume %s", vol) + } + } + } + if len(cc.HostConfig.BlkioWeightDevice) > 0 { + devices := make([]string, 0, len(cc.HostConfig.BlkioWeightDevice)) + for _, d := range cc.HostConfig.BlkioWeightDevice { + devices = append(devices, d.String()) + } + cliOpts.BlkIOWeightDevice = devices + } + if cc.HostConfig.BlkioWeight > 0 { + cliOpts.BlkIOWeight = strconv.Itoa(int(cc.HostConfig.BlkioWeight)) + } + + if cc.HostConfig.Memory > 0 { + cliOpts.Memory = strconv.Itoa(int(cc.HostConfig.Memory)) + } + + if cc.HostConfig.MemoryReservation > 0 { + cliOpts.MemoryReservation = strconv.Itoa(int(cc.HostConfig.MemoryReservation)) + } + + cgroupsv2, err := cgroups.IsCgroup2UnifiedMode() + if err != nil { + return nil, nil, err + } + if cc.HostConfig.MemorySwap > 0 && (!rootless.IsRootless() || (rootless.IsRootless() && cgroupsv2)) { + cliOpts.MemorySwap = strconv.Itoa(int(cc.HostConfig.MemorySwap)) + } + + if cc.Config.StopTimeout != nil { + cliOpts.StopTimeout = uint(*cc.Config.StopTimeout) + } + + if cc.HostConfig.ShmSize > 0 { + cliOpts.ShmSize = strconv.Itoa(int(cc.HostConfig.ShmSize)) + } + + if len(cc.HostConfig.RestartPolicy.Name) > 0 { + policy := cc.HostConfig.RestartPolicy.Name + // only add restart count on failure + if cc.HostConfig.RestartPolicy.IsOnFailure() { + policy += fmt.Sprintf(":%d", cc.HostConfig.RestartPolicy.MaximumRetryCount) + } + cliOpts.Restart = policy + } + + if cc.HostConfig.MemorySwappiness != nil && (!rootless.IsRootless() || rootless.IsRootless() && cgroupsv2 && rtc.Engine.CgroupManager == "systemd") { + cliOpts.MemorySwappiness = *cc.HostConfig.MemorySwappiness + } else { + cliOpts.MemorySwappiness = -1 + } + if cc.HostConfig.OomKillDisable != nil { + cliOpts.OOMKillDisable = *cc.HostConfig.OomKillDisable + } + if cc.Config.Healthcheck != nil { + finCmd := "" + for _, str := range cc.Config.Healthcheck.Test { + finCmd = finCmd + str + " " + } + if len(finCmd) > 1 { + finCmd = finCmd[:len(finCmd)-1] + } + cliOpts.HealthCmd = finCmd + if cc.Config.Healthcheck.Interval > 0 { + cliOpts.HealthInterval = cc.Config.Healthcheck.Interval.String() + } + if cc.Config.Healthcheck.Retries > 0 { + cliOpts.HealthRetries = uint(cc.Config.Healthcheck.Retries) + } + if cc.Config.Healthcheck.StartPeriod > 0 { + cliOpts.HealthStartPeriod = cc.Config.Healthcheck.StartPeriod.String() + } + if cc.Config.Healthcheck.Timeout > 0 { + cliOpts.HealthTimeout = cc.Config.Healthcheck.Timeout.String() + } + } + + // specgen assumes the image name is arg[0] + cmd := []string{cc.Config.Image} + cmd = append(cmd, cc.Config.Cmd...) + return &cliOpts, cmd, nil +} + +// addField is a helper function to populate mount options +func addField(b *strings.Builder, name, value string) { + if value == "" { + return + } + + if b.Len() > 0 { + b.WriteRune(',') + } + b.WriteString(name) + b.WriteRune('=') + b.WriteString(value) +} diff --git a/pkg/api/handlers/compat/events.go b/pkg/api/handlers/compat/events.go index 03b3d54bc..6bcb7bd32 100644 --- a/pkg/api/handlers/compat/events.go +++ b/pkg/api/handlers/compat/events.go @@ -63,7 +63,7 @@ func GetEvents(w http.ResponseWriter, r *http.Request) { errorChannel <- runtime.Events(r.Context(), readOpts) }() - var flush = func() {} + flush := func() {} if flusher, ok := w.(http.Flusher); ok { flush = flusher.Flush } diff --git a/pkg/api/handlers/compat/exec.go b/pkg/api/handlers/compat/exec.go index def16d1b5..a8b45c685 100644 --- a/pkg/api/handlers/compat/exec.go +++ b/pkg/api/handlers/compat/exec.go @@ -11,6 +11,7 @@ import ( "github.com/containers/podman/v4/pkg/api/handlers/utils" "github.com/containers/podman/v4/pkg/api/server/idle" api "github.com/containers/podman/v4/pkg/api/types" + "github.com/containers/podman/v4/pkg/domain/entities" "github.com/containers/podman/v4/pkg/specgenutil" "github.com/gorilla/mux" "github.com/pkg/errors" @@ -93,10 +94,7 @@ func ExecCreateHandler(w http.ResponseWriter, r *http.Request) { return } - resp := new(handlers.ExecCreateResponse) - resp.ID = sessID - - utils.WriteResponse(w, http.StatusCreated, resp) + utils.WriteResponse(w, http.StatusCreated, entities.IDResponse{ID: sessID}) } // ExecInspectHandler inspects a given exec session. diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index a690cdd40..8c4dea327 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -165,7 +165,7 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) { utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "CommitFailure")) return } - utils.WriteResponse(w, http.StatusCreated, handlers.IDResponse{ID: commitImage.ID()}) // nolint + utils.WriteResponse(w, http.StatusCreated, entities.IDResponse{ID: commitImage.ID()}) // nolint } func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 1a0ac6801..bcd102901 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -776,7 +776,7 @@ func extractTarFile(r *http.Request) (string, error) { } path := filepath.Join(anchorDir, "tarBall") - tarBall, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) + tarBall, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600) if err != nil { return "", err } @@ -790,7 +790,7 @@ func extractTarFile(r *http.Request) (string, error) { } buildDir := filepath.Join(anchorDir, "build") - err = os.Mkdir(buildDir, 0700) + err = os.Mkdir(buildDir, 0o700) if err != nil { return "", err } diff --git a/pkg/api/handlers/compat/images_prune.go b/pkg/api/handlers/compat/images_prune.go index 46524fcff..02cadbbbe 100644 --- a/pkg/api/handlers/compat/images_prune.go +++ b/pkg/api/handlers/compat/images_prune.go @@ -17,9 +17,7 @@ import ( ) func PruneImages(w http.ResponseWriter, r *http.Request) { - var ( - filters []string - ) + var filters []string runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) filterMap, err := util.PrepareFilters(r) diff --git a/pkg/api/handlers/compat/info.go b/pkg/api/handlers/compat/info.go index 6286fdaee..85547570a 100644 --- a/pkg/api/handlers/compat/info.go +++ b/pkg/api/handlers/compat/info.go @@ -53,75 +53,76 @@ func GetInfo(w http.ResponseWriter, r *http.Request) { // FIXME: Need to expose if runtime supports Checkpointing // liveRestoreEnabled := criu.CheckForCriu() && configInfo.RuntimeSupportsCheckpoint() - info := &handlers.Info{Info: docker.Info{ - Architecture: goRuntime.GOARCH, - BridgeNfIP6tables: !sysInfo.BridgeNFCallIP6TablesDisabled, - BridgeNfIptables: !sysInfo.BridgeNFCallIPTablesDisabled, - CPUCfsPeriod: sysInfo.CPUCfsPeriod, - CPUCfsQuota: sysInfo.CPUCfsQuota, - CPUSet: sysInfo.Cpuset, - CPUShares: sysInfo.CPUShares, - CgroupDriver: configInfo.Engine.CgroupManager, - ClusterAdvertise: "", - ClusterStore: "", - ContainerdCommit: docker.Commit{}, - Containers: infoData.Store.ContainerStore.Number, - ContainersPaused: stateInfo[define.ContainerStatePaused], - ContainersRunning: stateInfo[define.ContainerStateRunning], - ContainersStopped: stateInfo[define.ContainerStateStopped] + stateInfo[define.ContainerStateExited], - Debug: log.IsLevelEnabled(log.DebugLevel), - DefaultRuntime: configInfo.Engine.OCIRuntime, - DockerRootDir: infoData.Store.GraphRoot, - Driver: infoData.Store.GraphDriverName, - DriverStatus: getGraphStatus(infoData.Store.GraphStatus), - ExperimentalBuild: true, - GenericResources: nil, - HTTPProxy: getEnv("http_proxy"), - HTTPSProxy: getEnv("https_proxy"), - ID: uuid.New().String(), - IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled, - Images: infoData.Store.ImageStore.Number, - IndexServerAddress: "", - InitBinary: "", - InitCommit: docker.Commit{}, - Isolation: "", - KernelMemoryTCP: false, - KernelVersion: infoData.Host.Kernel, - Labels: nil, - LiveRestoreEnabled: false, - LoggingDriver: "", - MemTotal: infoData.Host.MemTotal, - MemoryLimit: sysInfo.MemoryLimit, - NCPU: goRuntime.NumCPU(), - NEventsListener: 0, - NFd: getFdCount(), - NGoroutines: goRuntime.NumGoroutine(), - Name: infoData.Host.Hostname, - NoProxy: getEnv("no_proxy"), - OSType: goRuntime.GOOS, - OSVersion: infoData.Host.Distribution.Version, - OomKillDisable: sysInfo.OomKillDisable, - OperatingSystem: infoData.Host.Distribution.Distribution, - PidsLimit: sysInfo.PidsLimit, - Plugins: docker.PluginsInfo{ - Volume: infoData.Plugins.Volume, - Network: infoData.Plugins.Network, - Log: infoData.Plugins.Log, + info := &handlers.Info{ + Info: docker.Info{ + Architecture: goRuntime.GOARCH, + BridgeNfIP6tables: !sysInfo.BridgeNFCallIP6TablesDisabled, + BridgeNfIptables: !sysInfo.BridgeNFCallIPTablesDisabled, + CPUCfsPeriod: sysInfo.CPUCfsPeriod, + CPUCfsQuota: sysInfo.CPUCfsQuota, + CPUSet: sysInfo.Cpuset, + CPUShares: sysInfo.CPUShares, + CgroupDriver: configInfo.Engine.CgroupManager, + ClusterAdvertise: "", + ClusterStore: "", + ContainerdCommit: docker.Commit{}, + Containers: infoData.Store.ContainerStore.Number, + ContainersPaused: stateInfo[define.ContainerStatePaused], + ContainersRunning: stateInfo[define.ContainerStateRunning], + ContainersStopped: stateInfo[define.ContainerStateStopped] + stateInfo[define.ContainerStateExited], + Debug: log.IsLevelEnabled(log.DebugLevel), + DefaultRuntime: configInfo.Engine.OCIRuntime, + DockerRootDir: infoData.Store.GraphRoot, + Driver: infoData.Store.GraphDriverName, + DriverStatus: getGraphStatus(infoData.Store.GraphStatus), + ExperimentalBuild: true, + GenericResources: nil, + HTTPProxy: getEnv("http_proxy"), + HTTPSProxy: getEnv("https_proxy"), + ID: uuid.New().String(), + IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled, + Images: infoData.Store.ImageStore.Number, + IndexServerAddress: "", + InitBinary: "", + InitCommit: docker.Commit{}, + Isolation: "", + KernelMemoryTCP: false, + KernelVersion: infoData.Host.Kernel, + Labels: nil, + LiveRestoreEnabled: false, + LoggingDriver: "", + MemTotal: infoData.Host.MemTotal, + MemoryLimit: sysInfo.MemoryLimit, + NCPU: goRuntime.NumCPU(), + NEventsListener: 0, + NFd: getFdCount(), + NGoroutines: goRuntime.NumGoroutine(), + Name: infoData.Host.Hostname, + NoProxy: getEnv("no_proxy"), + OSType: goRuntime.GOOS, + OSVersion: infoData.Host.Distribution.Version, + OomKillDisable: sysInfo.OomKillDisable, + OperatingSystem: infoData.Host.Distribution.Distribution, + PidsLimit: sysInfo.PidsLimit, + Plugins: docker.PluginsInfo{ + Volume: infoData.Plugins.Volume, + Network: infoData.Plugins.Network, + Log: infoData.Plugins.Log, + }, + ProductLicense: "Apache-2.0", + RegistryConfig: getServiceConfig(runtime), + RuncCommit: docker.Commit{}, + Runtimes: getRuntimes(configInfo), + SecurityOptions: getSecOpts(sysInfo), + ServerVersion: versionInfo.Version, + SwapLimit: sysInfo.SwapLimit, + Swarm: swarm.Info{ + LocalNodeState: swarm.LocalNodeStateInactive, + }, + SystemStatus: nil, + SystemTime: time.Now().Format(time.RFC3339Nano), + Warnings: []string{}, }, - ProductLicense: "Apache-2.0", - RegistryConfig: getServiceConfig(runtime), - RuncCommit: docker.Commit{}, - Runtimes: getRuntimes(configInfo), - SecurityOptions: getSecOpts(sysInfo), - ServerVersion: versionInfo.Version, - SwapLimit: sysInfo.SwapLimit, - Swarm: swarm.Info{ - LocalNodeState: swarm.LocalNodeStateInactive, - }, - SystemStatus: nil, - SystemTime: time.Now().Format(time.RFC3339Nano), - Warnings: []string{}, - }, BuildahVersion: infoData.Host.BuildahVersion, CPURealtimePeriod: sysInfo.CPURealtimePeriod, CPURealtimeRuntime: sysInfo.CPURealtimeRuntime, @@ -186,7 +187,7 @@ func getSecOpts(sysInfo *sysinfo.SysInfo) []string { } func getRuntimes(configInfo *config.Config) map[string]docker.Runtime { - var runtimes = map[string]docker.Runtime{} + runtimes := map[string]docker.Runtime{} for name, paths := range configInfo.Engine.OCIRuntimes { runtimes[name] = docker.Runtime{ Path: paths[0], @@ -206,7 +207,7 @@ func getFdCount() (count int) { // Just ignoring Container errors here... func getContainersState(r *libpod.Runtime) map[define.ContainerStatus]int { - var states = map[define.ContainerStatus]int{} + states := map[define.ContainerStatus]int{} ctnrs, err := r.GetAllContainers() if err == nil { for _, ctnr := range ctnrs { diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go index 89d914e0a..6fdd5c6a7 100644 --- a/pkg/api/handlers/compat/networks.go +++ b/pkg/api/handlers/compat/networks.go @@ -298,9 +298,7 @@ func RemoveNetwork(w http.ResponseWriter, r *http.Request) { func Connect(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) - var ( - netConnect types.NetworkConnect - ) + var netConnect types.NetworkConnect if err := json.NewDecoder(r.Body).Decode(&netConnect); err != nil { utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()")) return diff --git a/pkg/api/handlers/compat/secrets.go b/pkg/api/handlers/compat/secrets.go index 0c2306dc8..5031bf76b 100644 --- a/pkg/api/handlers/compat/secrets.go +++ b/pkg/api/handlers/compat/secrets.go @@ -16,9 +16,7 @@ import ( ) func ListSecrets(w http.ResponseWriter, r *http.Request) { - var ( - runtime = r.Context().Value(api.RuntimeKey).(*libpod.Runtime) - ) + runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) filtersMap, err := util.PrepareFilters(r) if err != nil { utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String())) @@ -51,9 +49,7 @@ func ListSecrets(w http.ResponseWriter, r *http.Request) { } func InspectSecret(w http.ResponseWriter, r *http.Request) { - var ( - runtime = r.Context().Value(api.RuntimeKey).(*libpod.Runtime) - ) + runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) name := utils.GetName(r) names := []string{name} ic := abi.ContainerEngine{Libpod: runtime} @@ -84,9 +80,7 @@ func InspectSecret(w http.ResponseWriter, r *http.Request) { } func RemoveSecret(w http.ResponseWriter, r *http.Request) { - var ( - runtime = r.Context().Value(api.RuntimeKey).(*libpod.Runtime) - ) + runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) opts := entities.SecretRmOptions{} name := utils.GetName(r) @@ -104,9 +98,7 @@ func RemoveSecret(w http.ResponseWriter, r *http.Request) { } func CreateSecret(w http.ResponseWriter, r *http.Request) { - var ( - runtime = r.Context().Value(api.RuntimeKey).(*libpod.Runtime) - ) + runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) opts := entities.SecretCreateOptions{} createParams := struct { *entities.SecretCreateRequest diff --git a/pkg/api/handlers/compat/swagger.go b/pkg/api/handlers/compat/swagger.go deleted file mode 100644 index 86527da6e..000000000 --- a/pkg/api/handlers/compat/swagger.go +++ /dev/null @@ -1,67 +0,0 @@ -package compat - -import ( - "github.com/containers/podman/v4/pkg/domain/entities" - "github.com/docker/docker/api/types" -) - -// Create container -// swagger:response ContainerCreateResponse -type swagCtrCreateResponse struct { - // in:body - Body struct { - entities.ContainerCreateResponse - } -} - -// Wait container -// swagger:response ContainerWaitResponse -type swagCtrWaitResponse struct { - // in:body - Body struct { - // container exit code - StatusCode int - Error struct { - Message string - } - } -} - -// Network inspect -// swagger:response CompatNetworkInspect -type swagCompatNetworkInspect struct { - // in:body - Body types.NetworkResource -} - -// Network list -// swagger:response CompatNetworkList -type swagCompatNetworkList struct { - // in:body - Body []types.NetworkResource -} - -// Network create -// swagger:model NetworkCreateRequest -type NetworkCreateRequest struct { - types.NetworkCreateRequest -} - -// Network create -// swagger:response CompatNetworkCreate -type swagCompatNetworkCreateResponse struct { - // in:body - Body struct{ types.NetworkCreate } -} - -// Network disconnect -// swagger:model NetworkCompatConnectRequest -type swagCompatNetworkConnectRequest struct { - types.NetworkConnect -} - -// Network disconnect -// swagger:model NetworkCompatDisconnectRequest -type swagCompatNetworkDisconnectRequest struct { - types.NetworkDisconnect -} diff --git a/pkg/api/handlers/compat/version.go b/pkg/api/handlers/compat/version.go index b113fbc90..cfc3468c2 100644 --- a/pkg/api/handlers/compat/version.go +++ b/pkg/api/handlers/compat/version.go @@ -57,13 +57,15 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) { Version: conmon.Version, Details: map[string]string{ "Package": conmon.Package, - }}, + }, + }, { Name: fmt.Sprintf("OCI Runtime (%s)", oci.Name), Version: oci.Version, Details: map[string]string{ "Package": oci.Package, - }}, + }, + }, } components = append(components, additional...) } @@ -89,5 +91,6 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) { MinAPIVersion: fmt.Sprintf("%d.%d", minVersion.Major, minVersion.Minor), Os: components[0].Details["Os"], Version: components[0].Version, - }}) + }, + }) } diff --git a/pkg/api/handlers/compat/volumes.go b/pkg/api/handlers/compat/volumes.go index c8e4339b0..ff0a7af02 100644 --- a/pkg/api/handlers/compat/volumes.go +++ b/pkg/api/handlers/compat/volumes.go @@ -180,9 +180,7 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) { } func InspectVolume(w http.ResponseWriter, r *http.Request) { - var ( - runtime = r.Context().Value(api.RuntimeKey).(*libpod.Runtime) - ) + runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) name := utils.GetName(r) vol, err := runtime.GetVolume(name) if err != nil { @@ -263,9 +261,7 @@ func RemoveVolume(w http.ResponseWriter, r *http.Request) { } func PruneVolumes(w http.ResponseWriter, r *http.Request) { - var ( - runtime = r.Context().Value(api.RuntimeKey).(*libpod.Runtime) - ) + runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) filterMap, err := util.PrepareFilters(r) if err != nil { utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()")) diff --git a/pkg/api/handlers/libpod/containers.go b/pkg/api/handlers/libpod/containers.go index 03dd436f6..6b5bee403 100644 --- a/pkg/api/handlers/libpod/containers.go +++ b/pkg/api/handlers/libpod/containers.go @@ -168,6 +168,7 @@ func UnmountContainer(w http.ResponseWriter, r *http.Request) { } utils.WriteResponse(w, http.StatusNoContent, "") } + func MountContainer(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) name := utils.GetName(r) diff --git a/pkg/api/handlers/libpod/generate.go b/pkg/api/handlers/libpod/generate.go index 28785b00d..b1ac6a65a 100644 --- a/pkg/api/handlers/libpod/generate.go +++ b/pkg/api/handlers/libpod/generate.go @@ -41,17 +41,17 @@ func GenerateSystemd(w http.ResponseWriter, r *http.Request) { return } - var ContainerPrefix = "container" + ContainerPrefix := "container" if query.ContainerPrefix != nil { ContainerPrefix = *query.ContainerPrefix } - var PodPrefix = "pod" + PodPrefix := "pod" if query.PodPrefix != nil { PodPrefix = *query.PodPrefix } - var Separator = "-" + Separator := "-" if query.Separator != nil { Separator = *query.Separator } @@ -106,5 +106,7 @@ func GenerateKube(w http.ResponseWriter, r *http.Request) { return } + // FIXME: Content-Type is being set as application/x-tar NOT text/vnd.yaml + // https://mailarchive.ietf.org/arch/msg/media-types/e9ZNC0hDXKXeFlAVRWxLCCaG9GI/ utils.WriteResponse(w, http.StatusOK, report.Reader) } diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go index cddf4c205..efcbe9d77 100644 --- a/pkg/api/handlers/libpod/images.go +++ b/pkg/api/handlers/libpod/images.go @@ -102,9 +102,7 @@ func GetImage(w http.ResponseWriter, r *http.Request) { } func PruneImages(w http.ResponseWriter, r *http.Request) { - var ( - err error - ) + var err error runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder) query := struct { @@ -129,7 +127,7 @@ func PruneImages(w http.ResponseWriter, r *http.Request) { return } - var libpodFilters = []string{} + libpodFilters := []string{} if _, found := r.URL.Query()["filters"]; found { dangling := (*filterMap)["all"] if len(dangling) > 0 { @@ -162,9 +160,7 @@ func PruneImages(w http.ResponseWriter, r *http.Request) { } func ExportImage(w http.ResponseWriter, r *http.Request) { - var ( - output string - ) + var output string runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder) query := struct { @@ -243,9 +239,7 @@ func ExportImage(w http.ResponseWriter, r *http.Request) { } func ExportImages(w http.ResponseWriter, r *http.Request) { - var ( - output string - ) + var output string runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder) query := struct { @@ -566,7 +560,7 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) { utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "CommitFailure")) return } - utils.WriteResponse(w, http.StatusOK, handlers.IDResponse{ID: commitImage.ID()}) // nolint + utils.WriteResponse(w, http.StatusOK, entities.IDResponse{ID: commitImage.ID()}) // nolint } func UntagImage(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/api/handlers/libpod/manifests.go b/pkg/api/handlers/libpod/manifests.go index 8dc7c57d5..65b9d6cb5 100644 --- a/pkg/api/handlers/libpod/manifests.go +++ b/pkg/api/handlers/libpod/manifests.go @@ -88,7 +88,7 @@ func ManifestCreate(w http.ResponseWriter, r *http.Request) { // Treat \r\n as empty body if len(buffer) < 3 { - utils.WriteResponse(w, status, handlers.IDResponse{ID: manID}) + utils.WriteResponse(w, status, entities.IDResponse{ID: manID}) return } @@ -113,7 +113,7 @@ func ManifestCreate(w http.ResponseWriter, r *http.Request) { return } - utils.WriteResponse(w, status, handlers.IDResponse{ID: id}) + utils.WriteResponse(w, status, entities.IDResponse{ID: id}) } // ManifestExists return true if manifest list exists. @@ -204,7 +204,7 @@ func ManifestAddV3(w http.ResponseWriter, r *http.Request) { utils.InternalServerError(w, err) return } - utils.WriteResponse(w, http.StatusOK, handlers.IDResponse{ID: newID}) + utils.WriteResponse(w, http.StatusOK, entities.IDResponse{ID: newID}) } // ManifestRemoveDigestV3 remove digest from manifest list @@ -238,7 +238,7 @@ func ManifestRemoveDigestV3(w http.ResponseWriter, r *http.Request) { utils.InternalServerError(w, err) return } - utils.WriteResponse(w, http.StatusOK, handlers.IDResponse{ID: manifestList.ID()}) + utils.WriteResponse(w, http.StatusOK, entities.IDResponse{ID: manifestList.ID()}) } // ManifestPushV3 push image to registry @@ -294,7 +294,7 @@ func ManifestPushV3(w http.ResponseWriter, r *http.Request) { utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "error pushing image %q", query.Destination)) return } - utils.WriteResponse(w, http.StatusOK, handlers.IDResponse{ID: digest}) + utils.WriteResponse(w, http.StatusOK, entities.IDResponse{ID: digest}) } // ManifestPush push image to registry @@ -353,7 +353,7 @@ func ManifestPush(w http.ResponseWriter, r *http.Request) { utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "error pushing image %q", destination)) return } - utils.WriteResponse(w, http.StatusOK, handlers.IDResponse{ID: digest}) + utils.WriteResponse(w, http.StatusOK, entities.IDResponse{ID: digest}) } // ManifestModify efficiently updates the named manifest list diff --git a/pkg/api/handlers/libpod/pods.go b/pkg/api/handlers/libpod/pods.go index d522631b7..5b92358fa 100644 --- a/pkg/api/handlers/libpod/pods.go +++ b/pkg/api/handlers/libpod/pods.go @@ -81,7 +81,7 @@ func PodCreate(w http.ResponseWriter, r *http.Request) { utils.Error(w, httpCode, errors.Wrap(err, "failed to make pod")) return } - utils.WriteResponse(w, http.StatusCreated, handlers.IDResponse{ID: pod.ID()}) + utils.WriteResponse(w, http.StatusCreated, entities.IDResponse{ID: pod.ID()}) } func Pods(w http.ResponseWriter, r *http.Request) { @@ -290,9 +290,7 @@ func PodPrune(w http.ResponseWriter, r *http.Request) { } func PodPruneHelper(r *http.Request) ([]*entities.PodPruneReport, error) { - var ( - runtime = r.Context().Value(api.RuntimeKey).(*libpod.Runtime) - ) + runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) responses, err := runtime.PrunePods(r.Context()) if err != nil { return nil, err @@ -414,7 +412,7 @@ loop: // break out of for/select infinite` loop } if len(output) > 0 { - var body = handlers.PodTopOKBody{} + body := handlers.PodTopOKBody{} body.Titles = strings.Split(output[0], "\t") for i := range body.Titles { body.Titles[i] = strings.TrimSpace(body.Titles[i]) diff --git a/pkg/api/handlers/libpod/swagger.go b/pkg/api/handlers/libpod/swagger.go deleted file mode 100644 index 5f33e6c01..000000000 --- a/pkg/api/handlers/libpod/swagger.go +++ /dev/null @@ -1,157 +0,0 @@ -package libpod - -import ( - "net/http" - "os" - - "github.com/containers/common/libnetwork/types" - "github.com/containers/image/v5/manifest" - "github.com/containers/podman/v4/libpod/define" - "github.com/containers/podman/v4/pkg/api/handlers/utils" - "github.com/containers/podman/v4/pkg/domain/entities" - "github.com/pkg/errors" -) - -// DefaultPodmanSwaggerSpec provides the default path to the podman swagger spec file -const DefaultPodmanSwaggerSpec = "/usr/share/containers/podman/swagger.yaml" - -// List Containers -// swagger:response ListContainers -type swagInspectPodResponse struct { - // in:body - Body []entities.ListContainer -} - -// Inspect Manifest -// swagger:response InspectManifest -type swagInspectManifestResponse struct { - // in:body - Body manifest.Schema2List -} - -// Kill Pod -// swagger:response PodKillReport -type swagKillPodResponse struct { - // in:body - Body entities.PodKillReport -} - -// Pause pod -// swagger:response PodPauseReport -type swagPausePodResponse struct { - // in:body - Body entities.PodPauseReport -} - -// Unpause pod -// swagger:response PodUnpauseReport -type swagUnpausePodResponse struct { - // in:body - Body entities.PodUnpauseReport -} - -// Stop pod -// swagger:response PodStopReport -type swagStopPodResponse struct { - // in:body - Body entities.PodStopReport -} - -// Restart pod -// swagger:response PodRestartReport -type swagRestartPodResponse struct { - // in:body - Body entities.PodRestartReport -} - -// Start pod -// swagger:response PodStartReport -type swagStartPodResponse struct { - // in:body - Body entities.PodStartReport -} - -// Prune pod -// swagger:response PodPruneReport -type swagPrunePodResponse struct { - // in:body - Body entities.PodPruneReport -} - -// Rm pod -// swagger:response PodRmReport -type swagRmPodResponse struct { - // in:body - Body entities.PodRmReport -} - -// Info -// swagger:response InfoResponse -type swagInfoResponse struct { - // in:body - Body define.Info -} - -// Network rm -// swagger:response NetworkRmReport -type swagNetworkRmReport struct { - // in:body - Body []entities.NetworkRmReport -} - -// Network inspect -// swagger:response NetworkInspectReport -type swagNetworkInspectReport struct { - // in:body - Body types.Network -} - -// Network list -// swagger:response NetworkListReport -type swagNetworkListReport struct { - // in:body - Body []types.Network -} - -// Network create -// swagger:model NetworkCreateLibpod -type swagNetworkCreateLibpod struct { - types.Network -} - -// Network create -// swagger:response NetworkCreateReport -type swagNetworkCreateReport struct { - // in:body - Body types.Network -} - -// Network prune -// swagger:response NetworkPruneResponse -type swagNetworkPruneResponse struct { - // in:body - Body []entities.NetworkPruneReport -} - -// Network connect -// swagger:model NetworkConnectRequest -type swagNetworkConnectRequest struct { - entities.NetworkConnectOptions -} - -func ServeSwagger(w http.ResponseWriter, r *http.Request) { - path := DefaultPodmanSwaggerSpec - if p, found := os.LookupEnv("PODMAN_SWAGGER_SPEC"); found { - path = p - } - if _, err := os.Stat(path); err != nil { - if os.IsNotExist(err) { - utils.InternalServerError(w, errors.Errorf("file %q does not exist", path)) - return - } - utils.InternalServerError(w, err) - return - } - w.Header().Set("Content-Type", "text/yaml") - http.ServeFile(w, r, path) -} diff --git a/pkg/api/handlers/libpod/swagger_spec.go b/pkg/api/handlers/libpod/swagger_spec.go new file mode 100644 index 000000000..8eeb041d2 --- /dev/null +++ b/pkg/api/handlers/libpod/swagger_spec.go @@ -0,0 +1,29 @@ +package libpod + +import ( + "net/http" + "os" + + "github.com/containers/podman/v4/pkg/api/handlers/utils" + "github.com/pkg/errors" +) + +// DefaultPodmanSwaggerSpec provides the default path to the podman swagger spec file +const DefaultPodmanSwaggerSpec = "/usr/share/containers/podman/swagger.yaml" + +func ServeSwagger(w http.ResponseWriter, r *http.Request) { + path := DefaultPodmanSwaggerSpec + if p, found := os.LookupEnv("PODMAN_SWAGGER_SPEC"); found { + path = p + } + if _, err := os.Stat(path); err != nil { + if errors.Is(err, os.ErrNotExist) { + utils.InternalServerError(w, errors.Errorf("swagger spec %q does not exist", path)) + return + } + utils.InternalServerError(w, err) + return + } + w.Header().Set("Content-Type", "text/yaml") + http.ServeFile(w, r, path) +} diff --git a/pkg/api/handlers/libpod/volumes.go b/pkg/api/handlers/libpod/volumes.go index e0ea16d82..e792dea35 100644 --- a/pkg/api/handlers/libpod/volumes.go +++ b/pkg/api/handlers/libpod/volumes.go @@ -25,8 +25,7 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) { runtime = r.Context().Value(api.RuntimeKey).(*libpod.Runtime) decoder = r.Context().Value(api.DecoderKey).(*schema.Decoder) ) - query := struct { - }{ + query := struct{}{ // override any golang type defaults } if err := decoder.Decode(&query, r.URL.Query()); err != nil { @@ -86,9 +85,7 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) { } func InspectVolume(w http.ResponseWriter, r *http.Request) { - var ( - runtime = r.Context().Value(api.RuntimeKey).(*libpod.Runtime) - ) + runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) name := utils.GetName(r) vol, err := runtime.GetVolume(name) if err != nil { @@ -107,9 +104,7 @@ func InspectVolume(w http.ResponseWriter, r *http.Request) { } func ListVolumes(w http.ResponseWriter, r *http.Request) { - var ( - runtime = r.Context().Value(api.RuntimeKey).(*libpod.Runtime) - ) + runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) filterMap, err := util.PrepareFilters(r) if err != nil { utils.Error(w, http.StatusInternalServerError, @@ -153,9 +148,7 @@ func PruneVolumes(w http.ResponseWriter, r *http.Request) { } func pruneVolumesHelper(r *http.Request) ([]*reports.PruneReport, error) { - var ( - runtime = r.Context().Value(api.RuntimeKey).(*libpod.Runtime) - ) + runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) filterMap, err := util.PrepareFilters(r) if err != nil { return nil, err diff --git a/pkg/api/handlers/swagger/doc.go b/pkg/api/handlers/swagger/doc.go new file mode 100644 index 000000000..67ede275a --- /dev/null +++ b/pkg/api/handlers/swagger/doc.go @@ -0,0 +1,17 @@ +// Package swagger defines the payloads used by the Podman API +// +// - errors.go: declares the errors used in the API. By embedding errors.ErrorModel, more meaningful +// comments can be provided for the developer documentation. +// - models.go: declares the models used in API requests. +// - responses.go: declares the responses used in the API responses. +// +// +// Notes: +// 1. As a developer of the Podman API, you are responsible for maintaining the associations between +// these models and responses, and the handler code. +// 2. There are a number of warnings produces when compiling the swagger yaml file. This is expected. +// Most are because embedded structs have been discovered but not used in the API declarations. +// 3. Response and model references that are exported (start with upper-case letter) imply that they +// exist outside this package and should be found in the entities package. +// +package swagger diff --git a/pkg/api/handlers/swagger/errors.go b/pkg/api/handlers/swagger/errors.go new file mode 100644 index 000000000..28e11c9fb --- /dev/null +++ b/pkg/api/handlers/swagger/errors.go @@ -0,0 +1,116 @@ +//nolint:deadcode,unused // these types are used to wire generated swagger to API code +package swagger + +import ( + "github.com/containers/podman/v4/pkg/errorhandling" +) + +// Error model embedded in swagger:response to aid in documentation generation + +// No such image +// swagger:response +type imageNotFound struct { + // in:body + Body errorhandling.ErrorModel +} + +// No such container +// swagger:response +type containerNotFound struct { + // in:body + Body errorhandling.ErrorModel +} + +// No such network +// swagger:response +type networkNotFound struct { + // in:body + Body errorhandling.ErrorModel +} + +// No such exec instance +// swagger:response +type execSessionNotFound struct { + // in:body + Body errorhandling.ErrorModel +} + +// No such volume +// swagger:response +type volumeNotFound struct { + // in:body + Body errorhandling.ErrorModel +} + +// No such pod +// swagger:response +type podNotFound struct { + // in:body + Body errorhandling.ErrorModel +} + +// No such manifest +// swagger:response +type manifestNotFound struct { + // in:body + Body errorhandling.ErrorModel +} + +// Internal server error +// swagger:response +type internalError struct { + // in:body + Body errorhandling.ErrorModel +} + +// Conflict error in operation +// swagger:response +type conflictError struct { + // in:body + Body errorhandling.ErrorModel +} + +// Bad parameter in request +// swagger:response +type badParamError struct { + // in:body + Body errorhandling.ErrorModel +} + +// Container already started +// swagger:response +type containerAlreadyStartedError struct { + // in:body + Body errorhandling.ErrorModel +} + +// Container already stopped +// swagger:response +type containerAlreadyStoppedError struct { + // in:body + Body errorhandling.ErrorModel +} + +// Pod already started +// swagger:response +type podAlreadyStartedError struct { + // in:body + Body errorhandling.ErrorModel +} + +// Pod already stopped +// swagger:response +type podAlreadyStoppedError struct { + // in:body + Body errorhandling.ErrorModel +} + +// Success +// swagger:response +type ok struct { + // in:body + Body struct { + // example: OK + ok string + } +} diff --git a/pkg/api/handlers/swagger/models.go b/pkg/api/handlers/swagger/models.go new file mode 100644 index 000000000..a05e57dff --- /dev/null +++ b/pkg/api/handlers/swagger/models.go @@ -0,0 +1,46 @@ +//nolint:deadcode,unused // these types are used to wire generated swagger to API code +package swagger + +import ( + "github.com/containers/podman/v4/pkg/domain/entities" + "github.com/docker/docker/api/types" +) + +// Details for creating a volume +// swagger:model +type volumeCreate struct { + // Name of the volume driver to use. + // Required: true + Driver string `json:"Driver"` + + // A mapping of driver options and values. These options are + // passed directly to the driver and are driver specific. + // + // Required: true + DriverOpts map[string]string `json:"DriverOpts"` + + // User-defined key/value metadata. + // Required: true + Labels map[string]string `json:"Labels"` + + // The new volume's name. If not specified, Docker generates a name. + // + // Required: true + Name string `json:"Name"` +} + +// Network create +// swagger:model +type networkCreate types.NetworkCreateRequest + +// Network connect +// swagger:model +type networkConnectRequest types.NetworkConnect + +// Network disconnect +// swagger:model +type networkDisconnectRequest types.NetworkDisconnect + +// Network connect +// swagger:model +type networkConnectRequestLibpod entities.NetworkConnectOptions diff --git a/pkg/api/handlers/swagger/responses.go b/pkg/api/handlers/swagger/responses.go new file mode 100644 index 000000000..55fc1a77f --- /dev/null +++ b/pkg/api/handlers/swagger/responses.go @@ -0,0 +1,453 @@ +//nolint:deadcode,unused // these types are used to wire generated swagger to API code +package swagger + +import ( + "github.com/containers/common/libnetwork/types" + "github.com/containers/image/v5/manifest" + "github.com/containers/podman/v4/libpod/define" + "github.com/containers/podman/v4/pkg/api/handlers" + "github.com/containers/podman/v4/pkg/domain/entities" + "github.com/containers/podman/v4/pkg/domain/entities/reports" + "github.com/containers/podman/v4/pkg/inspect" + dockerAPI "github.com/docker/docker/api/types" + dockerVolume "github.com/docker/docker/api/types/volume" +) + +// Image Tree +// swagger:response +type treeResponse struct { + // in:body + Body entities.ImageTreeReport +} + +// Image History +// swagger:response +type history struct { + // in:body + Body handlers.HistoryResponse +} + +// Image Inspect +// swagger:response +type imageInspect struct { + // in:body + Body handlers.ImageInspect +} + +// Image Load +// swagger:response +type imagesLoadResponseLibpod struct { + // in:body + Body entities.ImageLoadReport +} + +// Image Import +// swagger:response +type imagesImportResponseLibpod struct { + // in:body + Body entities.ImageImportReport +} + +// Image Pull +// swagger:response +type imagesPullResponseLibpod struct { + // in:body + Body handlers.LibpodImagesPullReport +} + +// Image Remove +// swagger:response +type imagesRemoveResponseLibpod struct { + // in:body + Body handlers.LibpodImagesRemoveReport +} + +// PlayKube response +// swagger:response +type playKubeResponseLibpod struct { + // in:body + Body entities.PlayKubeReport +} + +// Image Delete +// swagger:response +type imageDeleteResponse struct { + // in:body + Body []struct { + Untagged []string `json:"untagged"` + Deleted string `json:"deleted"` + } +} + +// Registry Search +// swagger:response +type registrySearchResponse struct { + // in:body + Body struct { + // Index is the image index + // example: quay.io + Index string + // Name is the canonical name of the image + // example: docker.io/library/alpine" + Name string + // Description of the image. + Description string + // Stars is the number of stars of the image. + Stars int + // Official indicates if it's an official image. + Official string + // Automated indicates if the image was created by an automated build. + Automated string + // Tag is the image tag + Tag string + } +} + +// Inspect Image +// swagger:response +type inspectImageResponseLibpod struct { + // in:body + Body inspect.ImageData +} + +// Inspect container +// swagger:response +type containerInspectResponse struct { + // in:body + Body dockerAPI.ContainerJSON +} + +// List processes in container +// swagger:response +type containerTopResponse struct { + // in:body + Body handlers.ContainerTopOKBody +} + +// List processes in pod +// swagger:response +type podTopResponse struct { + // in:body + Body handlers.PodTopOKBody +} + +// Pod Statistics +// swagger:response +type podStatsResponse struct { + // in:body + Body []entities.PodStatsReport +} + +// Inspect container +// swagger:response +type containerInspectResponseLibpod struct { + // in:body + Body define.InspectContainerData +} + +// List pods +// swagger:response +type podsListResponse struct { + // in:body + Body []entities.ListPodsReport +} + +// Inspect pod +// swagger:response +type podInspectResponse struct { + // in:body + Body define.InspectPodData +} + +// Volume details +// swagger:response +type volumeCreateResponse struct { + // in:body + Body entities.VolumeConfigResponse +} + +// Healthcheck Results +// swagger:response +type healthCheck struct { + // in:body + Body define.HealthCheckResults +} + +// Version +// swagger:response +type versionResponse struct { + // in:body + Body entities.ComponentVersion +} + +// Disk usage +// swagger:response +type systemDiskUsage struct { + // in:body + Body entities.SystemDfReport +} + +// System Prune results +// swagger:response +type systemPruneResponse struct { + // in:body + Body entities.SystemPruneReport +} + +// Auth response +// swagger:response +type systemAuthResponse struct { + // in:body + Body entities.AuthReport +} + +// Exec Session Inspect +// swagger:response +type execSessionInspect struct { + // in:body + Body define.InspectExecSession +} + +// Image summary for compat API +// swagger:response +type imageList struct { + // in:body + Body []dockerAPI.ImageSummary +} + +// Image summary for libpod API +// swagger:response +type imageListLibpod struct { + // in:body + Body []entities.ImageSummary +} + +// List Containers +// swagger:response +type containersList struct { + // in:body + Body []handlers.Container +} + +// This response definition is used for both the create and inspect endpoints +// swagger:response +type volumeInspect struct { + // in:body + Body dockerAPI.Volume +} + +// Volume prune +// swagger:response +type volumePruneResponse struct { + // in:body + Body dockerAPI.VolumesPruneReport +} + +// Volume List +// swagger:response +type volumeList struct { + // in:body + Body dockerVolume.VolumeListOKBody +} + +// Volume list +// swagger:response +type volumeListLibpod struct { + // in:body + Body []entities.VolumeConfigResponse +} + +// Image Prune +// swagger:response +type imagesPruneLibpod struct { + // in:body + Body []reports.PruneReport +} + +// Remove Containers +// swagger:response +type containerRemoveLibpod struct { + // in: body + Body []handlers.LibpodContainersRmReport +} + +// Prune Containers +// swagger:response +type containersPrune struct { + // in: body + Body []handlers.ContainersPruneReport +} + +// Prune Containers +// swagger:response +type containersPruneLibpod struct { + // in: body + Body []handlers.ContainersPruneReportLibpod +} + +// Get stats for one or more containers +// swagger:response +type containerStats struct { + // in:body + Body define.ContainerStats +} + +// Volume Prune +// swagger:response +type volumePruneLibpod struct { + // in:body + Body []reports.PruneReport +} + +// Create container +// swagger:response +type containerCreateResponse struct { + // in:body + Body entities.ContainerCreateResponse +} + +// Wait container +// swagger:response +type containerWaitResponse struct { + // in:body + Body struct { + // container exit code + StatusCode int + Error struct { + Message string + } + } +} + +// Network inspect +// swagger:response +type networkInspectCompat struct { + // in:body + Body dockerAPI.NetworkResource +} + +// Network list +// swagger:response +type networkListCompat struct { + // in:body + Body []dockerAPI.NetworkResource +} + +// List Containers +// swagger:response +type containersListLibpod struct { + // in:body + Body []entities.ListContainer +} + +// Inspect Manifest +// swagger:response +type manifestInspect struct { + // in:body + Body manifest.Schema2List +} + +// Kill Pod +// swagger:response +type podKillResponse struct { + // in:body + Body entities.PodKillReport +} + +// Pause pod +// swagger:response +type podPauseResponse struct { + // in:body + Body entities.PodPauseReport +} + +// Unpause pod +// swagger:response +type podUnpauseResponse struct { + // in:body + Body entities.PodUnpauseReport +} + +// Stop pod +// swagger:response +type podStopResponse struct { + // in:body + Body entities.PodStopReport +} + +// Restart pod +// swagger:response +type podRestartResponse struct { + // in:body + Body entities.PodRestartReport +} + +// Start pod +// swagger:response +type podStartResponse struct { + // in:body + Body entities.PodStartReport +} + +// Prune pod +// swagger:response +type podPruneResponse struct { + // in:body + Body entities.PodPruneReport +} + +// Rm pod +// swagger:response +type podRmResponse struct { + // in:body + Body entities.PodRmReport +} + +// Info +// swagger:response +type infoResponse struct { + // in:body + Body define.Info +} + +// Network Delete +// swagger:response +type networkRmResponse struct { + // in:body + Body []entities.NetworkRmReport +} + +// Network inspect +// swagger:response +type networkInspectResponse struct { + // in:body + Body types.Network +} + +// Network list +// swagger:response +type networkListLibpod struct { + // in:body + Body []types.Network +} + +// Network create +// swagger:model +type networkCreateLibpod struct { + // in:body + types.Network +} + +// Network create +// swagger:response +type networkCreateResponse struct { + // in:body + Body types.Network +} + +// Network prune +// swagger:response +type networkPruneResponse struct { + // in:body + Body []entities.NetworkPruneReport +} diff --git a/pkg/api/handlers/swagger/swagger.go b/pkg/api/handlers/swagger/swagger.go deleted file mode 100644 index 7446d901e..000000000 --- a/pkg/api/handlers/swagger/swagger.go +++ /dev/null @@ -1,194 +0,0 @@ -package swagger - -import ( - "github.com/containers/podman/v4/libpod/define" - "github.com/containers/podman/v4/pkg/api/handlers" - "github.com/containers/podman/v4/pkg/domain/entities" - "github.com/containers/podman/v4/pkg/inspect" - "github.com/docker/docker/api/types" -) - -// Tree response -// swagger:response TreeResponse -type swagTree struct { - // in:body - Body struct { - entities.ImageTreeReport - } -} - -// History response -// swagger:response DocsHistory -type swagHistory struct { - // in:body - Body struct { - handlers.HistoryResponse - } -} - -// Inspect response -// swagger:response DocsImageInspect -type swagImageInspect struct { - // in:body - Body struct { - handlers.ImageInspect - } -} - -// Load response -// swagger:response DocsLibpodImagesLoadResponse -type swagLibpodImagesLoadResponse struct { - // in:body - Body entities.ImageLoadReport -} - -// Import response -// swagger:response DocsLibpodImagesImportResponse -type swagLibpodImagesImportResponse struct { - // in:body - Body entities.ImageImportReport -} - -// Pull response -// swagger:response DocsLibpodImagesPullResponse -type swagLibpodImagesPullResponse struct { - // in:body - Body handlers.LibpodImagesPullReport -} - -// Remove response -// swagger:response DocsLibpodImagesRemoveResponse -type swagLibpodImagesRemoveResponse struct { - // in:body - Body handlers.LibpodImagesRemoveReport -} - -// PlayKube response -// swagger:response DocsLibpodPlayKubeResponse -type swagLibpodPlayKubeResponse struct { - // in:body - Body entities.PlayKubeReport -} - -// Delete response -// swagger:response DocsImageDeleteResponse -type swagImageDeleteResponse struct { - // in:body - Body []struct { - Untagged []string `json:"untagged"` - Deleted string `json:"deleted"` - } -} - -// Search results -// swagger:response DocsSearchResponse -type swagSearchResponse struct { - // in:body - Body struct { - // Index is the image index (e.g., "docker.io" or "quay.io") - Index string - // Name is the canonical name of the image (e.g., "docker.io/library/alpine"). - Name string - // Description of the image. - Description string - // Stars is the number of stars of the image. - Stars int - // Official indicates if it's an official image. - Official string - // Automated indicates if the image was created by an automated build. - Automated string - // Tag is the image tag - Tag string - } -} - -// Inspect image -// swagger:response DocsLibpodInspectImageResponse -type swagLibpodInspectImageResponse struct { - // in:body - Body struct { - inspect.ImageData - } -} - -// Rm containers -// swagger:response DocsLibpodContainerRmReport -type swagLibpodContainerRmReport struct { - // in: body - Body []handlers.LibpodContainersRmReport -} - -// Prune containers -// swagger:response DocsContainerPruneReport -type swagContainerPruneReport struct { - // in: body - Body []handlers.ContainersPruneReport -} - -// Prune containers -// swagger:response DocsLibpodPruneResponse -type swagLibpodContainerPruneReport struct { - // in: body - Body []handlers.LibpodContainersPruneReport -} - -// Inspect container -// swagger:response DocsContainerInspectResponse -type swagContainerInspectResponse struct { - // in:body - Body struct { - types.ContainerJSON - } -} - -// List processes in container -// swagger:response DocsContainerTopResponse -type swagContainerTopResponse struct { - // in:body - Body struct { - handlers.ContainerTopOKBody - } -} - -// List processes in pod -// swagger:response DocsPodTopResponse -type swagPodTopResponse struct { - // in:body - Body struct { - handlers.PodTopOKBody - } -} - -// Inspect container -// swagger:response LibpodInspectContainerResponse -type swagLibpodInspectContainerResponse struct { - // in:body - Body struct { - define.InspectContainerData - } -} - -// List pods -// swagger:response ListPodsResponse -type swagListPodsResponse struct { - // in:body - Body []entities.ListPodsReport -} - -// Inspect pod -// swagger:response InspectPodResponse -type swagInspectPodResponse struct { - // in:body - Body struct { - define.InspectPodData - } -} - -// Get stats for one or more containers -// swagger:response ContainerStats -type swagContainerStatsResponse struct { - // in:body - Body struct { - define.ContainerStats - } -} diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go index 07eebb4f4..9eb712c30 100644 --- a/pkg/api/handlers/types.go +++ b/pkg/api/handlers/types.go @@ -41,7 +41,7 @@ type ContainersPruneReport struct { docker.ContainersPruneReport } -type LibpodContainersPruneReport struct { +type ContainersPruneReportLibpod struct { ID string `json:"Id"` SpaceReclaimed int64 `json:"Size"` // Error which occurred during prune operation (if any). @@ -121,7 +121,7 @@ type ContainerWaitOKBody struct { } // CreateContainerConfig used when compatible endpoint creates a container -// swagger:model CreateContainerConfig +// swagger:model type CreateContainerConfig struct { Name string // container name dockerContainer.Config // desired container configuration @@ -131,12 +131,6 @@ type CreateContainerConfig struct { UnsetEnvAll bool // unset all default environment variables } -// swagger:model IDResponse -type IDResponse struct { - // ID - ID string `json:"Id"` -} - type ContainerTopOKBody struct { dockerContainer.ContainerTopOKBody } @@ -145,20 +139,6 @@ type PodTopOKBody struct { dockerContainer.ContainerTopOKBody } -// swagger:model PodCreateConfig -type PodCreateConfig struct { - Name string `json:"name"` - CgroupParent string `json:"cgroup-parent"` - Hostname string `json:"hostname"` - Infra bool `json:"infra"` - InfraCommand string `json:"infra-command"` - InfraImage string `json:"infra-image"` - InfraName string `json:"infra-name"` - Labels []string `json:"labels"` - Publish []string `json:"publish"` - Share string `json:"share"` -} - // HistoryResponse provides details on image layers type HistoryResponse struct { ID string `json:"Id"` @@ -173,10 +153,6 @@ type ExecCreateConfig struct { docker.ExecConfig } -type ExecCreateResponse struct { - docker.IDResponse -} - type ExecStartConfig struct { Detach bool `json:"Detach"` Tty bool `json:"Tty"` @@ -250,7 +226,7 @@ func ImageDataToImageInspect(ctx context.Context, l *libimage.Image) (*ImageInsp return &ImageInspect{dockerImageInspect}, nil } -// portsToPortSet converts libpods exposed ports to dockers structs +// portsToPortSet converts libpod's exposed ports to docker's structs func portsToPortSet(input map[string]struct{}) (nat.PortSet, error) { ports := make(nat.PortSet) for k := range input { diff --git a/pkg/api/handlers/utils/containers.go b/pkg/api/handlers/utils/containers.go index 3a5488a4a..8588b49ba 100644 --- a/pkg/api/handlers/utils/containers.go +++ b/pkg/api/handlers/utils/containers.go @@ -57,7 +57,6 @@ func WaitContainerDocker(w http.ResponseWriter, r *http.Request) { name := GetName(r) exists, err := containerExists(ctx, name) - if err != nil { InternalServerError(w, err) return diff --git a/pkg/api/server/docs.go b/pkg/api/server/doc.go index 2127e7d82..0bb10a19c 100644 --- a/pkg/api/server/docs.go +++ b/pkg/api/server/doc.go @@ -1,10 +1,7 @@ -// Package api Provides an API for the Libpod library +// Package server supports a RESTful API for the Libpod library // -// This documentation describes the Podman v2.0 RESTful API. -// It replaces the Podman v1.0 API and was initially delivered -// along with Podman v2.0. It consists of a Docker-compatible -// API and a Libpod API providing support for Podman’s unique -// features such as pods. +// This documentation describes the Podman v2.x+ RESTful API. It consists of a Docker-compatible +// API and a Libpod API providing support for Podman’s unique features such as pods. // // To start the service and keep it running for 5,000 seconds (-t 0 runs forever): // @@ -15,11 +12,11 @@ // NOTE: if you install the package podman-docker, it will create a symbolic // link for /run/docker.sock to /run/podman/podman.sock // -// NOTE: some fields in the API response JSON are set as omitempty, which means that -// if there is no value set for them, they will not show up in the API response. This +// NOTE: Some fields in the API response JSON are encoded as omitempty, which means that +// if said field has a zero value, they will not be encoded in the API response. This // is a feature to help reduce the size of the JSON responses returned via the API. // -// NOTE: due to the limitations of [go-swagger](https://github.com/go-swagger/go-swagger), +// NOTE: Due to the limitations of [go-swagger](https://github.com/go-swagger/go-swagger), // some field values that have a complex type show up as null in the docs as well as in the // API responses. This is because the zero value for the field type is null. The field // description in the docs will state what type the field is expected to be for such cases. @@ -30,18 +27,20 @@ // // 'podman info' // -// curl --unix-socket /run/podman/podman.sock http://d/v3.0.0/libpod/info +// curl --unix-socket /run/podman/podman.sock http://d/v4.0.0/libpod/info // // 'podman pull quay.io/containers/podman' // -// curl -XPOST --unix-socket /run/podman/podman.sock -v 'http://d/v3.0.0/images/create?fromImage=quay.io%2Fcontainers%2Fpodman' +// curl -XPOST --unix-socket /run/podman/podman.sock -v 'http://d/v4.0.0/images/create?fromImage=quay.io%2Fcontainers%2Fpodman' // // 'podman list images' // -// curl --unix-socket /run/podman/podman.sock -v 'http://d/v3.0.0/libpod/images/json' | jq +// curl --unix-socket /run/podman/podman.sock -v 'http://d/v4.0.0/libpod/images/json' | jq // // Terms Of Service: // +// https://github.com/containers/podman/blob/913caaa9b1de2b63692c9bae15120208194c9eb3/LICENSE +// // Schemes: http, https // Host: podman.io // BasePath: / @@ -62,5 +61,6 @@ // Consumes: // - application/json // - application/x-tar +// // swagger:meta package server diff --git a/pkg/api/server/register_archive.go b/pkg/api/server/register_archive.go index e51d12300..10131c7f2 100644 --- a/pkg/api/server/register_archive.go +++ b/pkg/api/server/register_archive.go @@ -44,13 +44,13 @@ func (s *APIServer) registerArchiveHandlers(r *mux.Router) error { // 200: // description: no error // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 403: // description: the container rootfs is read-only // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" // swagger:operation GET /containers/{name}/archive compat ContainerArchive // --- @@ -78,11 +78,11 @@ func (s *APIServer) registerArchiveHandlers(r *mux.Router) error { // type: string // format: binary // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/archive"), s.APIHandler(compat.Archive)).Methods(http.MethodGet, http.MethodPut, http.MethodHead) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/archive", s.APIHandler(compat.Archive)).Methods(http.MethodGet, http.MethodPut, http.MethodHead) @@ -124,13 +124,13 @@ func (s *APIServer) registerArchiveHandlers(r *mux.Router) error { // 200: // description: no error // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 403: // description: the container rootfs is read-only // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" // swagger:operation GET /libpod/containers/{name}/archive libpod ContainerArchiveLibpod // --- @@ -162,11 +162,11 @@ func (s *APIServer) registerArchiveHandlers(r *mux.Router) error { // type: string // format: binary // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/archive"), s.APIHandler(compat.Archive)).Methods(http.MethodGet, http.MethodPut, http.MethodHead) return nil diff --git a/pkg/api/server/register_auth.go b/pkg/api/server/register_auth.go index e66a211fd..beb37bf00 100644 --- a/pkg/api/server/register_auth.go +++ b/pkg/api/server/register_auth.go @@ -23,9 +23,9 @@ func (s *APIServer) registerAuthHandlers(r *mux.Router) error { // $ref: "#/definitions/AuthConfig" // responses: // 200: - // $ref: "#/responses/SystemAuthResponse" + // $ref: "#/responses/systemAuthResponse" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/auth"), s.APIHandler(compat.Auth)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/auth", s.APIHandler(compat.Auth)).Methods(http.MethodPost) diff --git a/pkg/api/server/register_containers.go b/pkg/api/server/register_containers.go index 89324794e..e2ecdb6af 100644 --- a/pkg/api/server/register_containers.go +++ b/pkg/api/server/register_containers.go @@ -29,15 +29,15 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // required: true // responses: // 201: - // $ref: "#/responses/ContainerCreateResponse" + // $ref: "#/responses/containerCreateResponse" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 409: - // $ref: "#/responses/ConflictError" + // $ref: "#/responses/conflictError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/create"), s.APIHandler(compat.CreateContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/create", s.APIHandler(compat.CreateContainer)).Methods(http.MethodPost) @@ -90,11 +90,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsListContainer" + // $ref: "#/responses/containersList" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/json"), s.APIHandler(compat.ListContainers)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/json", s.APIHandler(compat.ListContainers)).Methods(http.MethodGet) @@ -116,9 +116,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsContainerPruneReport" + // $ref: "#/responses/containersPrune" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/prune"), s.APIHandler(compat.PruneContainers)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/prune", s.APIHandler(compat.PruneContainers)).Methods(http.MethodPost) @@ -153,13 +153,13 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 409: - // $ref: "#/responses/ConflictError" + // $ref: "#/responses/conflictError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}"), s.APIHandler(compat.RemoveContainer)).Methods(http.MethodDelete) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}", s.APIHandler(compat.RemoveContainer)).Methods(http.MethodDelete) @@ -184,11 +184,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsContainerInspectResponse" + // $ref: "#/responses/containerInspectResponse" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/json"), s.APIHandler(compat.GetContainer)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/json", s.APIHandler(compat.GetContainer)).Methods(http.MethodGet) @@ -221,11 +221,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 409: - // $ref: "#/responses/ConflictError" + // $ref: "#/responses/conflictError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/kill"), s.APIHandler(compat.KillContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/kill", s.APIHandler(compat.KillContainer)).Methods(http.MethodPost) @@ -277,9 +277,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 200: // description: logs returned as a stream in response body. // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/logs"), s.APIHandler(compat.LogsFromContainer)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/logs", s.APIHandler(compat.LogsFromContainer)).Methods(http.MethodGet) @@ -301,9 +301,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/pause"), s.APIHandler(compat.PauseContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/pause", s.APIHandler(compat.PauseContainer)).Methods(http.MethodPost) @@ -328,9 +328,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/restart"), s.APIHandler(compat.RestartContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/restart", s.APIHandler(compat.RestartContainer)).Methods(http.MethodPost) @@ -356,11 +356,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 304: - // $ref: "#/responses/ContainerAlreadyStartedError" + // $ref: "#/responses/containerAlreadyStartedError" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/start"), s.APIHandler(compat.StartContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/start", s.APIHandler(compat.StartContainer)).Methods(http.MethodPost) @@ -390,11 +390,13 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // description: OK + // description: no error + // schema: + // type: object // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/stats"), s.APIHandler(compat.StatsContainer)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/stats", s.APIHandler(compat.StatsContainer)).Methods(http.MethodGet) @@ -420,11 +422,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 304: - // $ref: "#/responses/ContainerAlreadyStoppedError" + // $ref: "#/responses/containerAlreadyStoppedError" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/stop"), s.APIHandler(compat.StopContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/stop", s.APIHandler(compat.StopContainer)).Methods(http.MethodPost) @@ -448,11 +450,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsContainerTopResponse" + // $ref: "#/responses/containerTopResponse" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/top"), s.APIHandler(compat.TopContainer)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/top", s.APIHandler(compat.TopContainer)).Methods(http.MethodGet) @@ -474,9 +476,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/unpause"), s.APIHandler(compat.UnpauseContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/unpause", s.APIHandler(compat.UnpauseContainer)).Methods(http.MethodPost) @@ -512,11 +514,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/ContainerWaitResponse" + // $ref: "#/responses/containerWaitResponse" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/wait"), s.APIHandler(compat.WaitContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/wait", s.APIHandler(compat.WaitContainer)).Methods(http.MethodPost) @@ -569,11 +571,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 101: // description: No error, connection has been hijacked for transporting streams. // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/attach"), s.APIHandler(compat.AttachContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/attach", s.APIHandler(compat.AttachContainer)).Methods(http.MethodPost) @@ -610,9 +612,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 200: // $ref: "#/responses/ok" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/resize"), s.APIHandler(compat.ResizeTTY)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/resize", s.APIHandler(compat.ResizeTTY)).Methods(http.MethodPost) @@ -634,9 +636,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 200: // description: tarball is returned in body // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/export"), s.APIHandler(compat.ExportContainer)).Methods(http.MethodGet) r.HandleFunc("/containers/{name}/export", s.APIHandler(compat.ExportContainer)).Methods(http.MethodGet) // swagger:operation POST /containers/{name}/rename compat ContainerRename @@ -662,11 +664,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 409: - // $ref: "#/responses/ConflictError" + // $ref: "#/responses/conflictError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/rename"), s.APIHandler(compat.RenameContainer)).Methods(http.MethodPost) r.HandleFunc("/containers/{name}/rename", s.APIHandler(compat.RenameContainer)).Methods(http.MethodPost) @@ -689,15 +691,15 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // $ref: "#/definitions/SpecGenerator" // responses: // 201: - // $ref: "#/responses/ContainerCreateResponse" + // $ref: "#/responses/containerCreateResponse" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 409: - // $ref: "#/responses/ConflictError" + // $ref: "#/responses/conflictError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/create"), s.APIHandler(libpod.CreateContainer)).Methods(http.MethodPost) // swagger:operation GET /libpod/containers/json libpod ContainerListLibpod // --- @@ -758,11 +760,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/ListContainers" + // $ref: "#/responses/containersListLibpod" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/json"), s.APIHandler(libpod.ListContainers)).Methods(http.MethodGet) // swagger:operation POST /libpod/containers/prune libpod ContainerPruneLibpod // --- @@ -782,9 +784,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsLibpodPruneResponse" + // $ref: "#/responses/containersPruneLibpod" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/prune"), s.APIHandler(compat.PruneContainers)).Methods(http.MethodPost) // swagger:operation GET /libpod/containers/showmounted libpod ContainerShowMountedLibpod // --- @@ -802,7 +804,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // additionalProperties: // type: string // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/showmounted"), s.APIHandler(libpod.ShowMountedContainers)).Methods(http.MethodGet) // swagger:operation DELETE /libpod/containers/{name} libpod ContainerDeleteLibpod // --- @@ -841,17 +843,17 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsLibpodContainerRmReport" + // $ref: "#/responses/containerRemoveLibpod" // 204: // description: no error // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 409: - // $ref: "#/responses/ConflictError" + // $ref: "#/responses/conflictError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}"), s.APIHandler(compat.RemoveContainer)).Methods(http.MethodDelete) // swagger:operation GET /libpod/containers/{name}/json libpod ContainerInspectLibpod // --- @@ -873,11 +875,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/LibpodInspectContainerResponse" + // $ref: "#/responses/containerInspectResponseLibpod" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/json"), s.APIHandler(libpod.GetContainer)).Methods(http.MethodGet) // swagger:operation POST /libpod/containers/{name}/kill libpod ContainerKillLibpod // --- @@ -902,11 +904,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 409: - // $ref: "#/responses/ConflictError" + // $ref: "#/responses/conflictError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/kill"), s.APIHandler(compat.KillContainer)).Methods(http.MethodPost) // swagger:operation POST /libpod/containers/{name}/mount libpod ContainerMountLibpod // --- @@ -930,9 +932,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // type: string // example: /var/lib/containers/storage/overlay/f3f693bd88872a1e3193f4ebb925f4c282e8e73aadb8ab3e7492754dda3a02a4/merged // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/mount"), s.APIHandler(libpod.MountContainer)).Methods(http.MethodPost) // swagger:operation POST /libpod/containers/{name}/unmount libpod ContainerUnmountLibpod // --- @@ -952,9 +954,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: ok // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/unmount"), s.APIHandler(libpod.UnmountContainer)).Methods(http.MethodPost) // swagger:operation GET /libpod/containers/{name}/logs libpod ContainerLogsLibpod // --- @@ -1004,9 +1006,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 200: // description: logs returned as a stream in response body. // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/logs"), s.APIHandler(compat.LogsFromContainer)).Methods(http.MethodGet) // swagger:operation POST /libpod/containers/{name}/pause libpod ContainerPauseLibpod // --- @@ -1026,9 +1028,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 404: - // "$ref": "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // "$ref": "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/pause"), s.APIHandler(compat.PauseContainer)).Methods(http.MethodPost) // swagger:operation POST /libpod/containers/{name}/restart libpod ContainerRestartLibpod // --- @@ -1052,9 +1054,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/restart"), s.APIHandler(compat.RestartContainer)).Methods(http.MethodPost) // swagger:operation POST /libpod/containers/{name}/start libpod ContainerStartLibpod // --- @@ -1078,11 +1080,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 304: - // $ref: "#/responses/ContainerAlreadyStartedError" + // $ref: "#/responses/containerAlreadyStartedError" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/start"), s.APIHandler(compat.StartContainer)).Methods(http.MethodPost) // swagger:operation GET /libpod/containers/{name}/stats libpod ContainerStatsLibpod // --- @@ -1107,11 +1109,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 200: // description: no error // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 409: - // $ref: "#/responses/ConflictError" + // $ref: "#/responses/conflictError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/stats"), s.APIHandler(compat.StatsContainer)).Methods(http.MethodGet) // swagger:operation GET /libpod/containers/stats libpod ContainersStatsAllLibpod // --- @@ -1140,11 +1142,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/ContainerStats" + // $ref: "#/responses/containerStats" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/stats"), s.APIHandler(libpod.StatsContainer)).Methods(http.MethodGet) // swagger:operation GET /libpod/containers/{name}/top libpod ContainerTopLibpod @@ -1179,11 +1181,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsContainerTopResponse" + // $ref: "#/responses/containerTopResponse" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/top"), s.APIHandler(compat.TopContainer)).Methods(http.MethodGet) // swagger:operation POST /libpod/containers/{name}/unpause libpod ContainerUnpauseLibpod // --- @@ -1202,16 +1204,16 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/unpause"), s.APIHandler(compat.UnpauseContainer)).Methods(http.MethodPost) // swagger:operation POST /libpod/containers/{name}/wait libpod ContainerWaitLibpod // --- // tags: // - containers // summary: Wait on a container - // description: Wait on a container to met a given condition + // description: Wait on a container to meet a given condition // parameters: // - in: path // name: name @@ -1250,9 +1252,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // examples: // text/plain: 137 // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/wait"), s.APIHandler(libpod.WaitContainer)).Methods(http.MethodPost) // swagger:operation GET /libpod/containers/{name}/exists libpod ContainerExistsLibpod // --- @@ -1272,9 +1274,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: container exists // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/exists"), s.APIHandler(libpod.ContainerExists)).Methods(http.MethodGet) // swagger:operation POST /libpod/containers/{name}/stop libpod ContainerStopLibpod // --- @@ -1308,11 +1310,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 304: - // $ref: "#/responses/ContainerAlreadyStoppedError" + // $ref: "#/responses/containerAlreadyStoppedError" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/stop"), s.APIHandler(compat.StopContainer)).Methods(http.MethodPost) // swagger:operation POST /libpod/containers/{name}/attach libpod ContainerAttachLibpod // --- @@ -1363,11 +1365,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 101: // description: No error, connection has been hijacked for transporting streams. // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/attach"), s.APIHandler(compat.AttachContainer)).Methods(http.MethodPost) // swagger:operation POST /libpod/containers/{name}/resize libpod ContainerResizeLibpod // --- @@ -1397,11 +1399,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 200: // $ref: "#/responses/ok" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 409: - // $ref: "#/responses/ConflictError" + // $ref: "#/responses/conflictError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/resize"), s.APIHandler(compat.ResizeTTY)).Methods(http.MethodPost) // swagger:operation GET /libpod/containers/{name}/export libpod ContainerExportLibpod // --- @@ -1421,9 +1423,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 200: // description: tarball is returned in body // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/export"), s.APIHandler(compat.ExportContainer)).Methods(http.MethodGet) // swagger:operation POST /libpod/containers/{name}/checkpoint libpod ContainerCheckpointLibpod // --- @@ -1466,9 +1468,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 200: // description: tarball is returned in body if exported // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/checkpoint"), s.APIHandler(libpod.Checkpoint)).Methods(http.MethodPost) // swagger:operation POST /libpod/containers/{name}/restore libpod ContainerRestoreLibpod // --- @@ -1524,9 +1526,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 200: // description: tarball is returned in body if exported // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/restore"), s.APIHandler(libpod.Restore)).Methods(http.MethodPost) // swagger:operation GET /containers/{name}/changes compat ContainerChanges // swagger:operation GET /libpod/containers/{name}/changes libpod ContainerChangesLibpod @@ -1564,9 +1566,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // schema: // $ref: "#/responses/Changes" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/containers/{name}/changes"), s.APIHandler(compat.Changes)).Methods(http.MethodGet) r.HandleFunc("/containers/{name}/changes", s.APIHandler(compat.Changes)).Methods(http.MethodGet) r.HandleFunc(VersionedPath("/libpod/containers/{name}/changes"), s.APIHandler(compat.Changes)).Methods(http.MethodGet) @@ -1590,9 +1592,9 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 304: // description: container already initialized // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/init"), s.APIHandler(libpod.InitContainer)).Methods(http.MethodPost) // swagger:operation POST /libpod/containers/{name}/rename libpod ContainerRenameLibpod // --- @@ -1617,11 +1619,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 204: // description: no error // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 409: - // $ref: "#/responses/ConflictError" + // $ref: "#/responses/conflictError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/rename"), s.APIHandler(compat.RenameContainer)).Methods(http.MethodPost) return nil } diff --git a/pkg/api/server/register_events.go b/pkg/api/server/register_events.go index 10a7b76fc..76f9ec619 100644 --- a/pkg/api/server/register_events.go +++ b/pkg/api/server/register_events.go @@ -33,7 +33,7 @@ func (s *APIServer) registerEventsHandlers(r *mux.Router) error { // 200: // description: returns a string of json data describing an event // 500: - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/events"), s.APIHandler(compat.GetEvents)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/events", s.APIHandler(compat.GetEvents)).Methods(http.MethodGet) @@ -67,7 +67,7 @@ func (s *APIServer) registerEventsHandlers(r *mux.Router) error { // 200: // description: returns a string of json data describing an event // 500: - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/libpod/events"), s.APIHandler(compat.GetEvents)).Methods(http.MethodGet) return nil } diff --git a/pkg/api/server/register_exec.go b/pkg/api/server/register_exec.go index 90136463d..cf1fb8c16 100644 --- a/pkg/api/server/register_exec.go +++ b/pkg/api/server/register_exec.go @@ -69,11 +69,11 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // 201: // description: no error // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 409: // description: container is paused // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/containers/{name}/exec"), s.APIHandler(compat.ExecCreateHandler)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/containers/{name}/exec", s.APIHandler(compat.ExecCreateHandler)).Methods(http.MethodPost) @@ -107,11 +107,11 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // 200: // description: no error // 404: - // $ref: "#/responses/NoSuchExecInstance" + // $ref: "#/responses/execSessionNotFound" // 409: // description: container is not running // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/exec/{id}/start"), s.APIHandler(compat.ExecStartHandler)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/exec/{id}/start", s.APIHandler(compat.ExecStartHandler)).Methods(http.MethodPost) @@ -147,9 +147,9 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // 201: // description: no error // 404: - // $ref: "#/responses/NoSuchExecInstance" + // $ref: "#/responses/execSessionNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/exec/{id}/resize"), s.APIHandler(compat.ResizeTTY)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/exec/{id}/resize", s.APIHandler(compat.ResizeTTY)).Methods(http.MethodPost) @@ -169,11 +169,11 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/InspectExecSession" + // $ref: "#/responses/execSessionInspect" // 404: - // $ref: "#/responses/NoSuchExecInstance" + // $ref: "#/responses/execSessionNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/exec/{id}/json"), s.APIHandler(compat.ExecInspectHandler)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/exec/{id}/json", s.APIHandler(compat.ExecInspectHandler)).Methods(http.MethodGet) @@ -243,11 +243,11 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // 201: // description: no error // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 409: // description: container is paused // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/containers/{name}/exec"), s.APIHandler(compat.ExecCreateHandler)).Methods(http.MethodPost) // swagger:operation POST /libpod/exec/{id}/start libpod ExecStartLibpod // --- @@ -285,11 +285,11 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // 200: // description: no error // 404: - // $ref: "#/responses/NoSuchExecInstance" + // $ref: "#/responses/execSessionNotFound" // 409: // description: container is not running. // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/exec/{id}/start"), s.APIHandler(compat.ExecStartHandler)).Methods(http.MethodPost) // swagger:operation POST /libpod/exec/{id}/resize libpod ExecResizeLibpod // --- @@ -318,9 +318,9 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // 201: // description: no error // 404: - // $ref: "#/responses/NoSuchExecInstance" + // $ref: "#/responses/execSessionNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/exec/{id}/resize"), s.APIHandler(compat.ResizeTTY)).Methods(http.MethodPost) // swagger:operation GET /libpod/exec/{id}/json libpod ExecInspectLibpod // --- @@ -340,9 +340,9 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // 200: // description: no error // 404: - // $ref: "#/responses/NoSuchExecInstance" + // $ref: "#/responses/execSessionNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/exec/{id}/json"), s.APIHandler(compat.ExecInspectHandler)).Methods(http.MethodGet) return nil } diff --git a/pkg/api/server/register_generate.go b/pkg/api/server/register_generate.go index 6b7f0cfe7..82fbe3d09 100644 --- a/pkg/api/server/register_generate.go +++ b/pkg/api/server/register_generate.go @@ -103,7 +103,7 @@ func (s *APIServer) registerGenerateHandlers(r *mux.Router) error { // additionalProperties: // type: string // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/generate/{name:.*}/systemd"), s.APIHandler(libpod.GenerateSystemd)).Methods(http.MethodGet) // swagger:operation GET /libpod/generate/kube libpod GenerateKubeLibpod @@ -127,15 +127,16 @@ func (s *APIServer) registerGenerateHandlers(r *mux.Router) error { // default: false // description: Generate YAML for a Kubernetes service object. // produces: + // - text/vnd.yaml // - application/json // responses: // 200: - // description: no error + // description: Kubernetes YAML file describing pod // schema: // type: string // format: binary // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/generate/kube"), s.APIHandler(libpod.GenerateKube)).Methods(http.MethodGet) return nil } diff --git a/pkg/api/server/register_healthcheck.go b/pkg/api/server/register_healthcheck.go index 014e82fe4..4e2d4059a 100644 --- a/pkg/api/server/register_healthcheck.go +++ b/pkg/api/server/register_healthcheck.go @@ -24,13 +24,13 @@ func (s *APIServer) registerHealthCheckHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/HealthcheckRun" + // $ref: "#/responses/healthCheck" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 409: // description: container has no healthcheck or is not running // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/containers/{name:.*}/healthcheck"), s.APIHandler(libpod.RunHealthCheck)).Methods(http.MethodGet) return nil } diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go index 89f808e7d..1617a5dd7 100644 --- a/pkg/api/server/register_images.go +++ b/pkg/api/server/register_images.go @@ -66,9 +66,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // type: "string" // format: "binary" // 404: - // $ref: "#/responses/NoSuchImage" + // $ref: "#/responses/imageNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/images/create"), s.APIHandler(compat.CreateImageFromImage)).Methods(http.MethodPost).Queries("fromImage", "{fromImage}") // Added non version path to URI to support docker non versioned paths r.Handle("/images/create", s.APIHandler(compat.CreateImageFromImage)).Methods(http.MethodPost).Queries("fromImage", "{fromImage}") @@ -106,9 +106,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DockerImageSummaryResponse" + // $ref: "#/responses/imageList" // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/images/json"), s.APIHandler(compat.GetImages)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/images/json", s.APIHandler(compat.GetImages)).Methods(http.MethodGet) @@ -134,7 +134,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 200: // description: no error // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/images/load"), s.APIHandler(compat.LoadImages)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/images/load", s.APIHandler(compat.LoadImages)).Methods(http.MethodPost) @@ -159,9 +159,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsImageDeleteResponse" + // $ref: "#/responses/imageDeleteResponse" // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/images/prune"), s.APIHandler(compat.PruneImages)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/images/prune", s.APIHandler(compat.PruneImages)).Methods(http.MethodPost) @@ -202,11 +202,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsSearchResponse" + // $ref: "#/responses/registrySearchResponse" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/images/search"), s.APIHandler(compat.SearchImages)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/images/search", s.APIHandler(compat.SearchImages)).Methods(http.MethodGet) @@ -234,13 +234,13 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsImageDeleteResponse" + // $ref: "#/responses/imageDeleteResponse" // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 409: - // $ref: '#/responses/ConflictError' + // $ref: '#/responses/conflictError' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/images/{name:.*}"), s.APIHandler(compat.RemoveImage)).Methods(http.MethodDelete) // Added non version path to URI to support docker non versioned paths r.Handle("/images/{name:.*}", s.APIHandler(compat.RemoveImage)).Methods(http.MethodDelete) @@ -285,9 +285,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // type: string // format: binary // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/images/{name:.*}/push"), s.APIHandler(compat.PushImage)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/images/{name:.*}/push", s.APIHandler(compat.PushImage)).Methods(http.MethodPost) @@ -312,7 +312,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // type: string // format: binary // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/images/{name:.*}/get"), s.APIHandler(compat.ExportImage)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/images/{name:.*}/get", s.APIHandler(compat.ExportImage)).Methods(http.MethodGet) @@ -337,7 +337,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // type: string // format: binary // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/images/get"), s.APIHandler(compat.ExportImages)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/images/get", s.APIHandler(compat.ExportImages)).Methods(http.MethodGet) @@ -357,11 +357,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsHistory" + // $ref: "#/responses/history" // 404: - // $ref: "#/responses/NoSuchImage" + // $ref: "#/responses/imageNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/images/{name:.*}/history"), s.APIHandler(compat.HistoryImage)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/images/{name:.*}/history", s.APIHandler(compat.HistoryImage)).Methods(http.MethodGet) @@ -381,11 +381,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsImageInspect" + // $ref: "#/responses/imageInspect" // 404: - // $ref: "#/responses/NoSuchImage" + // $ref: "#/responses/imageNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/images/{name:.*}/json"), s.APIHandler(compat.GetImage)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/images/{name:.*}/json", s.APIHandler(compat.GetImage)).Methods(http.MethodGet) @@ -415,13 +415,13 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 201: // description: no error // 400: - // $ref: '#/responses/BadParamError' + // $ref: '#/responses/badParamError' // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 409: - // $ref: '#/responses/ConflictError' + // $ref: '#/responses/conflictError' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/images/{name:.*}/tag"), s.APIHandler(compat.TagImage)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/images/{name:.*}/tag", s.APIHandler(compat.TagImage)).Methods(http.MethodPost) @@ -470,9 +470,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 201: // description: no error // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/commit"), s.APIHandler(compat.CommitContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/commit", s.APIHandler(compat.CommitContainer)).Methods(http.MethodPost) @@ -699,9 +699,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // Successfully built 8ba084515c724cbf90d447a63600c0a6 // Successfully tagged your_image:latest // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/build"), s.APIHandler(compat.BuildImage)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/build", s.APIHandler(compat.BuildImage)).Methods(http.MethodPost) @@ -743,9 +743,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // type: string // format: binary // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/push"), s.APIHandler(libpod.PushImage)).Methods(http.MethodPost) // swagger:operation GET /libpod/images/{name}/exists libpod ImageExistsLibpod // --- @@ -765,9 +765,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 204: // description: image exists // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/exists"), s.APIHandler(libpod.ImageExists)).Methods(http.MethodGet) // swagger:operation GET /libpod/images/{name}/tree libpod ImageTreeLibpod // --- @@ -789,11 +789,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/TreeResponse" + // $ref: "#/responses/treeResponse" // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/tree"), s.APIHandler(libpod.ImageTree)).Methods(http.MethodGet) // swagger:operation GET /libpod/images/{name}/history libpod ImageHistoryLibpod // --- @@ -811,11 +811,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsHistory" + // $ref: "#/responses/history" // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/history"), s.APIHandler(compat.HistoryImage)).Methods(http.MethodGet) // swagger:operation GET /libpod/images/json libpod ImageListLibpod // --- @@ -844,9 +844,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/LibpodImageSummaryResponse" + // $ref: "#/responses/imageListLibpod" // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/json"), s.APIHandler(compat.GetImages)).Methods(http.MethodGet) // swagger:operation POST /libpod/images/load libpod ImageLoadLibpod // --- @@ -867,11 +867,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsLibpodImagesLoadResponse" + // $ref: "#/responses/imagesLoadResponseLibpod" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/load"), s.APIHandler(libpod.ImagesLoad)).Methods(http.MethodPost) // swagger:operation POST /libpod/images/import libpod ImageImportLibpod // --- @@ -916,11 +916,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/x-tar // responses: // 200: - // $ref: "#/responses/DocsLibpodImagesImportResponse" + // $ref: "#/responses/imagesImportResponseLibpod" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/import"), s.APIHandler(libpod.ImagesImport)).Methods(http.MethodPost) // swagger:operation DELETE /libpod/images/remove libpod ImageDeleteAllLibpod // --- @@ -952,11 +952,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsLibpodImagesRemoveResponse" + // $ref: "#/responses/imagesRemoveResponseLibpod" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/remove"), s.APIHandler(libpod.ImagesBatchRemove)).Methods(http.MethodDelete) // swagger:operation DELETE /libpod/images/{name} libpod ImageDeleteLibpod // --- @@ -978,15 +978,15 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsLibpodImagesRemoveResponse" + // $ref: "#/responses/imagesRemoveResponseLibpod" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 409: - // $ref: '#/responses/ConflictError' + // $ref: '#/responses/conflictError' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/{name:.*}"), s.APIHandler(libpod.ImagesRemove)).Methods(http.MethodDelete) // swagger:operation POST /libpod/images/pull libpod ImagePullLibpod // --- @@ -1041,11 +1041,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsLibpodImagesPullResponse" + // $ref: "#/responses/imagesPullResponseLibpod" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/pull"), s.APIHandler(libpod.ImagesPull)).Methods(http.MethodPost) // swagger:operation POST /libpod/images/prune libpod ImagePruneLibpod // --- @@ -1080,9 +1080,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsLibpodPruneResponse" + // $ref: "#/responses/imagesPruneLibpod" // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/prune"), s.APIHandler(libpod.PruneImages)).Methods(http.MethodPost) // swagger:operation GET /libpod/images/search libpod ImageSearchLibpod // --- @@ -1122,9 +1122,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsSearchResponse" + // $ref: "#/responses/registrySearchResponse" // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/search"), s.APIHandler(compat.SearchImages)).Methods(http.MethodGet) // swagger:operation GET /libpod/images/{name}/get libpod ImageGetLibpod // --- @@ -1155,9 +1155,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // type: string // format: binary // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/get"), s.APIHandler(libpod.ExportImage)).Methods(http.MethodGet) // swagger:operation GET /libpod/images/export libpod ImageExportLibpod // --- @@ -1193,9 +1193,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // type: string // format: binary // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/export"), s.APIHandler(libpod.ExportImages)).Methods(http.MethodGet) // swagger:operation GET /libpod/images/{name}/json libpod ImageInspectLibpod // --- @@ -1213,11 +1213,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsLibpodInspectImageResponse" + // $ref: "#/responses/inspectImageResponseLibpod" // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/json"), s.APIHandler(libpod.GetImage)).Methods(http.MethodGet) // swagger:operation POST /libpod/images/{name}/tag libpod ImageTagLibpod // --- @@ -1245,13 +1245,13 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 201: // description: no error // 400: - // $ref: '#/responses/BadParamError' + // $ref: '#/responses/badParamError' // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 409: - // $ref: '#/responses/ConflictError' + // $ref: '#/responses/conflictError' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/tag"), s.APIHandler(compat.TagImage)).Methods(http.MethodPost) // swagger:operation POST /libpod/commit libpod ImageCommitLibpod // --- @@ -1301,9 +1301,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 201: // description: no error // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/commit"), s.APIHandler(libpod.CommitContainer)).Methods(http.MethodPost) // swagger:operation POST /libpod/images/{name}/untag libpod ImageUntagLibpod // --- @@ -1331,13 +1331,13 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 201: // description: no error // 400: - // $ref: '#/responses/BadParamError' + // $ref: '#/responses/badParamError' // 404: - // $ref: '#/responses/NoSuchImage' + // $ref: '#/responses/imageNotFound' // 409: - // $ref: '#/responses/ConflictError' + // $ref: '#/responses/conflictError' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/untag"), s.APIHandler(libpod.UntagImage)).Methods(http.MethodPost) // swagger:operation GET /libpod/images/{name}/changes libpod ImageChangesLibpod @@ -1374,9 +1374,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // schema: // $ref: "#/responses/Changes" // 404: - // $ref: "#/responses/NoSuchContainer" + // $ref: "#/responses/containerNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/images/{name}/changes"), s.APIHandler(compat.Changes)).Methods(http.MethodGet) // swagger:operation POST /libpod/build libpod ImageBuildLibpod @@ -1611,9 +1611,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // example: | // (build details...) // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/build"), s.APIHandler(compat.BuildImage)).Methods(http.MethodPost) return nil } diff --git a/pkg/api/server/register_info.go b/pkg/api/server/register_info.go index ccb145366..116d847cc 100644 --- a/pkg/api/server/register_info.go +++ b/pkg/api/server/register_info.go @@ -21,7 +21,7 @@ func (s *APIServer) registerInfoHandlers(r *mux.Router) error { // 200: // description: to be determined // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/info"), s.APIHandler(compat.GetInfo)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/info", s.APIHandler(compat.GetInfo)).Methods(http.MethodGet) @@ -35,9 +35,9 @@ func (s *APIServer) registerInfoHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/InfoResponse" + // $ref: "#/responses/infoResponse" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/info"), s.APIHandler(libpod.GetInfo)).Methods(http.MethodGet) return nil } diff --git a/pkg/api/server/register_manifest.go b/pkg/api/server/register_manifest.go index 3e3a516f4..4fadb92fd 100644 --- a/pkg/api/server/register_manifest.go +++ b/pkg/api/server/register_manifest.go @@ -39,11 +39,11 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // schema: // $ref: "#/definitions/IDResponse" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchManifest" + // $ref: "#/responses/manifestNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" v3.Handle("/{name}/push", s.APIHandler(libpod.ManifestPushV3)).Methods(http.MethodPost) // swagger:operation POST /libpod/manifests/{name}/registry/{destination} manifests ManifestPushLibpod // --- @@ -80,11 +80,11 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // schema: // $ref: "#/definitions/IDResponse" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchManifest" + // $ref: "#/responses/manifestNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" v4.Handle("/{name:.*}/registry/{destination:.*}", s.APIHandler(libpod.ManifestPush)).Methods(http.MethodPost) // swagger:operation POST /libpod/manifests manifests ManifestCreateLibpod // --- @@ -123,11 +123,11 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // schema: // $ref: "#/definitions/IDResponse" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchImage" + // $ref: "#/responses/imageNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" v3.Handle("/create", s.APIHandler(libpod.ManifestCreate)).Methods(http.MethodPost) v4.Handle("/{name:.*}", s.APIHandler(libpod.ManifestCreate)).Methods(http.MethodPost) // swagger:operation GET /libpod/manifests/{name}/exists manifests ManifestExistsLibpod @@ -149,9 +149,9 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // 204: // description: manifest list exists // 404: - // $ref: '#/responses/NoSuchManifest' + // $ref: '#/responses/manifestNotFound' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' v3.Handle("/{name:.*}/exists", s.APIHandler(libpod.ManifestExists)).Methods(http.MethodGet) v4.Handle("/{name:.*}/exists", s.APIHandler(libpod.ManifestExists)).Methods(http.MethodGet) // swagger:operation GET /libpod/manifests/{name}/json manifests ManifestInspectLibpod @@ -168,11 +168,11 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // description: the name or ID of the manifest list // responses: // 200: - // $ref: "#/responses/InspectManifest" + // $ref: "#/responses/manifestInspect" // 404: - // $ref: "#/responses/NoSuchManifest" + // $ref: "#/responses/manifestNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" v3.Handle("/{name:.*}/json", s.APIHandler(libpod.ManifestInspect)).Methods(http.MethodGet) v4.Handle("/{name:.*}/json", s.APIHandler(libpod.ManifestInspect)).Methods(http.MethodGet) // swagger:operation PUT /libpod/manifests/{name} manifests ManifestModifyLibpod @@ -208,15 +208,15 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // schema: // $ref: "#/definitions/ManifestModifyReport" // 404: - // $ref: "#/responses/NoSuchManifest" + // $ref: "#/responses/manifestNotFound" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 409: // description: Operation had partial success, both Images and Errors may have members // schema: // $ref: "#/definitions/ManifestModifyReport" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" v4.Handle("/{name:.*}", s.APIHandler(libpod.ManifestModify)).Methods(http.MethodPut) // swagger:operation POST /libpod/manifests/{name}/add manifests ManifestAddLibpod // --- @@ -243,11 +243,11 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // schema: // $ref: "#/definitions/IDResponse" // 404: - // $ref: "#/responses/NoSuchManifest" + // $ref: "#/responses/manifestNotFound" // 409: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" v3.Handle("/{name:.*}/add", s.APIHandler(libpod.ManifestAddV3)).Methods(http.MethodPost) // swagger:operation DELETE /libpod/manifests/{name} manifests ManifestDeleteV3Libpod // --- @@ -273,11 +273,11 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // schema: // $ref: "#/definitions/IDResponse" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchManifest" + // $ref: "#/responses/manifestNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" v3.Handle("/{name:.*}", s.APIHandler(libpod.ManifestRemoveDigestV3)).Methods(http.MethodDelete) // swagger:operation DELETE /libpod/manifests/{name} manifests ManifestDeleteLibpod // --- @@ -296,11 +296,11 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // description: The name or ID of the list to be deleted // responses: // 200: - // $ref: "#/responses/DocsLibpodImagesRemoveResponse" + // $ref: "#/responses/imagesRemoveResponseLibpod" // 404: - // $ref: "#/responses/NoSuchManifest" + // $ref: "#/responses/manifestNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" v4.Handle("/{name:.*}", s.APIHandler(libpod.ManifestDelete)).Methods(http.MethodDelete) return nil } diff --git a/pkg/api/server/register_networks.go b/pkg/api/server/register_networks.go index b900aa953..dcc656283 100644 --- a/pkg/api/server/register_networks.go +++ b/pkg/api/server/register_networks.go @@ -27,9 +27,9 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // 204: // description: no error // 404: - // $ref: "#/responses/NoSuchNetwork" + // $ref: "#/responses/networkNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/networks/{name}"), s.APIHandler(compat.RemoveNetwork)).Methods(http.MethodDelete) r.HandleFunc("/networks/{name}", s.APIHandler(compat.RemoveNetwork)).Methods(http.MethodDelete) // swagger:operation GET /networks/{name} compat NetworkInspect @@ -58,11 +58,11 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/CompatNetworkInspect" + // $ref: "#/responses/networkInspectCompat" // 404: - // $ref: "#/responses/NoSuchNetwork" + // $ref: "#/responses/networkNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/networks/{name}"), s.APIHandler(compat.InspectNetwork)).Methods(http.MethodGet) r.HandleFunc("/networks/{name}", s.APIHandler(compat.InspectNetwork)).Methods(http.MethodGet) // swagger:operation GET /networks compat NetworkList @@ -85,9 +85,9 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/CompatNetworkList" + // $ref: "#/responses/networkListCompat" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/networks"), s.APIHandler(compat.ListNetworks)).Methods(http.MethodGet) r.HandleFunc("/networks", s.APIHandler(compat.ListNetworks)).Methods(http.MethodGet) // swagger:operation POST /networks/create compat NetworkCreate @@ -103,7 +103,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // name: create // description: attributes for creating a network // schema: - // $ref: "#/definitions/NetworkCreateRequest" + // $ref: "#/definitions/networkCreate" // responses: // 201: // description: network created @@ -115,9 +115,9 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // Warning: // type: string // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/networks/create"), s.APIHandler(compat.CreateNetwork)).Methods(http.MethodPost) r.HandleFunc("/networks/create", s.APIHandler(compat.CreateNetwork)).Methods(http.MethodPost) // swagger:operation POST /networks/{name}/connect compat NetworkConnect @@ -138,14 +138,14 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // name: create // description: attributes for connecting a container to a network // schema: - // $ref: "#/definitions/NetworkCompatConnectRequest" + // $ref: "#/definitions/networkConnectRequest" // responses: // 200: // description: OK // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/networks/{name}/connect"), s.APIHandler(compat.Connect)).Methods(http.MethodPost) r.HandleFunc("/networks/{name}/connect", s.APIHandler(compat.Connect)).Methods(http.MethodPost) // swagger:operation POST /networks/{name}/disconnect compat NetworkDisconnect @@ -166,14 +166,14 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // name: create // description: attributes for disconnecting a container from a network // schema: - // $ref: "#/definitions/NetworkCompatDisconnectRequest" + // $ref: "#/definitions/networkDisconnectRequest" // responses: // 200: // description: OK // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/networks/{name}/disconnect"), s.APIHandler(compat.Disconnect)).Methods(http.MethodPost) r.HandleFunc("/networks/{name}/disconnect", s.APIHandler(compat.Disconnect)).Methods(http.MethodPost) // swagger:operation POST /networks/prune compat NetworkPrune @@ -204,7 +204,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // items: // type: string // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/networks/prune"), s.APIHandler(compat.Prune)).Methods(http.MethodPost) r.HandleFunc("/networks/prune", s.APIHandler(compat.Prune)).Methods(http.MethodPost) @@ -228,11 +228,11 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/NetworkRmReport" + // $ref: "#/responses/networkRmResponse" // 404: - // $ref: "#/responses/NoSuchNetwork" + // $ref: "#/responses/networkNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/networks/{name}"), s.APIHandler(libpod.RemoveNetwork)).Methods(http.MethodDelete) // swagger:operation GET /libpod/networks/{name}/exists libpod NetworkExistsLibpod // --- @@ -252,9 +252,9 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // 204: // description: network exists // 404: - // $ref: '#/responses/NoSuchNetwork' + // $ref: '#/responses/networkNotFound' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/networks/{name}/exists"), s.APIHandler(libpod.ExistsNetwork)).Methods(http.MethodGet) // swagger:operation GET /libpod/networks/json libpod NetworkListLibpod // --- @@ -279,9 +279,9 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/NetworkListReport" + // $ref: "#/responses/networkListLibpod" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/networks/json"), s.APIHandler(libpod.ListNetworks)).Methods(http.MethodGet) // swagger:operation GET /libpod/networks/{name}/json libpod NetworkInspectLibpod // --- @@ -301,11 +301,11 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/NetworkInspectReport" + // $ref: "#/responses/networkInspectResponse" // 404: - // $ref: "#/responses/NoSuchNetwork" + // $ref: "#/responses/networkNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/networks/{name}/json"), s.APIHandler(libpod.InspectNetwork)).Methods(http.MethodGet) r.HandleFunc(VersionedPath("/libpod/networks/{name}"), s.APIHandler(libpod.InspectNetwork)).Methods(http.MethodGet) // swagger:operation POST /libpod/networks/create libpod NetworkCreateLibpod @@ -321,16 +321,16 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // name: create // description: attributes for creating a network // schema: - // $ref: "#/definitions/NetworkCreateLibpod" + // $ref: "#/definitions/networkCreateLibpod" // responses: // 200: - // $ref: "#/responses/NetworkCreateReport" + // $ref: "#/responses/networkCreateResponse" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 409: - // $ref: "#/responses/ConflictError" + // $ref: "#/responses/conflictError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/networks/create"), s.APIHandler(libpod.CreateNetwork)).Methods(http.MethodPost) // swagger:operation POST /libpod/networks/{name}/connect libpod NetworkConnectLibpod // --- @@ -350,14 +350,14 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // name: create // description: attributes for connecting a container to a network // schema: - // $ref: "#/definitions/NetworkConnectRequest" + // $ref: "#/definitions/networkConnectRequestLibpod" // responses: // 200: // description: OK // 404: - // $ref: "#/responses/NoSuchNetwork" + // $ref: "#/responses/networkNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/networks/{name}/connect"), s.APIHandler(libpod.Connect)).Methods(http.MethodPost) // swagger:operation POST /libpod/networks/{name}/disconnect libpod NetworkDisconnectLibpod // --- @@ -377,14 +377,14 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // name: create // description: attributes for disconnecting a container from a network // schema: - // $ref: "#/definitions/NetworkCompatDisconnectRequest" + // $ref: "#/definitions/networkDisconnectRequest" // responses: // 200: // description: OK // 404: - // $ref: "#/responses/NoSuchNetwork" + // $ref: "#/responses/networkNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/networks/{name}/disconnect"), s.APIHandler(compat.Disconnect)).Methods(http.MethodPost) // swagger:operation POST /libpod/networks/prune libpod NetworkPruneLibpod // --- @@ -405,9 +405,9 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune networks with (or without, in case `label!=...` is used) the specified labels. // responses: // 200: - // $ref: "#/responses/NetworkPruneResponse" + // $ref: "#/responses/networkPruneResponse" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/networks/prune"), s.APIHandler(libpod.Prune)).Methods(http.MethodPost) return nil } diff --git a/pkg/api/server/register_ping.go b/pkg/api/server/register_ping.go index 22c7eb3fd..fcc8b4a10 100644 --- a/pkg/api/server/register_ping.go +++ b/pkg/api/server/register_ping.go @@ -59,7 +59,7 @@ func (s *APIServer) registerPingHandlers(r *mux.Router) error { // Available if service is backed by Podman, therefore may be used to // determine if talking to Podman engine or another engine // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle("/libpod/_ping", s.APIHandler(compat.Ping)).Methods(http.MethodGet, http.MethodHead) r.Handle(VersionedPath("/libpod/_ping"), s.APIHandler(compat.Ping)).Methods(http.MethodGet, http.MethodHead) return nil diff --git a/pkg/api/server/register_play.go b/pkg/api/server/register_play.go index 52bc75bcf..35da80ccc 100644 --- a/pkg/api/server/register_play.go +++ b/pkg/api/server/register_play.go @@ -57,9 +57,9 @@ func (s *APIServer) registerPlayHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsLibpodPlayKubeResponse" + // $ref: "#/responses/playKubeResponseLibpod" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/play/kube"), s.APIHandler(libpod.PlayKube)).Methods(http.MethodPost) // swagger:operation DELETE /libpod/play/kube libpod PlayKubeDownLibpod // --- @@ -72,9 +72,9 @@ func (s *APIServer) registerPlayHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsLibpodPlayKubeResponse" + // $ref: "#/responses/playKubeResponseLibpod" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.HandleFunc(VersionedPath("/libpod/play/kube"), s.APIHandler(libpod.PlayKubeDown)).Methods(http.MethodDelete) return nil } diff --git a/pkg/api/server/register_pods.go b/pkg/api/server/register_pods.go index 7aeafe724..d54cc413e 100644 --- a/pkg/api/server/register_pods.go +++ b/pkg/api/server/register_pods.go @@ -31,11 +31,11 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // - `ctr-number=<pod-ctr-number>` Number of containers in the pod. // responses: // 200: - // $ref: "#/responses/ListPodsResponse" + // $ref: "#/responses/podsListResponse" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/json"), s.APIHandler(libpod.Pods)).Methods(http.MethodGet) // swagger:operation POST /libpod/pods/create pods PodCreateLibpod // --- @@ -53,14 +53,14 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // schema: // $ref: "#/definitions/IDResponse" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 409: // description: status conflict // schema: // type: string // description: message describing error // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/create"), s.APIHandler(libpod.PodCreate)).Methods(http.MethodPost) // swagger:operation POST /libpod/pods/prune pods PodPruneLibpod // --- @@ -69,13 +69,13 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: '#/responses/PodPruneReport' + // $ref: '#/responses/podPruneResponse' // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 409: // description: pod already exists // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/prune"), s.APIHandler(libpod.PodPrune)).Methods(http.MethodPost) // swagger:operation DELETE /libpod/pods/{name} pods PodDeleteLibpod // --- @@ -94,13 +94,13 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // description : force removal of a running pod by first stopping all containers, then removing all containers in the pod // responses: // 200: - // $ref: '#/responses/PodRmReport' + // $ref: '#/responses/podRmResponse' // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchPod" + // $ref: "#/responses/podNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/{name}"), s.APIHandler(libpod.PodDelete)).Methods(http.MethodDelete) // swagger:operation GET /libpod/pods/{name}/json pods PodInspectLibpod // --- @@ -115,11 +115,11 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // description: the name or ID of the pod // responses: // 200: - // $ref: "#/responses/InspectPodResponse" + // $ref: "#/responses/podInspectResponse" // 404: - // $ref: "#/responses/NoSuchPod" + // $ref: "#/responses/podNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/{name}/json"), s.APIHandler(libpod.PodInspect)).Methods(http.MethodGet) // swagger:operation GET /libpod/pods/{name}/exists pods PodExistsLibpod // --- @@ -137,9 +137,9 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 204: // description: pod exists // 404: - // $ref: "#/responses/NoSuchPod" + // $ref: "#/responses/podNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/{name}/exists"), s.APIHandler(libpod.PodExists)).Methods(http.MethodGet) // swagger:operation POST /libpod/pods/{name}/kill pods PodKillLibpod // --- @@ -159,15 +159,15 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // default: SIGKILL // responses: // 200: - // $ref: "#/responses/PodKillReport" + // $ref: "#/responses/podKillResponse" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchPod" + // $ref: "#/responses/podNotFound" // 409: - // $ref: "#/responses/PodKillReport" + // $ref: "#/responses/podKillResponse" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/{name}/kill"), s.APIHandler(libpod.PodKill)).Methods(http.MethodPost) // swagger:operation POST /libpod/pods/{name}/pause pods PodPauseLibpod // --- @@ -183,13 +183,13 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // description: the name or ID of the pod // responses: // 200: - // $ref: '#/responses/PodPauseReport' + // $ref: '#/responses/podPauseResponse' // 404: - // $ref: "#/responses/NoSuchPod" + // $ref: "#/responses/podNotFound" // 409: - // $ref: '#/responses/PodPauseReport' + // $ref: '#/responses/podPauseResponse' // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/{name}/pause"), s.APIHandler(libpod.PodPause)).Methods(http.MethodPost) // swagger:operation POST /libpod/pods/{name}/restart pods PodRestartLibpod // --- @@ -204,13 +204,13 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // description: the name or ID of the pod // responses: // 200: - // $ref: '#/responses/PodRestartReport' + // $ref: '#/responses/podRestartResponse' // 404: - // $ref: "#/responses/NoSuchPod" + // $ref: "#/responses/podNotFound" // 409: - // $ref: "#/responses/PodRestartReport" + // $ref: "#/responses/podRestartResponse" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/{name}/restart"), s.APIHandler(libpod.PodRestart)).Methods(http.MethodPost) // swagger:operation POST /libpod/pods/{name}/start pods PodStartLibpod // --- @@ -225,15 +225,15 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // description: the name or ID of the pod // responses: // 200: - // $ref: '#/responses/PodStartReport' + // $ref: '#/responses/podStartResponse' // 304: - // $ref: "#/responses/PodAlreadyStartedError" + // $ref: "#/responses/podAlreadyStartedError" // 404: - // $ref: "#/responses/NoSuchPod" + // $ref: "#/responses/podNotFound" // 409: - // $ref: '#/responses/PodStartReport' + // $ref: '#/responses/podStartResponse' // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/{name}/start"), s.APIHandler(libpod.PodStart)).Methods(http.MethodPost) // swagger:operation POST /libpod/pods/{name}/stop pods PodStopLibpod // --- @@ -252,17 +252,17 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // description: timeout // responses: // 200: - // $ref: '#/responses/PodStopReport' + // $ref: '#/responses/podStopResponse' // 304: - // $ref: "#/responses/PodAlreadyStoppedError" + // $ref: "#/responses/podAlreadyStoppedError" // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 404: - // $ref: "#/responses/NoSuchPod" + // $ref: "#/responses/podNotFound" // 409: - // $ref: "#/responses/PodStopReport" + // $ref: "#/responses/podStopResponse" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/{name}/stop"), s.APIHandler(libpod.PodStop)).Methods(http.MethodPost) // swagger:operation POST /libpod/pods/{name}/unpause pods PodUnpauseLibpod // --- @@ -277,13 +277,13 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // description: the name or ID of the pod // responses: // 200: - // $ref: '#/responses/PodUnpauseReport' + // $ref: '#/responses/podUnpauseResponse' // 404: - // $ref: "#/responses/NoSuchPod" + // $ref: "#/responses/podNotFound" // 409: - // $ref: '#/responses/PodUnpauseReport' + // $ref: '#/responses/podUnpauseResponse' // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/{name}/unpause"), s.APIHandler(libpod.PodUnpause)).Methods(http.MethodPost) // swagger:operation GET /libpod/pods/{name}/top pods PodTopLibpod // --- @@ -315,17 +315,17 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // Requires ps(1) to be installed in the container if no ps(1) compatible AIX descriptors are used. // responses: // 200: - // $ref: "#/responses/DocsPodTopResponse" + // $ref: "#/responses/podTopResponse" // 404: - // $ref: "#/responses/NoSuchPod" + // $ref: "#/responses/podNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/{name}/top"), s.APIHandler(libpod.PodTop)).Methods(http.MethodGet) // swagger:operation GET /libpod/pods/stats pods PodStatsAllLibpod // --- // tags: // - pods - // summary: Get stats for one or more pods + // summary: Statistics for one or more pods // description: Display a live stream of resource usage statistics for the containers in one or more pods // parameters: // - in: query @@ -342,11 +342,11 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/DocsPodTopResponse" + // $ref: "#/responses/podStatsResponse" // 404: - // $ref: "#/responses/NoSuchPod" + // $ref: "#/responses/podNotFound" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/pods/stats"), s.APIHandler(libpod.PodStats)).Methods(http.MethodGet) return nil } diff --git a/pkg/api/server/register_secrets.go b/pkg/api/server/register_secrets.go index 26bc07834..f4608baa6 100644 --- a/pkg/api/server/register_secrets.go +++ b/pkg/api/server/register_secrets.go @@ -36,7 +36,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // '201': // $ref: "#/responses/SecretCreateResponse" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/libpod/secrets/create"), s.APIHandler(libpod.CreateSecret)).Methods(http.MethodPost) // swagger:operation GET /libpod/secrets/json libpod SecretListLibpod // --- @@ -59,7 +59,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // '200': // "$ref": "#/responses/SecretListResponse" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/libpod/secrets/json"), s.APIHandler(compat.ListSecrets)).Methods(http.MethodGet) // swagger:operation GET /libpod/secrets/{name}/json libpod SecretInspectLibpod // --- @@ -80,7 +80,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // '404': // "$ref": "#/responses/NoSuchSecret" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/libpod/secrets/{name}/json"), s.APIHandler(compat.InspectSecret)).Methods(http.MethodGet) // swagger:operation DELETE /libpod/secrets/{name} libpod SecretDeleteLibpod // --- @@ -106,7 +106,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // '404': // "$ref": "#/responses/NoSuchSecret" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/libpod/secrets/{name}"), s.APIHandler(compat.RemoveSecret)).Methods(http.MethodDelete) /* @@ -133,7 +133,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // '200': // "$ref": "#/responses/SecretListCompatResponse" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/secrets"), s.APIHandler(compat.ListSecrets)).Methods(http.MethodGet) r.Handle("/secrets", s.APIHandler(compat.ListSecrets)).Methods(http.MethodGet) // swagger:operation POST /secrets/create compat SecretCreate @@ -156,7 +156,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // '409': // "$ref": "#/responses/SecretInUse" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/secrets/create"), s.APIHandler(compat.CreateSecret)).Methods(http.MethodPost) r.Handle("/secrets/create", s.APIHandler(compat.CreateSecret)).Methods(http.MethodPost) // swagger:operation GET /secrets/{name} compat SecretInspect @@ -178,7 +178,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // '404': // "$ref": "#/responses/NoSuchSecret" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/secrets/{name}"), s.APIHandler(compat.InspectSecret)).Methods(http.MethodGet) r.Handle("/secrets/{name}", s.APIHandler(compat.InspectSecret)).Methods(http.MethodGet) // swagger:operation DELETE /secrets/{name} compat SecretDelete @@ -200,7 +200,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // '404': // "$ref": "#/responses/NoSuchSecret" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/secrets/{name}"), s.APIHandler(compat.RemoveSecret)).Methods(http.MethodDelete) r.Handle("/secret/{name}", s.APIHandler(compat.RemoveSecret)).Methods(http.MethodDelete) diff --git a/pkg/api/server/register_system.go b/pkg/api/server/register_system.go index a70f3b5f2..8932ecc81 100644 --- a/pkg/api/server/register_system.go +++ b/pkg/api/server/register_system.go @@ -19,9 +19,9 @@ func (s *APIServer) registerSystemHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: '#/responses/SystemDiskUse' + // $ref: '#/responses/systemDiskUsage' // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/system/df"), s.APIHandler(compat.GetDiskUsage)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/system/df", s.APIHandler(compat.GetDiskUsage)).Methods(http.MethodGet) @@ -34,11 +34,11 @@ func (s *APIServer) registerSystemHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: '#/responses/SystemPruneReport' + // $ref: '#/responses/systemPruneResponse' // 400: - // $ref: "#/responses/BadParamError" + // $ref: "#/responses/badParamError" // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/system/prune"), s.APIHandler(libpod.SystemPrune)).Methods(http.MethodPost) // swagger:operation GET /libpod/system/df libpod SystemDataUsageLibpod // --- @@ -50,9 +50,9 @@ func (s *APIServer) registerSystemHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: '#/responses/SystemDiskUse' + // $ref: '#/responses/systemDiskUsage' // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/system/df"), s.APIHandler(libpod.DiskUsage)).Methods(http.MethodGet) return nil } diff --git a/pkg/api/server/register_version.go b/pkg/api/server/register_version.go index e9680f9ef..f7bdc2ea9 100644 --- a/pkg/api/server/register_version.go +++ b/pkg/api/server/register_version.go @@ -17,7 +17,7 @@ func (s *APIServer) registerVersionHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/Version" + // $ref: "#/responses/versionResponse" r.Handle("/version", s.APIHandler(compat.VersionHandler)).Methods(http.MethodGet) r.Handle(VersionedPath("/version"), s.APIHandler(compat.VersionHandler)).Methods(http.MethodGet) // swagger:operation GET /libpod/version libpod SystemVersionLibpod @@ -29,7 +29,7 @@ func (s *APIServer) registerVersionHandlers(r *mux.Router) error { // - application/json // responses: // 200: - // $ref: "#/responses/Version" + // $ref: "#/responses/versionResponse" r.Handle(VersionedPath("/libpod/version"), s.APIHandler(compat.VersionHandler)).Methods(http.MethodGet) return nil } diff --git a/pkg/api/server/register_volumes.go b/pkg/api/server/register_volumes.go index d36350146..820953b09 100644 --- a/pkg/api/server/register_volumes.go +++ b/pkg/api/server/register_volumes.go @@ -19,14 +19,14 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // name: create // description: attributes for creating a volume // schema: - // $ref: "#/definitions/VolumeCreate" + // $ref: "#/definitions/VolumeCreateOptions" // produces: // - application/json // responses: // '201': - // $ref: "#/responses/VolumeCreateResponse" + // $ref: "#/responses/volumeCreateResponse" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/libpod/volumes/create"), s.APIHandler(libpod.CreateVolume)).Methods(http.MethodPost) // swagger:operation GET /libpod/volumes/{name}/exists libpod VolumeExistsLibpod // --- @@ -46,9 +46,9 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // 204: // description: volume exists // 404: - // $ref: '#/responses/NoSuchVolume' + // $ref: '#/responses/volumeNotFound' // 500: - // $ref: '#/responses/InternalError' + // $ref: '#/responses/internalError' r.Handle(VersionedPath("/libpod/volumes/{name}/exists"), s.APIHandler(libpod.ExistsVolume)).Methods(http.MethodGet) // swagger:operation GET /libpod/volumes/json libpod VolumeListLibpod // --- @@ -71,9 +71,9 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // - `until=<timestamp>` List volumes created before this timestamp. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon machine’s time. // responses: // '200': - // "$ref": "#/responses/VolumeList" + // "$ref": "#/responses/volumeListLibpod" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/libpod/volumes/json"), s.APIHandler(libpod.ListVolumes)).Methods(http.MethodGet) // swagger:operation POST /libpod/volumes/prune libpod VolumePruneLibpod // --- @@ -93,9 +93,9 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune volumes with (or without, in case `label!=...` is used) the specified labels. // responses: // '200': - // "$ref": "#/responses/VolumePruneResponse" + // "$ref": "#/responses/volumePruneLibpod" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/libpod/volumes/prune"), s.APIHandler(libpod.PruneVolumes)).Methods(http.MethodPost) // swagger:operation GET /libpod/volumes/{name}/json libpod VolumeInspectLibpod // --- @@ -111,12 +111,12 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // produces: // - application/json // responses: - // '200': - // "$ref": "#/responses/VolumeCreateResponse" - // '404': - // "$ref": "#/responses/NoSuchVolume" - // '500': - // "$ref": "#/responses/InternalError" + // 200: + // $ref: "#/responses/volumeCreateResponse" + // 404: + // $ref: "#/responses/volumeNotFound" + // 500: + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/volumes/{name}/json"), s.APIHandler(libpod.InspectVolume)).Methods(http.MethodGet) // swagger:operation DELETE /libpod/volumes/{name} libpod VolumeDeleteLibpod // --- @@ -139,11 +139,11 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // 204: // description: no error // 404: - // $ref: "#/responses/NoSuchVolume" + // $ref: "#/responses/volumeNotFound" // 409: // description: Volume is in use and cannot be removed // 500: - // $ref: "#/responses/InternalError" + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/libpod/volumes/{name}"), s.APIHandler(libpod.RemoveVolume)).Methods(http.MethodDelete) /* @@ -173,9 +173,9 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // The boolean `dangling` filter is not yet implemented for this endpoint. // responses: // '200': - // "$ref": "#/responses/VolumeListResponse" + // "$ref": "#/responses/volumeList" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/volumes"), s.APIHandler(compat.ListVolumes)).Methods(http.MethodGet) r.Handle("/volumes", s.APIHandler(compat.ListVolumes)).Methods(http.MethodGet) @@ -191,14 +191,14 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // attributes for creating a volume. // Note: If a volume by the same name exists, a 201 response with that volume's information will be generated. // schema: - // $ref: "#/definitions/DockerVolumeCreate" + // $ref: "#/definitions/volumeCreate" // produces: // - application/json // responses: // '201': - // "$ref": "#/responses/DockerVolumeInfoResponse" + // "$ref": "#/responses/volumeInspect" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/volumes/create"), s.APIHandler(compat.CreateVolume)).Methods(http.MethodPost) r.Handle("/volumes/create", s.APIHandler(compat.CreateVolume)).Methods(http.MethodPost) @@ -216,12 +216,12 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // produces: // - application/json // responses: - // '200': - // "$ref": "#/responses/DockerVolumeInfoResponse" - // '404': - // "$ref": "#/responses/NoSuchVolume" - // '500': - // "$ref": "#/responses/InternalError" + // 200: + // $ref: "#/responses/volumeInspect" + // 40': + // $ref: "#/responses/volumeNotFound" + // 500: + // $ref: "#/responses/internalError" r.Handle(VersionedPath("/volumes/{name}"), s.APIHandler(compat.InspectVolume)).Methods(http.MethodGet) r.Handle("/volumes/{name}", s.APIHandler(compat.InspectVolume)).Methods(http.MethodGet) @@ -249,11 +249,11 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // 204: // description: no error // 404: - // "$ref": "#/responses/NoSuchVolume" + // $ref: "#/responses/volumeNotFound" // 409: // description: Volume is in use and cannot be removed // 500: - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/volumes/{name}"), s.APIHandler(compat.RemoveVolume)).Methods(http.MethodDelete) r.Handle("/volumes/{name}", s.APIHandler(compat.RemoveVolume)).Methods(http.MethodDelete) @@ -275,9 +275,9 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune volumes with (or without, in case `label!=...` is used) the specified labels. // responses: // '200': - // "$ref": "#/responses/DockerVolumePruneResponse" + // "$ref": "#/responses/volumePruneResponse" // '500': - // "$ref": "#/responses/InternalError" + // "$ref": "#/responses/internalError" r.Handle(VersionedPath("/volumes/prune"), s.APIHandler(compat.PruneVolumes)).Methods(http.MethodPost) r.Handle("/volumes/prune", s.APIHandler(compat.PruneVolumes)).Methods(http.MethodPost) diff --git a/pkg/api/server/server.go b/pkg/api/server/server.go index 7f5537fb4..7a7e35e8e 100644 --- a/pkg/api/server/server.go +++ b/pkg/api/server/server.go @@ -45,10 +45,8 @@ const ( UnlimitedServiceDuration = 0 * time.Second ) -var ( - // shutdownOnce ensures Shutdown() may safely be called from several go routines - shutdownOnce sync.Once -) +// shutdownOnce ensures Shutdown() may safely be called from several go routines +var shutdownOnce sync.Once // NewServer will create and configure a new API server with all defaults func NewServer(runtime *libpod.Runtime) (*APIServer, error) { @@ -209,7 +207,7 @@ func (s *APIServer) Serve() error { }() // Before we start serving, ensure umask is properly set for container creation. - _ = syscall.Umask(0022) + _ = syscall.Umask(0o022) errChan := make(chan error, 1) s.setupSystemd() diff --git a/pkg/api/server/swagger.go b/pkg/api/server/swagger.go deleted file mode 100644 index 6cf89581a..000000000 --- a/pkg/api/server/swagger.go +++ /dev/null @@ -1,246 +0,0 @@ -package server - -import ( - "github.com/containers/podman/v4/libpod/define" - "github.com/containers/podman/v4/pkg/domain/entities" - "github.com/containers/podman/v4/pkg/domain/entities/reports" - "github.com/containers/podman/v4/pkg/errorhandling" - docker "github.com/docker/docker/api/types" -) - -// No such image -// swagger:response NoSuchImage -type swagErrNoSuchImage struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// No such container -// swagger:response NoSuchContainer -type swagErrNoSuchContainer struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// No such network -// swagger:response NoSuchNetwork -type swagErrNoSuchNetwork struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// No such exec instance -// swagger:response NoSuchExecInstance -type swagErrNoSuchExecInstance struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// No such volume -// swagger:response NoSuchVolume -type swagErrNoSuchVolume struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// No such pod -// swagger:response NoSuchPod -type swagErrNoSuchPod struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// No such manifest -// swagger:response NoSuchManifest -type swagErrNoSuchManifest struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// Internal server error -// swagger:response InternalError -type swagInternalError struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// Conflict error in operation -// swagger:response ConflictError -type swagConflictError struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// Bad parameter in request -// swagger:response BadParamError -type swagBadParamError struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// Container already started -// swagger:response ContainerAlreadyStartedError -type swagContainerAlreadyStartedError struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// Container already stopped -// swagger:response ContainerAlreadyStoppedError -type swagContainerAlreadyStopped struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// Pod already started -// swagger:response PodAlreadyStartedError -type swagPodAlreadyStartedError struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// Pod already stopped -// swagger:response PodAlreadyStoppedError -type swagPodAlreadyStopped struct { - // in:body - Body struct { - errorhandling.ErrorModel - } -} - -// Image summary for compat API -// swagger:response DockerImageSummaryResponse -type swagDockerImageSummaryResponse struct { - // in:body - Body []docker.ImageSummary -} - -// Image summary for libpod API -// swagger:response LibpodImageSummaryResponse -type swagLibpodImageSummaryResponse struct { - // in:body - Body []entities.ImageSummary -} - -// List Containers -// swagger:response DocsListContainer -type swagListContainers struct { - // in:body - Body struct { - // This causes go-swagger to crash - // handlers.Container - } -} - -// Success -// swagger:response -type ok struct { - // in:body - Body struct { - // example: OK - ok string - } -} - -// Volume prune response -// swagger:response VolumePruneResponse -type swagVolumePruneResponse struct { - // in:body - Body []reports.PruneReport -} - -// Volume create response -// swagger:response VolumeCreateResponse -type swagVolumeCreateResponse struct { - // in:body - Body struct { - entities.VolumeConfigResponse - } -} - -// Volume list -// swagger:response VolumeList -type swagVolumeListResponse struct { - // in:body - Body []entities.VolumeConfigResponse -} - -// Healthcheck -// swagger:response HealthcheckRun -type swagHealthCheckRunResponse struct { - // in:body - Body struct { - define.HealthCheckResults - } -} - -// Version -// swagger:response Version -type swagVersion struct { - // in:body - Body struct { - entities.ComponentVersion - } -} - -// Disk usage -// swagger:response SystemDiskUse -type swagDiskUseResponse struct { - // in:body - Body struct { - entities.SystemDfReport - } -} - -// Prune report -// swagger:response SystemPruneReport -type swagSystemPruneReport struct { - // in:body - Body struct { - entities.SystemPruneReport - } -} - -// Auth response -// swagger:response SystemAuthResponse -type swagSystemAuthResponse struct { - // in:body - Body struct { - entities.AuthReport - } -} - -// Inspect response -// swagger:response InspectExecSession -type swagInspectExecSession struct { - // in:body - Body struct { - define.InspectExecSession - } -} diff --git a/pkg/api/types/types.go b/pkg/api/types/types.go index d5067cc54..034bae6d4 100644 --- a/pkg/api/types/types.go +++ b/pkg/api/types/types.go @@ -1,13 +1,5 @@ package types -const ( - // DefaultAPIVersion is the version of the compatible API the server defaults to - DefaultAPIVersion = "1.40" // See https://docs.docker.com/engine/api/v1.40/ - - // MinimalAPIVersion is the minimal required version of the compatible API - MinimalAPIVersion = "1.24" -) - type APIContextKey int const ( |