cmd: delete osbuild-koji
Delete the osbuild-koji tools, which is not used by any code or test case. This also allows to delete the koji.NewFromPlain() function. This is to minimize the set of exported functions by the koji package, before moving it to osbuild/images repository. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
parent
651946ae54
commit
97c3460a94
3 changed files with 0 additions and 149 deletions
|
|
@ -8,8 +8,6 @@ osbuild-worker: The worker binary that handles jobs from the job queue locally.
|
|||
|
||||
osbuild-worker-executor: The binary that runs osbuild to build an image on an isolated VM.
|
||||
|
||||
osbuild-koji: Submits builds to Koji.
|
||||
|
||||
Service binaries
|
||||
================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,124 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/osbuild/images/pkg/platform"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/koji"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var taskID int
|
||||
var server, user, password, name, version, release, arch, filename string
|
||||
flag.IntVar(&taskID, "task-id", 0, "id of owning task")
|
||||
flag.StringVar(&server, "server", "", "url to API")
|
||||
flag.StringVar(&user, "user", "", "koji username")
|
||||
flag.StringVar(&password, "password", "", "koji password")
|
||||
flag.StringVar(&name, "name", "", "image name")
|
||||
flag.StringVar(&version, "version", "", "image verison")
|
||||
flag.StringVar(&release, "release", "", "image release")
|
||||
flag.StringVar(&arch, "arch", "", "image architecture")
|
||||
flag.StringVar(&filename, "filename", "", "filename")
|
||||
flag.Parse()
|
||||
|
||||
id, err := uuid.NewRandom()
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
return
|
||||
}
|
||||
dir := fmt.Sprintf("osbuild-%v", id)
|
||||
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
transport := koji.CreateRetryableTransport(nil)
|
||||
k, err := koji.NewFromPlain(server, "osbuild", "osbuildpass", transport, nil)
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
err := k.Logout()
|
||||
if err != nil {
|
||||
log.Printf("logging out of koji failed: %s ", err)
|
||||
}
|
||||
}()
|
||||
|
||||
hash, length, err := k.Upload(file, dir, path.Base(filename))
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
build := koji.Build{
|
||||
TaskID: uint64(taskID),
|
||||
Name: name,
|
||||
Version: version,
|
||||
Release: release,
|
||||
StartTime: time.Now().Unix(),
|
||||
EndTime: time.Now().Unix(),
|
||||
}
|
||||
buildRoots := []koji.BuildRoot{
|
||||
{
|
||||
ID: 1,
|
||||
Host: koji.Host{
|
||||
Os: "RHEL8",
|
||||
Arch: arch,
|
||||
},
|
||||
ContentGenerator: koji.ContentGenerator{
|
||||
Name: "osbuild",
|
||||
Version: "1",
|
||||
},
|
||||
Container: koji.Container{
|
||||
Type: "nspawn",
|
||||
Arch: arch,
|
||||
},
|
||||
Tools: []koji.Tool{},
|
||||
RPMs: []koji.RPM{},
|
||||
},
|
||||
}
|
||||
output := []koji.BuildOutput{
|
||||
{
|
||||
BuildRootID: 1,
|
||||
Filename: path.Base(filename),
|
||||
FileSize: length,
|
||||
Arch: arch,
|
||||
ChecksumType: koji.ChecksumTypeMD5,
|
||||
Checksum: hash,
|
||||
Type: koji.BuildOutputTypeImage,
|
||||
RPMs: []koji.RPM{},
|
||||
Extra: &koji.BuildOutputExtra{
|
||||
ImageOutput: koji.ImageExtraInfo{
|
||||
Arch: arch,
|
||||
BootMode: platform.BOOT_NONE.String(), // TODO: put the correct boot mode here
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
initResult, err := k.CGInitBuild(build.Name, build.Version, build.Release)
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
build.BuildID = uint64(initResult.BuildID)
|
||||
|
||||
importResult, err := k.CGImport(build, buildRoots, output, dir, initResult.Token)
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Success, build id: %d\n", importResult.BuildID)
|
||||
}
|
||||
|
|
@ -75,29 +75,6 @@ func newKoji(server string, transport http.RoundTripper, reply loginReply, logge
|
|||
}, nil
|
||||
}
|
||||
|
||||
// NewFromPlain creates a new Koji sessions =authenticated using the plain
|
||||
// username/password method. If you want to speak to a public koji instance,
|
||||
// you probably cannot use this method.
|
||||
func NewFromPlain(server, user, password string, transport http.RoundTripper, logger rh.LeveledLogger) (*Koji, error) {
|
||||
// Create a temporary xmlrpc client.
|
||||
// The API doesn't require sessionID, sessionKey and callnum yet,
|
||||
// so there's no need to use the custom Koji RoundTripper,
|
||||
// let's just use the one that the called passed in.
|
||||
loginClient, err := xmlrpc.NewClient(server, transport)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
args := []interface{}{user, password}
|
||||
var reply loginReply
|
||||
err = loginClient.Call("login", args, &reply)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return newKoji(server, transport, reply, logger)
|
||||
}
|
||||
|
||||
// NewFromGSSAPI creates a new Koji session authenticated using GSSAPI.
|
||||
// Principal and keytab used for the session is passed using credentials
|
||||
// parameter.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue