gofmt
This commit is contained in:
parent
f2e3de4b5d
commit
40fd4646ce
9 changed files with 187 additions and 189 deletions
|
@ -2,8 +2,8 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"git.deuxfleurs.fr/deuxfleurs/albatros/cmd"
|
"git.deuxfleurs.fr/deuxfleurs/albatros/cmd"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
|
||||||
"errors"
|
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/sha256"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -13,17 +13,17 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/containers/image/v5/transports/alltransports"
|
|
||||||
"github.com/containers/image/v5/signature"
|
|
||||||
"github.com/containers/image/v5/copy"
|
"github.com/containers/image/v5/copy"
|
||||||
|
"github.com/containers/image/v5/signature"
|
||||||
|
"github.com/containers/image/v5/transports/alltransports"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"gocloud.dev/blob"
|
"gocloud.dev/blob"
|
||||||
_ "gocloud.dev/blob/s3blob"
|
_ "gocloud.dev/blob/s3blob"
|
||||||
)
|
)
|
||||||
|
|
||||||
var pctx *signature.PolicyContext
|
var pctx *signature.PolicyContext
|
||||||
const distributionPrefix = "v2"
|
|
||||||
|
|
||||||
|
const distributionPrefix = "v2"
|
||||||
|
|
||||||
//---
|
//---
|
||||||
//--- Image converter
|
//--- Image converter
|
||||||
|
@ -33,6 +33,7 @@ type OCIImageManifest struct {
|
||||||
Config OCIRef `json:"config"`
|
Config OCIRef `json:"config"`
|
||||||
Layers []OCIRef `json:layers"`
|
Layers []OCIRef `json:layers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadOCIImageManifest(path string) (*OCIImageManifest, error) {
|
func LoadOCIImageManifest(path string) (*OCIImageManifest, error) {
|
||||||
fd, err := os.Open(path)
|
fd, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -71,6 +72,7 @@ type OCIImageIndex struct {
|
||||||
MediaType string `json:"mediaType"`
|
MediaType string `json:"mediaType"`
|
||||||
Manifests []OCIRef `json:"manifests"`
|
Manifests []OCIRef `json:"manifests"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOCIImageIndex(o *OCIMultiArch) (OCIImageIndex, error) {
|
func NewOCIImageIndex(o *OCIMultiArch) (OCIImageIndex, error) {
|
||||||
idx := OCIImageIndex{
|
idx := OCIImageIndex{
|
||||||
SchemaVersion: 2,
|
SchemaVersion: 2,
|
||||||
|
@ -130,6 +132,7 @@ func (i OCIImageIndex) WriteTo(root string) error {
|
||||||
type OCILayout struct {
|
type OCILayout struct {
|
||||||
ImageLayoutVersion string `json:"imageLayoutVersion"`
|
ImageLayoutVersion string `json:"imageLayoutVersion"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOCILayout() OCILayout {
|
func NewOCILayout() OCILayout {
|
||||||
return OCILayout{"1.0.0"}
|
return OCILayout{"1.0.0"}
|
||||||
}
|
}
|
||||||
|
@ -151,6 +154,7 @@ type OCISystemImage struct {
|
||||||
arch string
|
arch string
|
||||||
index *OCIImageIndex
|
index *OCIImageIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOCISystemImage(path, os, arch string) (OCISystemImage, error) {
|
func NewOCISystemImage(path, os, arch string) (OCISystemImage, error) {
|
||||||
si := OCISystemImage{
|
si := OCISystemImage{
|
||||||
path: path,
|
path: path,
|
||||||
|
@ -252,7 +256,6 @@ func (o *OCIMultiArch) LoadFromDockerArchives(path string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Convert the docker archive to an oci image
|
// Convert the docker archive to an oci image
|
||||||
_, err = copy.Image(context.Background(), pctx, dstRef, srcRef, ©.Options{})
|
_, err = copy.Image(context.Background(), pctx, dstRef, srcRef, ©.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -288,7 +291,6 @@ func (o *OCIMultiArch) MergeSystemImages() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create the oci-layout file
|
// Create the oci-layout file
|
||||||
err = NewOCILayout().WriteTo(multiArchRoot)
|
err = NewOCILayout().WriteTo(multiArchRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -308,7 +310,6 @@ func (o *OCIMultiArch) MergeSystemImages() error {
|
||||||
o.multi = &idx
|
o.multi = &idx
|
||||||
fmt.Printf("-> index.json\n")
|
fmt.Printf("-> index.json\n")
|
||||||
|
|
||||||
|
|
||||||
// Copy blobs
|
// Copy blobs
|
||||||
for _, img := range o.images {
|
for _, img := range o.images {
|
||||||
blobCounter := 0
|
blobCounter := 0
|
||||||
|
@ -462,7 +463,6 @@ func (o *OCIMultiArch) UploadImageS3(buck *blob.Bucket) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type StaticRegistryManager struct {
|
type StaticRegistryManager struct {
|
||||||
name string
|
name string
|
||||||
buck *blob.Bucket
|
buck *blob.Bucket
|
||||||
|
|
|
@ -44,7 +44,6 @@ type Manifest struct {
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---
|
//---
|
||||||
//--- Collect data on the filesystem
|
//--- Collect data on the filesystem
|
||||||
type Platform struct {
|
type Platform struct {
|
||||||
|
@ -83,7 +82,6 @@ func CollectPlatforms(path string) ([]Platform, error) {
|
||||||
filenames = append(filenames, f.Name())
|
filenames = append(filenames, f.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
plat := Platform{
|
plat := Platform{
|
||||||
OS: osDir.Name(),
|
OS: osDir.Name(),
|
||||||
Arch: archDir.Name(),
|
Arch: archDir.Name(),
|
||||||
|
@ -212,6 +210,7 @@ type BucketUploader struct {
|
||||||
reader io.ReadCloser
|
reader io.ReadCloser
|
||||||
options *blob.WriterOptions
|
options *blob.WriterOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUploadFromFS(buck *blob.Bucket, path string) (*BucketUploader, error) {
|
func NewUploadFromFS(buck *blob.Bucket, path string) (*BucketUploader, error) {
|
||||||
fd, err := os.Open(path)
|
fd, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package pkg
|
package pkg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
consul "github.com/hashicorp/consul/api"
|
consul "github.com/hashicorp/consul/api"
|
||||||
nomad "github.com/hashicorp/nomad/api"
|
nomad "github.com/hashicorp/nomad/api"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type Cluster struct {
|
type Cluster struct {
|
||||||
Nomad *nomad.Client
|
Nomad *nomad.Client
|
||||||
Consul *consul.Client
|
Consul *consul.Client
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package pkg
|
package pkg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/caarlos0/env/v7"
|
"github.com/caarlos0/env/v7"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
|
|
@ -4,10 +4,10 @@ import (
|
||||||
b64 "encoding/base64"
|
b64 "encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"golang.org/x/exp/slices"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
nomad "github.com/hashicorp/nomad/api"
|
nomad "github.com/hashicorp/nomad/api"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package pkg
|
package pkg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"code.gitea.io/sdk/gitea"
|
"code.gitea.io/sdk/gitea"
|
||||||
nomad "github.com/hashicorp/nomad/api"
|
nomad "github.com/hashicorp/nomad/api"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Job struct {
|
type Job struct {
|
||||||
|
|
Loading…
Reference in a new issue