Initial cut for removing the old API.

Remove API reverse proxy server and google dependencies.
Remove API config.
Remove API client.
Remove API GRPC server.
Remove unused ImageCopy function. image.Duplicate is used.
Update Makefile to avoid protobuf builds.

Signed-off-by: Matt Hink <mhink@ciq.com>
This commit is contained in:
Matt Hink
2025-04-21 16:00:48 -07:00
committed by Jonathon Anderson
parent edc0e151c3
commit be73ac056a
24 changed files with 4 additions and 2271 deletions

View File

@@ -1,42 +0,0 @@
package apiconfig
import (
"log"
"os"
"gopkg.in/yaml.v3"
)
// ClientApiConfig contains configuration parameters for an API server.
type ClientApiConfig struct {
// Server is the hostname or IP address of the server to connect to.
Server string `yaml:"prefix"`
// Port is the where the API server listens.
Port uint32 `yaml:"port"`
}
// ClientConfig is the full client configuration.
type ClientConfig struct {
ApiConfig ClientApiConfig `yaml:"api"`
TlsConfig TlsConfig `yaml:"tls"`
}
// NewClient loads the client config from the given configFilePath.
func NewClient(configFilePath string) (config ClientConfig, err error) {
log.Printf("Loading api client configuration from: %v\n", configFilePath)
var fileBytes []byte
fileBytes, err = os.ReadFile(configFilePath)
if err != nil {
return
}
err = yaml.Unmarshal(fileBytes, &config)
if err != nil {
return
}
log.Printf("api client config: %#v\n", config)
return
}

View File

@@ -1,38 +0,0 @@
package apiconfig
import (
"log"
"os"
"gopkg.in/yaml.v3"
)
// ClientServerConfig is the full client server configuration.
// wwapird is a client of wwapid.
// wwapird serves REST. (WareWulf API Rest Daemon)
type ClientServerConfig struct {
ClientApiConfig ClientApiConfig `yaml:"clientapi"`
ServerApiConfig ServerApiConfig `yaml:"serverapi"`
ClientTlsConfig TlsConfig `yaml:"clienttls"`
ServerTlsConfig TlsConfig `yaml:"servertls"`
}
// NewClientServer loads the client config from the given configFilePath.
func NewClientServer(configFilePath string) (config ClientServerConfig, err error) {
log.Printf("Loading api client server configuration from: %v\n", configFilePath)
var fileBytes []byte
fileBytes, err = os.ReadFile(configFilePath)
if err != nil {
return
}
err = yaml.Unmarshal(fileBytes, &config)
if err != nil {
return
}
log.Printf("api client server config: %#v\n", config)
return
}

View File

@@ -1,44 +0,0 @@
package apiconfig
import (
"log"
"os"
"gopkg.in/yaml.v3"
)
// ServerApiConfig contains configuration parameters for an API server.
type ServerApiConfig struct {
// Version contains the full version of the API server, eg: 1.0.0.
Version string `yaml:"version"`
// Prefix contains the version url prefix for the API server, eg: v1.
Prefix string `yaml:"prefix"`
// Port is the where the API server listens.
Port uint32 `yaml:"port"`
}
// ServerConfig is the full server configuration.
type ServerConfig struct {
ApiConfig ServerApiConfig `yaml:"api"`
TlsConfig TlsConfig `yaml:"tls"`
}
// NewServer loads the server config from the given configFilePath.
func NewServer(configFilePath string) (config ServerConfig, err error) {
log.Printf("Loading api server configuration from: %v\n", configFilePath)
var fileBytes []byte
fileBytes, err = os.ReadFile(configFilePath)
if err != nil {
return
}
err = yaml.Unmarshal(fileBytes, &config)
if err != nil {
return
}
log.Printf("api server config: %#v\n", config)
return
}

View File

@@ -1,20 +0,0 @@
package apiconfig
// TlsConfig contains TLS configuration parameters for a client or server.
type TlsConfig struct {
// Enabled is true when secure.
Enabled bool `yaml:"enabled"`
// Cert is the path to the client or server certificate file.
Cert string `yaml:"cert,omitempty"`
// Key is the path to the client or server key file.
Key string `yaml:"key,omitempty"`
// CaCert is the path the CA certificate file.
CaCert string `yaml:"cacert,omitempty"`
// ConcatCert is for wwapird. http.ListenAndServeTLS wants the following
// cert file, so in our case this file contains `cat ${Cert} ${CaCert}`
//
// If the certificate is signed by a certificate authority, the certFile
// should be the concatenation of the server's certificate, any
// intermediates, and the CA's certificate
ConcatCert string `yaml:"concatcert,omitempty"`
}

View File

@@ -18,38 +18,6 @@ import (
"github.com/warewulf/warewulf/internal/pkg/wwlog"
)
func ImageCopy(cbp *wwapiv1.ImageCopyParameter) (err error) {
if cbp == nil {
return fmt.Errorf("imageCopyParameter is nil")
}
if !image.DoesSourceExist(cbp.ImageSource) {
return fmt.Errorf("image %s does not exist", cbp.ImageSource)
}
if !image.ValidName(cbp.ImageDestination) {
return fmt.Errorf("image name contains illegal characters : %s", cbp.ImageDestination)
}
if image.DoesSourceExist(cbp.ImageDestination) {
return fmt.Errorf("an other image with the name %s already exists", cbp.ImageDestination)
}
err = image.Duplicate(cbp.ImageSource, cbp.ImageDestination)
if err != nil {
return fmt.Errorf("could not duplicate image: %s", err.Error())
}
if cbp.Build {
err = image.Build(cbp.ImageDestination, true)
if err != nil {
return err
}
}
return fmt.Errorf("image %s has been succesfully duplicated as %s", cbp.ImageSource, cbp.ImageDestination)
}
func ImageBuild(cbp *wwapiv1.ImageBuildParameter) (err error) {
if cbp == nil {
return fmt.Errorf("input parameter is nil")