repo_name stringlengths 1 52 | repo_creator stringclasses 6
values | programming_language stringclasses 4
values | code stringlengths 0 9.68M | num_lines int64 1 234k |
|---|---|---|---|---|
eks-anywhere | aws | Go | package registry
import (
"github.com/docker/cli/cli/config"
"github.com/docker/cli/cli/config/configfile"
"github.com/docker/cli/cli/config/credentials"
"oras.land/oras-go/v2/registry/remote/auth"
)
// CredentialStore for registry credentials such as ~/.docker/config.json.
type CredentialStore struct {
director... | 54 |
eks-anywhere | aws | Go | package registry_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/aws/eks-anywhere/pkg/registry"
)
func TestCredentialStore_Init(t *testing.T) {
credentialStore := registry.NewCredentialStore()
credentialStore.SetDirectory("testdata")
err := credentialStore.Init()
assert.NoError(t, e... | 56 |
eks-anywhere | aws | Go | package registry
import (
"context"
"encoding/json"
"fmt"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
// PullBytes a resource from the registry.
func PullBytes(ctx context.Context, sc StorageClient, artifact Artifact) (data []byte, err error) {
srcStorage, err := sc.GetStorage(ctx, artifact)
i... | 37 |
eks-anywhere | aws | Go | package registry_test
import (
_ "embed"
"fmt"
"testing"
"github.com/golang/mock/gomock"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/stretchr/testify/assert"
"github.com/aws/eks-anywhere/pkg/registry"
"github.com/aws/eks-anywhere/pkg/registry/mocks"
)
//go:embed testdata/image-man... | 115 |
eks-anywhere | aws | Go | package registry
import (
"context"
"crypto/x509"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
orasregistry "oras.land/oras-go/v2/registry"
)
// StorageContext describes aspects of a registry.
type StorageContext struct {
host string
project string
credentialStore *CredentialS... | 42 |
eks-anywhere | aws | Go | // Code generated by MockGen. DO NOT EDIT.
// Source: oras.land/oras-go/v2/registry (interfaces: Repository)
// Package mocks is a generated GoMock package.
package mocks
import (
context "context"
io "io"
reflect "reflect"
gomock "github.com/golang/mock/gomock"
v1 "github.com/opencontainers/image-spec/specs-go... | 212 |
eks-anywhere | aws | Go | // Code generated by MockGen. DO NOT EDIT.
// Source: pkg/registry/storage.go
// Package mocks is a generated GoMock package.
package mocks
import (
context "context"
reflect "reflect"
registry "github.com/aws/eks-anywhere/pkg/registry"
gomock "github.com/golang/mock/gomock"
v1 "github.com/opencontainers/image-... | 169 |
eks-anywhere | aws | Go | package registrymirror
import (
"net"
urllib "net/url"
"path/filepath"
"regexp"
"strings"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/constants"
)
// RegistryMirror configures mirror mappings for artifact registries.
type RegistryMirror struct {
// BaseRegistry is the addr... | 103 |
eks-anywhere | aws | Go | package registrymirror_test
import (
"testing"
. "github.com/onsi/gomega"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/constants"
"github.com/aws/eks-anywhere/pkg/registrymirror"
)
func TestFromCluster(t *testing.T) {
tests := []struct {
name string
cluster *v1alpha1.... | 388 |
eks-anywhere | aws | Go | package containerd
import (
"net/url"
"path/filepath"
"strings"
)
// ToAPIEndpoint turns URL to a valid API endpoint used in
// a containerd config file for a local registry.
// Original input is returned in case of malformed inputs.
func ToAPIEndpoint(url string) string {
u, err := parseURL(url)
if err != nil {... | 40 |
eks-anywhere | aws | Go | package containerd_test
import (
"testing"
. "github.com/onsi/gomega"
"github.com/aws/eks-anywhere/pkg/constants"
"github.com/aws/eks-anywhere/pkg/registrymirror/containerd"
)
func TestToAPIEndpoint(t *testing.T) {
tests := []struct {
name string
URL string
want string
}{
{
name: "no namespace",
... | 76 |
eks-anywhere | aws | Go | package retrier
import (
"math"
"time"
"github.com/aws/eks-anywhere/pkg/logger"
)
type Retrier struct {
retryPolicy RetryPolicy
timeout time.Duration
backoffFactor *float32
}
type (
// RetryPolicy allows to customize the retrying logic. The boolean retry indicates if a new retry
// should be perform... | 133 |
eks-anywhere | aws | Go | package retrier_test
import (
"errors"
"testing"
"time"
"github.com/aws/eks-anywhere/pkg/retrier"
)
func TestNewWithMaxRetriesExhausted(t *testing.T) {
wantRetries := 10
r := retrier.NewWithMaxRetries(wantRetries, 0)
gotRetries := 0
fn := func() error {
gotRetries += 1
return errors.New("")
}
err := ... | 200 |
eks-anywhere | aws | Go | package semver
import (
"fmt"
"regexp"
"strconv"
)
const semverRegex = `^v?(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`
v... | 104 |
eks-anywhere | aws | Go | package semver_test
import (
"testing"
"github.com/aws/eks-anywhere/pkg/semver"
)
func TestNewError(t *testing.T) {
testCases := []struct {
testName string
version string
}{
{
testName: "empty",
version: "",
},
{
testName: "only letters",
version: "xxx",
},
{
testName: "only mayor... | 201 |
eks-anywhere | aws | Go | package tar
import (
"compress/gzip"
"fmt"
"os"
)
func GzipTarFolder(sourceFolder, dstFile string) error {
tarfile, err := os.Create(dstFile)
if err != nil {
return fmt.Errorf("creating dst tar file: %v", err)
}
defer tarfile.Close()
gw := gzip.NewWriter(tarfile)
defer gw.Close()
if err := tarFolderToWri... | 40 |
eks-anywhere | aws | Go | package tar
type GzipPackager struct{}
func NewGzipPackager() GzipPackager {
return GzipPackager{}
}
func (GzipPackager) Package(sourceFolder, dstFile string) error {
return GzipTarFolder(sourceFolder, dstFile)
}
func (GzipPackager) UnPackage(orgFile, dstFolder string) error {
return UnGzipTarFile(orgFile, dstFo... | 16 |
eks-anywhere | aws | Go | package tar_test
import (
"os"
"path/filepath"
"testing"
. "github.com/onsi/gomega"
"github.com/aws/eks-anywhere/pkg/tar"
)
func TestUnGzipTarFile(t *testing.T) {
g := NewWithT(t)
dstFile := "dst.tar.gz"
untarFolder := "dst-untar"
g.Expect(os.MkdirAll(untarFolder, os.ModePerm))
t.Cleanup(func() {
os.Rem... | 33 |
eks-anywhere | aws | Go | package tar
type Packager struct{}
func NewPackager() Packager {
return Packager{}
}
func (Packager) Package(sourceFolder, dstFile string) error {
return TarFolder(sourceFolder, dstFile)
}
func (Packager) UnPackage(orgFile, dstFolder string) error {
return UntarFile(orgFile, dstFolder)
}
| 16 |
eks-anywhere | aws | Go | package tar
import (
"archive/tar"
"path/filepath"
)
// Router instructs where to extract a file.
type Router interface {
// ExtractPath instructs the path where a file should be extracted.
// Empty strings instructs to omit the file extraction
ExtractPath(header *tar.Header) string
}
type FolderRouter struct {... | 26 |
eks-anywhere | aws | Go | package tar
import (
"archive/tar"
"fmt"
"io"
"os"
)
func TarFolder(sourceFolder, dstFile string) error {
tarfile, err := os.Create(dstFile)
if err != nil {
return fmt.Errorf("creating dst tar file: %v", err)
}
defer tarfile.Close()
if err := tarFolderToWriter(sourceFolder, tarfile); err != nil {
return... | 69 |
eks-anywhere | aws | Go | package tar_test
import (
"os"
"testing"
. "github.com/onsi/gomega"
"github.com/aws/eks-anywhere/pkg/tar"
)
func TestTarFolder(t *testing.T) {
dstFile := "dst.tar"
t.Cleanup(func() {
os.Remove(dstFile)
})
g := NewWithT(t)
g.Expect(tar.TarFolder("testdata", dstFile)).To(Succeed())
g.Expect(dstFile).To(B... | 22 |
eks-anywhere | aws | Go | package tar
import (
"archive/tar"
"io"
"os"
)
func UntarFile(tarFile, dstFolder string) error {
reader, err := os.Open(tarFile)
if err != nil {
return err
}
defer reader.Close()
return Untar(reader, NewFolderRouter(dstFolder))
}
func Untar(source io.Reader, router Router) error {
tarReader := tar.NewRea... | 56 |
eks-anywhere | aws | Go | package tar_test
import (
"os"
"path/filepath"
"testing"
. "github.com/onsi/gomega"
"github.com/aws/eks-anywhere/pkg/tar"
)
func TestUntarFile(t *testing.T) {
g := NewWithT(t)
dstFile := "dst.tar"
untarFolder := "dst-untar"
g.Expect(os.MkdirAll(untarFolder, os.ModePerm))
t.Cleanup(func() {
os.Remove(dst... | 33 |
eks-anywhere | aws | Go | package tar
import (
"archive/tar"
"fmt"
"os"
"path/filepath"
"strings"
)
func NewFolderWalker(folder string) FolderWalker {
return FolderWalker{
folder: folder,
folderPrefix: fmt.Sprintf("%s/", folder),
}
}
type FolderWalker struct {
folder, folderPrefix string
}
func (f FolderWalker) Walk(fn Tar... | 45 |
eks-anywhere | aws | Go | package task
import (
"context"
"fmt"
"os"
"path/filepath"
"time"
"sigs.k8s.io/yaml"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/filewriter"
"github.com/aws/eks-anywhere/pkg/logger"
"github.com/aws/eks-anywhere/pkg/providers"
"github.com/aws/eks-anywhere/pkg/types"
"github.... | 269 |
eks-anywhere | aws | Go | package task_test
import (
"context"
"fmt"
"os"
"testing"
"github.com/golang/mock/gomock"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/features"
writermocks "github.com/aws/eks-anywhere/pkg/filewriter/mocks"
"github.com/aws/eks-an... | 218 |
eks-anywhere | aws | Go | // Code generated by MockGen. DO NOT EDIT.
// Source: github.com/aws/eks-anywhere/pkg/task (interfaces: Task)
// Package mocks is a generated GoMock package.
package mocks
import (
context "context"
reflect "reflect"
task "github.com/aws/eks-anywhere/pkg/task"
gomock "github.com/golang/mock/gomock"
)
// MockTas... | 94 |
eks-anywhere | aws | Go | package templater
import (
"reflect"
"strings"
"sigs.k8s.io/yaml"
)
type PartialYaml map[string]interface{}
func (p PartialYaml) AddIfNotZero(k string, v interface{}) {
if !isZeroVal(v) {
p[k] = v
}
}
func isZeroVal(x interface{}) bool {
return x == nil || reflect.DeepEqual(x, reflect.Zero(reflect.TypeOf(x... | 32 |
eks-anywhere | aws | Go | package templater_test
import (
"reflect"
"testing"
"github.com/aws/eks-anywhere/internal/test"
"github.com/aws/eks-anywhere/pkg/templater"
)
func TestPartialYamlAddIfNotZero(t *testing.T) {
tests := []struct {
testName string
p templater.PartialYaml
k string
v interface{}
wan... | 132 |
eks-anywhere | aws | Go | package templater
import (
"bytes"
"fmt"
"strings"
"text/template"
"github.com/aws/eks-anywhere/pkg/filewriter"
)
type Templater struct {
writer filewriter.FileWriter
}
func New(writer filewriter.FileWriter) *Templater {
return &Templater{
writer: writer,
}
}
func (t *Templater) WriteToFile(templateConte... | 67 |
eks-anywhere | aws | Go | package templater_test
import (
"os"
"strings"
"testing"
"github.com/aws/eks-anywhere/internal/test"
"github.com/aws/eks-anywhere/pkg/filewriter"
"github.com/aws/eks-anywhere/pkg/templater"
)
func TestTemplaterWriteToFileSuccess(t *testing.T) {
type dataStruct struct {
Key1, Key2, Key3, KeyAndValue3 string
... | 144 |
eks-anywhere | aws | Go | package templater
import (
"fmt"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/yaml"
)
const objectSeparator string = "\n---\n"
func AppendYamlResources(resources ...[]byte) []byte {
separator := []byte(objectSeparator)
size := 0
for _, resource := range resources {
size += len(resource) + len(separator)
... | 40 |
eks-anywhere | aws | Go | package types
import "context"
type Closer interface {
Close(ctx context.Context) error
}
| 8 |
eks-anywhere | aws | Go | package types
import "github.com/aws/eks-anywhere/release/api/v1alpha1"
type Cluster struct {
Name string
KubeconfigFile string
ExistingManagement bool // true is the cluster has EKS Anywhere management components
}
type InfrastructureBundle struct {
FolderName string
Manifests []v1alpha1.Man... | 15 |
eks-anywhere | aws | Go | package types
// EKSACliContextKey is defined to avoid conflict with other packages.
type EKSACliContextKey string
// InsecureRegistry can be used to bypass https registry certification check when push/pull images or artifacts.
var InsecureRegistry = EKSACliContextKey("insecure-registry")
| 8 |
eks-anywhere | aws | Go | package types
type DockerCredentials struct {
Username string
Password string
}
| 7 |
eks-anywhere | aws | Go | package types
type Lookup map[string]struct{}
func (l Lookup) IsPresent(v string) bool {
_, present := l[v]
return present
}
func (l Lookup) ToSlice() []string {
keys := make([]string, 0, len(l))
for k := range l {
keys = append(keys, k)
}
return keys
}
func SliceToLookup(slice []string) Lookup {
l := make... | 26 |
eks-anywhere | aws | Go | package types_test
import (
"testing"
. "github.com/onsi/gomega"
"github.com/aws/eks-anywhere/pkg/types"
)
func TestLookupIsPresent(t *testing.T) {
tests := []struct {
testName string
value string
slice []string
wantPresent bool
}{
{
testName: "empty slice",
slice: []str... | 77 |
eks-anywhere | aws | Go | package types
import "time"
type Deployment struct {
Namespace string
Name string
Container string
}
type Machine struct {
Metadata MachineMetadata `json:"metadata"`
Status MachineStatus `json:"status"`
}
func (m *Machine) HasAnyLabel(labels []string) bool {
for _, label := range labels {
if _, ok ... | 94 |
eks-anywhere | aws | Go | package types_test
import (
"testing"
"github.com/aws/eks-anywhere/pkg/types"
)
func TestHasAnyLabel(t *testing.T) {
tests := []struct {
testName string
labels map[string]string
wantLabels []string
hasAnyLabel bool
}{
{
testName: "empty labels",
labels: map[string]string{},
wa... | 82 |
eks-anywhere | aws | Go | package types
type ChangeDiff struct {
ComponentReports []ComponentChangeDiff `json:"components"`
}
type ComponentChangeDiff struct {
ComponentName string `json:"name"`
OldVersion string `json:"oldVersion"`
NewVersion string `json:"newVersion"`
}
func NewChangeDiff(componentReports ...*ComponentChangeDiff)... | 37 |
eks-anywhere | aws | Go | package types_test
import (
"testing"
"github.com/aws/eks-anywhere/pkg/types"
)
func TestAppend(t *testing.T) {
tests := []struct {
testName string
changeDiffs *types.ChangeDiff
componentReports []types.ComponentChangeDiff
}{
{
testName: "empty changeDiff",
componentReports: []types.Co... | 59 |
eks-anywhere | aws | Go | package oci
import (
"fmt"
"path/filepath"
"strings"
)
const OCIPrefix = "oci://"
func Split(artifact string) (path, tag string) {
lastInd := strings.LastIndex(artifact, ":")
if lastInd == -1 {
return artifact, ""
}
if lastInd == len(artifact)-1 {
return artifact[:lastInd], ""
}
return artifact[:lastI... | 38 |
eks-anywhere | aws | Go | package oci_test
import (
"testing"
. "github.com/onsi/gomega"
"github.com/aws/eks-anywhere/pkg/utils/oci"
)
func TestURL(t *testing.T) {
tests := []struct {
name string
artifactPath string
want string
}{
{
name: "normal artifact",
artifactPath: "public.ecr.aws/folder/fold... | 108 |
eks-anywhere | aws | Go | /*
Package ptr provides utility functions for converting non-addressable primitive types to pointers.
Its useful in contexts where a variable gives nil primitive type pointers semantics
(often meaning "not set") which can make it annoying to set the value.
Example
type Foo struct {
A *int
}
func main() {
foo ... | 91 |
eks-anywhere | aws | Go | package unstructured
import (
"fmt"
"reflect"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"sigs.k8s.io/cluster-api/util/yaml"
)
func YamlToUnstructured(yamlObjects []byte) ([]unstructured.Unstructured, error) {
// Using this CAPI util for now, not sure if we want to depend on it but it's well written
r... | 46 |
eks-anywhere | aws | Go | package unstructured_test
import (
"bytes"
"testing"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
unstructuredutil "github.com/aws/eks-anywhere/pkg/utils/unstructured"
)
func TestYamlToClientObjects(t *testing.T) {
tests := []struct {
name string
yaml []byte
want map[st... | 316 |
eks-anywhere | aws | Go | package urls
import (
"net/url"
"strings"
)
// ReplaceHost replaces the host in a url
// It supports full URLs and container image URLs
// If the provided original url is malformed, the are no guarantees
// that the returned value will be valid
// If host is empty, it will return the original URL.
func ReplaceHost(... | 26 |
eks-anywhere | aws | Go | package urls_test
import (
"testing"
. "github.com/onsi/gomega"
"github.com/aws/eks-anywhere/pkg/utils/urls"
)
func TestReplaceHost(t *testing.T) {
tests := []struct {
name string
orgURL string
host string
want string
}{
{
name: "oci url",
orgURL: "oci://public.ecr.aws/product/chart",
... | 49 |
eks-anywhere | aws | Go | package yaml
import (
"bytes"
"fmt"
"sigs.k8s.io/yaml"
)
// Join joins YAML resources into a single YAML document. It does not validate individual
// resources.
func Join(resources [][]byte) []byte {
return bytes.Join(resources, []byte("\n---\n"))
}
// Serialize serializes objects into YAML documents.
func Seri... | 28 |
eks-anywhere | aws | Go | /*
Package validation implements tools to validate data objects.
These might be used from the CLI and/or the controller.
This package shoul not, under any circumtance, include specific validation logic.
Only the tools to operate that logic should live here.
*/
package validation
| 10 |
eks-anywhere | aws | Go | package validation
import "errors"
// Remediable is an error that provides a possible remediation.
type Remediable interface {
Remediation() string
}
// remediableError implements Fixable around a generic error.
type remediableError struct {
error
remediation string
}
// Remediation returns a possible solution t... | 53 |
eks-anywhere | aws | Go | package validation_test
import (
"errors"
"testing"
. "github.com/onsi/gomega"
"github.com/aws/eks-anywhere/pkg/validation"
)
func TestErrorRemediationWithRemediation(t *testing.T) {
g := NewWithT(t)
err := errors.New("my error")
remediable := validation.WithRemediation(err, "this is how you fix it")
g.Exp... | 70 |
eks-anywhere | aws | Go | package validation_test
import (
"context"
"errors"
"fmt"
"github.com/go-logr/logr"
"github.com/aws/eks-anywhere/internal/test"
anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/cli"
"github.com/aws/eks-anywhere/pkg/cluster"
eksaerrors "github.com/aws/eks-anywhere/pk... | 94 |
eks-anywhere | aws | Go | package validation
import (
"context"
"reflect"
"runtime"
"sync"
"github.com/aws/eks-anywhere/pkg/errors"
)
// Validatable is anything that can be validated.
type Validatable[O any] interface {
DeepCopy() O
}
// Validation is the logic for a validation of a type O.
type Validation[O Validatable[O]] func(ctx c... | 139 |
eks-anywhere | aws | Go | package validation_test
import (
"context"
"errors"
"testing"
. "github.com/onsi/gomega"
eksaerrors "github.com/aws/eks-anywhere/pkg/errors"
"github.com/aws/eks-anywhere/pkg/validation"
)
func TestRunnerRunAllSuccess(t *testing.T) {
g := NewWithT(t)
ctx := context.Background()
r := validation.NewRunner[*ap... | 137 |
eks-anywhere | aws | Go | package validations
import (
"context"
"errors"
"fmt"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/config"
"github.com/aws/eks-anywhere/pkg/logger"
"github.com/aws/eks-anywhere/pkg/providers"
"github.com/aws/eks-anywhere/pkg/types"
... | 117 |
eks-anywhere | aws | Go | package validations_test
import (
"context"
"errors"
"os"
"testing"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/aws/eks-anywhere/internal/test"
anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/clu... | 417 |
eks-anywhere | aws | Go | package validations
import (
"context"
"fmt"
"github.com/aws/eks-anywhere/pkg/logger"
)
const (
recommendedTotalMemory = 6200000000
requiredMajorVersion = 20
)
type DockerExecutable interface {
Version(ctx context.Context) (int, error)
AllocatedMemory(ctx context.Context) (uint64, error)
}
func CheckMinim... | 52 |
eks-anywhere | aws | Go | package validations_test
import (
"context"
"fmt"
"testing"
"github.com/golang/mock/gomock"
"github.com/aws/eks-anywhere/pkg/validations"
"github.com/aws/eks-anywhere/pkg/validations/mocks"
)
const (
requiredMajorVersion = 20
)
func TestValidateDockerVersion(t *testing.T) {
ctx := context.Background()
te... | 90 |
eks-anywhere | aws | Go | package validations
import (
"fmt"
"strings"
)
type ValidationError struct {
Errs []string
}
func (v *ValidationError) Error() string {
return fmt.Sprintf("validation failed with %d errors: %s", len(v.Errs), strings.Join(v.Errs[:], ","))
}
func (v *ValidationError) String() string {
return v.Error()
}
| 19 |
eks-anywhere | aws | Go | package validations
import (
"errors"
"fmt"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/config"
)
func ValidateAuthenticationForGitProvider(clusterSpec *cluster.Spec, cliConfig *config.CliConfig) error {
if clusterSpec.FluxConfig == nil || clusterSpec.FluxConfig.Spec.Git == nil {
... | 38 |
eks-anywhere | aws | Go | package validations_test
import (
"fmt"
"reflect"
"testing"
"github.com/aws/eks-anywhere/internal/test"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/config"
"github.com/aws/eks-anywhere/pkg/validations"
)
const (
emptyVar = ""
t... | 166 |
eks-anywhere | aws | Go | package validations
import (
"errors"
"os"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
)
func ValidateClusterNameArg(args []string) (string, error) {
if len(args) == 0 {
return "", errors.New("please specify a cluster name")
}
err := v1alpha1.ValidateClusterName(args[0])
if err != nil {
return args[0],... | 34 |
eks-anywhere | aws | Go | package validations_test
import (
"errors"
"path/filepath"
"reflect"
"testing"
"github.com/aws/eks-anywhere/pkg/validations"
)
func TestOldClusterConfigExists(t *testing.T) {
tests := map[string]struct {
Filename string
Expect bool
}{
"Non existence should return false": {
Filename: "nonexistence",... | 114 |
eks-anywhere | aws | Go | package validations
import (
"context"
"testing"
"github.com/golang/mock/gomock"
"k8s.io/apimachinery/pkg/runtime"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/clients/kubernetes"
"github.com/aws/eks-anywhere/pkg/executables"
mockexecutables "github.com/aws/eks-anywhere/pkg... | 52 |
eks-anywhere | aws | Go | package validations
// ProcessValidationResults is currently used for unit test processing.
func ProcessValidationResults(validations []Validation) error {
var errs []string
results := make([]ValidationResult, 0, len(validations))
for _, validation := range validations {
results = append(results, *validation())
... | 23 |
eks-anywhere | aws | Go | package validations
import "errors"
var errRunnerValidation = errors.New("validations failed")
type Validation func() *ValidationResult
type Runner struct {
validations []Validation
}
func NewRunner() *Runner {
return &Runner{validations: make([]Validation, 0)}
}
func (r *Runner) Register(validations ...Validat... | 37 |
eks-anywhere | aws | Go | package validations_test
import (
"errors"
"testing"
. "github.com/onsi/gomega"
"github.com/aws/eks-anywhere/pkg/validations"
)
func TestRunnerRunError(t *testing.T) {
g := NewWithT(t)
r := validations.NewRunner()
r.Register(func() *validations.ValidationResult {
return &validations.ValidationResult{
Er... | 47 |
eks-anywhere | aws | Go | package validations
type TlsValidator interface {
ValidateCert(host, port, caCertContent string) error
IsSignedByUnknownAuthority(host, port string) (bool, error)
}
| 7 |
eks-anywhere | aws | Go | package validations
import (
"unicode"
"github.com/aws/eks-anywhere/pkg/logger"
)
type ValidationResult struct {
Name string
Err error
Remediation string
Silent bool
}
func (v *ValidationResult) Report() {
if v.Err != nil {
logger.MarkFail("Validation failed", "validation", v.Name, "err... | 39 |
eks-anywhere | aws | Go | package validations
import (
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/config"
"github.com/aws/eks-anywhere/pkg/crypto"
"github.com/aws/eks-anywhere/pkg/providers"
"github.com/aws/eks-anywhere/pkg/types"
)
type Opts struct {
Kubectl KubectlClient
Spec *... | 27 |
eks-anywhere | aws | Go | package createcluster
import (
"context"
"fmt"
"runtime"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/gitops/flux"
"github.com/aws/eks-anywhere/pkg/kubeconfig"
"github.com/aws/eks-anywhere/pkg/providers"
"github.com/aws/eks-anywhere/pkg/validations"
)
type ValidationManager stru... | 81 |
eks-anywhere | aws | Go | package createcluster_test
import (
"context"
"testing"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/aws/eks-anywhere/internal/test"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aw... | 143 |
eks-anywhere | aws | Go | // Code generated by MockGen. DO NOT EDIT.
// Source: pkg/validations/createcluster/createcluster.go
// Package mocks is a generated GoMock package.
package mocks
import (
context "context"
reflect "reflect"
validations "github.com/aws/eks-anywhere/pkg/validations"
gomock "github.com/golang/mock/gomock"
)
// Mo... | 51 |
eks-anywhere | aws | Go | package createvalidations
import (
"context"
"fmt"
"github.com/aws/eks-anywhere/pkg/types"
"github.com/aws/eks-anywhere/pkg/validations"
)
func ValidateClusterNameIsUnique(ctx context.Context, k validations.KubectlClient, cluster *types.Cluster, clusterName string) error {
c, err := k.GetClusters(ctx, cluster)
... | 30 |
eks-anywhere | aws | Go | package createvalidations_test
import (
"bytes"
"errors"
"fmt"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"github.com/aws/eks-anywhere/internal/test"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/clients/kuberne... | 124 |
eks-anywhere | aws | Go | package createvalidations
import (
"github.com/aws/eks-anywhere/pkg/validations"
)
func New(opts *validations.Opts) *CreateValidations {
opts.SetDefaults()
return &CreateValidations{Opts: opts}
}
type CreateValidations struct {
Opts *validations.Opts
}
| 15 |
eks-anywhere | aws | Go | package createvalidations
import (
"context"
"errors"
"fmt"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/types"
"github.com/aws/eks-anywhere/pkg/validations"
)
var (
clusterResourceTy... | 102 |
eks-anywhere | aws | Go | package createvalidations_test
import (
"context"
"errors"
"testing"
. "github.com/onsi/gomega"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/validations/createvalidations"
)
func TestVa... | 191 |
eks-anywhere | aws | Go | package createvalidations
import (
"context"
"fmt"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/logger"
"github.com/aws/eks-anywhere/pkg/types"
"github.com/aws/eks-anywhere/pkg/validations"
)
func ValidateIdentityProviderNameIsUnique(ctx context.Context, k validations.KubectlClien... | 35 |
eks-anywhere | aws | Go | package createvalidations_test
import (
"bytes"
"errors"
"fmt"
"reflect"
"testing"
"github.com/aws/eks-anywhere/internal/test"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/clients/kubernetes"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/valida... | 146 |
eks-anywhere | aws | Go | package createvalidations
import (
"context"
"fmt"
anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/config"
"github.com/aws/eks-anywhere/pkg/types"
"github.com/aws/eks-anywhere/pkg/validations"
)
// PreflightValidations returns the validations required before creating ... | 97 |
eks-anywhere | aws | Go | package createvalidations_test
import (
"context"
"testing"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/aws/eks-anywhere/internal/test"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"... | 97 |
eks-anywhere | aws | Go | // Code generated by MockGen. DO NOT EDIT.
// Source: github.com/aws/eks-anywhere/pkg/validations (interfaces: DockerExecutable)
// Package mocks is a generated GoMock package.
package mocks
import (
context "context"
reflect "reflect"
gomock "github.com/golang/mock/gomock"
)
// MockDockerExecutable is a mock of... | 66 |
eks-anywhere | aws | Go | // Code generated by MockGen. DO NOT EDIT.
// Source: pkg/validations/kubectl.go
// Package mocks is a generated GoMock package.
package mocks
import (
context "context"
reflect "reflect"
v1alpha1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
kubernetes "github.com/aws/eks-anywhere/pkg/clients/kubernetes"
exec... | 320 |
eks-anywhere | aws | Go | // Code generated by MockGen. DO NOT EDIT.
// Source: pkg/validations/tls.go
// Package mocks is a generated GoMock package.
package mocks
import (
reflect "reflect"
gomock "github.com/golang/mock/gomock"
)
// MockTlsValidator is a mock of TlsValidator interface.
type MockTlsValidator struct {
ctrl *gomock.C... | 64 |
eks-anywhere | aws | Go | package upgradevalidations
import (
"context"
"fmt"
"github.com/aws/eks-anywhere/pkg/types"
"github.com/aws/eks-anywhere/pkg/validations"
)
func ValidateClusterObjectExists(ctx context.Context, k validations.KubectlClient, cluster *types.Cluster) error {
c, err := k.GetClusters(ctx, cluster)
if err != nil {
... | 26 |
eks-anywhere | aws | Go | package upgradevalidations_test
import (
"bytes"
"errors"
"fmt"
"reflect"
"testing"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"github.com/aws/eks-anywhere/internal/test"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/clients/kubernetes"
"github.com/aws/eks-anywhere/pk... | 69 |
eks-anywhere | aws | Go | package upgradevalidations
import (
"context"
"fmt"
"github.com/aws/eks-anywhere/pkg/constants"
"github.com/aws/eks-anywhere/pkg/executables"
"github.com/aws/eks-anywhere/pkg/types"
)
const (
eksaControllerDeploymentName = "eksa-controller-manager"
)
func ValidateEksaSystemComponents(ctx context.Context, k *e... | 36 |
eks-anywhere | aws | Go | package upgradevalidations_test
import (
"bytes"
"errors"
"reflect"
"testing"
"github.com/aws/eks-anywhere/internal/test"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/constants"
"github.com/aws/eks-anywhere/pkg/validations"
"github.com/aws/eks-anywhere/pkg/validations/upgra... | 58 |
eks-anywhere | aws | Go | package upgradevalidations
import (
"context"
"errors"
"fmt"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/providers"
"github.com/aws/eks-anywhere/pkg/types"
"github.com/aws/eks-anywhere/pkg/validations"
)
func ValidateImmutableField... | 195 |
eks-anywhere | aws | Go | package upgradevalidations_test
import (
"context"
"errors"
"testing"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"github.com/aws/eks-anywhere/internal/test"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/cluster"
pmock "github.com/aws/eks-anywhere/pkg/provide... | 363 |
eks-anywhere | aws | Go | package upgradevalidations
import (
"context"
"fmt"
"github.com/pkg/errors"
policy "k8s.io/api/policy/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"github.com/aws/eks-anywhere/pkg/types"
"github.com/aws/eks-anywhere/pkg/validations"
)
// ValidatePodDisruptionBudgets returns an error if any pdbs are det... | 30 |
eks-anywhere | aws | Go | package upgradevalidations_test
import (
"context"
"errors"
"fmt"
"reflect"
"strings"
"testing"
"github.com/golang/mock/gomock"
policy "k8s.io/api/policy/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"github.com/aws/eks-anywhere/pkg/clients/kubernetes"
"github.com/aws/eks-anywhere/pkg/types"
"github.com/aws/... | 104 |
eks-anywhere | aws | Go | package upgradevalidations
import (
"context"
"fmt"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/config"
"github.com/aws/eks-anywhere/pkg/types"
"github.com/aws/eks-anywhere/pkg/validations"
)
// PreflightValidation... | 121 |
eks-anywhere | aws | Go | package upgradevalidations_test
import (
"context"
"errors"
"fmt"
"reflect"
"testing"
"github.com/golang/mock/gomock"
"github.com/aws/eks-anywhere/internal/test"
anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/config"
"gi... | 1,392 |
eks-anywhere | aws | Go | package upgradevalidations
import (
"fmt"
"strings"
)
// string values of supported validation names that can be skipped.
const (
PDB = "pod-disruption"
)
// SkippableValidations represents all the validations we offer for users to skip.
var SkippableValidations = []string{
PDB,
}
// ValidSkippableValidationsMa... | 44 |
eks-anywhere | aws | Go | package upgradevalidations_test
import (
"fmt"
"reflect"
"strings"
"testing"
"github.com/aws/eks-anywhere/pkg/validations/upgradevalidations"
)
func TestValidateSkippableUpgradeValidation(t *testing.T) {
tests := []struct {
name string
want map[string]bool
wantErr e... | 47 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.