8000 add testing with envtest by tommyknows · Pull Request #3 · ninech/relokator · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add testing with envtest #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on: [push, pull_request]
jobs:
test:
name: Test
container: ninech/controller-test-image:latest
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
Expand Down
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ module github.com/ninech/relokator
go 1.14

require (
cloud.google.com/go v0.51.0 // indirect
github.com/google/go-cmp v0.4.0 // indirect
github.com/hashicorp/golang-lru v0.5.3 // indirect
github.com/imdario/mergo v0.3.7 // indirect
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
github.com/pkg/errors v0.9.1
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sys v0.0.0-20200107162124-548cf772de50 // indirect
k8s.io/api v0.18.3
k8s.io/apimachinery v0.18.3
k8s.io/client-go v0.18.3
sigs.k8s.io/controller-runtime v0.6.0
)
356 changes: 356 additions & 0 deletions go.sum

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,24 @@ func (c clusterState) allPVCs(ctx context.Context, client kubernetesClient, name
if err != nil {
return errors.Wrapf(err, "could not list PVs")
}
// TODO: figure out if a PVC is in Terminating state and ignore it?
for _, pvc := range p {
if pvc.Spec.StorageClassName == nil || *pvc.Spec.StorageClassName != globalSourceClass {
log.Debugf("%v/%v: storageClass of PVC is %q, not %q. not migrating", namespace, pvc.Name, *pvc.Spec.StorageClassName, globalSourceClass)
continue
}
// TODO: figure out if a PVC is in Terminating state and ignore it

if _, ok := pvc.Annotations[completedMigrationPhase]; ok {
if name, ok := pvc.Annotations[isRenamedPVC]; ok {
// overwrite the name to the original PVC
pvc.Name = name
}
}

if c[namespace] == nil {
c[namespace] = make(namespaceState)
}

c[namespace][pvc.Name], err = newState(ctx, client, namespace, pvc.Name)
if err != nil {
return errors.Wrapf(err, "could not create state")
Expand Down Expand Up @@ -297,10 +305,10 @@ func (m *Migrator) String() string {
return str.String()
}

const argoAnnotation = "nine.ch/argo-admin"

// toggleArgoAdmin enables or disables the admin access for argo in the specified namespace
func (m *Migrator) toggleArgoAdmin(ns *corev1.Namespace) error {
const argoAnnotation = "nine.ch/argo-admin"

val, ok := ns.Annotations[argoAnnotation]
if !ok {
return nil
Expand Down Expand Up @@ -425,7 +433,6 @@ func (m *Migrator) namespace(ns string, nsState namespaceState) error {
log.Infof("starting migration in namespace %v", ns)

// grab the namespace from the first state
// TODO: should we embed the namespace in the namespaceState?
var namespace *corev1.Namespace
for _, st := range nsState {
namespace = st.ns
Expand Down
Loading
0