Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
Signed-off-by: Yingrong Zhao <[email protected]>
  • Loading branch information
VinozzZ committed Sep 30, 2022
1 parent 85d9d50 commit 0b6a224
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 135 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
check-latest: true
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Set up Mage
run: go run mage.go EnsureMage
- name: Test
Expand Down
16 changes: 0 additions & 16 deletions agent-config.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion api/v1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const (

// VolumePorterSharedName is the name of the volume shared between the porter
// agent and the invocation image.
VolumePorterPluginsName = "plugins"
VolumePorterPluginsName = "porter-plugins"

// VolumePorterConfigPath is the mount path of the volume containing Porter's
// config file.
Expand Down
18 changes: 6 additions & 12 deletions api/v1/testdata/credential-set.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
apiVersion: porter.sh/v1
kind: CredentialSet
metadata:
name: hello-3
namespace: test
spec:
schemaVersion: 1.0.1
name: porter-test-me
namespace: test
credentials:
- name: kubeconfig
schemaVersion: 1.0.1
name: porter-test-me
namespace: dev
credentials:
- name: insecureValue
source:
secret: ~/.kube/config
secret: test-secret
23 changes: 12 additions & 11 deletions controllers/agentconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (r *AgentConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request)
if err != nil {
return ctrl.Result{}, err
}
if readyPVC != nil && tempPVC == nil {
if readyPVC != nil && tempPVC == nil && !isDeleted(agentCfg) {
if readyPVC.Status.Phase != corev1.ClaimBound || agentCfg.Status.Phase == porterv1.PhaseSucceeded {
return ctrl.Result{}, nil
}
Expand Down Expand Up @@ -501,16 +501,6 @@ func (r *AgentConfigReconciler) cleanup(ctx context.Context, log logr.Logger, ag
return err
}

// remove owner reference
if idx, exist := containOwner(newPVC.GetOwnerReferences(), agentCfg); exist {
newPVC.OwnerReferences = removeOwnerByIdx(newPVC.GetOwnerReferences(), idx)
err := r.Update(ctx, newPVC)
if err != nil {
return err
}
return nil
}

pv := &corev1.PersistentVolume{}
pvKey := client.ObjectKey{Namespace: newPVC.Namespace, Name: newPVC.Spec.VolumeName}
err = r.Get(ctx, pvKey, pv)
Expand All @@ -530,6 +520,16 @@ func (r *AgentConfigReconciler) cleanup(ctx context.Context, log logr.Logger, ag
return nil
}

// remove owner reference
if idx, exist := containOwner(newPVC.GetOwnerReferences(), agentCfg); exist {
newPVC.OwnerReferences = removeOwnerByIdx(newPVC.GetOwnerReferences(), idx)
err := r.Update(ctx, newPVC)
if err != nil {
return err
}
return nil
}

return nil

}
Expand Down Expand Up @@ -610,6 +610,7 @@ func (r *AgentConfigReconciler) DeleteTemporaryPVC(ctx context.Context, log logr
}

func (r *AgentConfigReconciler) isDeleteProcessed(ctx context.Context, agentCfg *porterv1.AgentConfig) (bool, error) {

if !isDeleted(agentCfg) {
return false, nil
}
Expand Down
14 changes: 0 additions & 14 deletions cred.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module get.porter.sh/operator

go 1.17
go 1.18

replace (
// a dependency of buildx (github.com/tonistiigi/fsutil) relies on an untagged version of Docker on the master branch
Expand Down
6 changes: 0 additions & 6 deletions kind-config.ymal

This file was deleted.

14 changes: 0 additions & 14 deletions llama.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions mage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//go:build ignore
// +build ignore

package main

import (
"os"

"github.com/magefile/mage/mage"
)

// This file allows someone to run mage commands without mage installed
// by running `go run mage.go TARGET`.
// See https://magefile.org/zeroinstall/
func main() { os.Exit(mage.Main()) }
19 changes: 0 additions & 19 deletions magefiles/kind.config

This file was deleted.

23 changes: 13 additions & 10 deletions magefile.go → magefiles/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
. "get.porter.sh/magefiles/docker"
"get.porter.sh/magefiles/porter"
"get.porter.sh/magefiles/releases"

//mage:import
. "get.porter.sh/magefiles/tests"
"get.porter.sh/magefiles/tools"
. "get.porter.sh/operator/mage"
Expand All @@ -45,7 +47,7 @@ const (
testNamespace = "test"

// Relative location of the KUBECONFIG for the test cluster
kubeconfig = "kind.config.yaml"
kubeconfig = "kind.config"

// Namespace of the porter operator
operatorNamespace = "porter-operator-system"
Expand All @@ -57,15 +59,18 @@ const (
porterVersion = "v1.0.0-rc.1"
)

var srcDirs = []string{"api", "config", "controllers", "installer", "installer-olm"}
var binDir = "bin"
var (
srcDirs = []string{"api", "config", "controllers", "installer", "installer-olm"}
binDir = "bin"
)

// Porter agent that has k8s plugin included
var porterAgentImgRepository = "ghcr.io/getporter/dev/porter-agent-kubernetes"
var porterAgentImgVersion = "v1.0.0-rc.1"
var (
porterAgentImgRepository = "ghcr.io/getporter/porter-agent"
porterAgentImgVersion = "v1.0.0-rc.3"
)

// Local porter agent image name to use for local testing
var localAgentImgName = "localhost:5000/porter-agent:test"
var localAgentImgName = "localhost:5000/porter-agent:canary-dev"

// Build a command that stops the build on if the command fails
var must = shx.CommandBuilder{StopOnError: true}
Expand Down Expand Up @@ -363,9 +368,7 @@ func Deploy() {
buildPorterCmd("credentials", "apply", "hack/creds.yaml", "-n=operator").Must().RunV()
}
bundleRef := Env.BundlePrefix + meta.Version
//buildPorterCmd("install", "operator", "-r", bundleRef, "-c=kind", "--force", "-n=operator").Must().RunV()

buildPorterCmd("install", "operator", "-r", bundleRef, "--param", "porterRepository=localhost:5000/porter-agent", "--param", "porterVersion=canary-v1", "-c=kind", "--force", "-n=operator").Must().RunV()
buildPorterCmd("install", "operator", "-r", bundleRef, "-c=kind", "--force", "-n=operator").Must().RunV()
}

func isDeployed() bool {
Expand Down
2 changes: 0 additions & 2 deletions notes.md

This file was deleted.

20 changes: 0 additions & 20 deletions porter-config.yaml

This file was deleted.

Empty file removed test
Empty file.
2 changes: 0 additions & 2 deletions test-output

This file was deleted.

1 change: 0 additions & 1 deletion test2

This file was deleted.

2 changes: 1 addition & 1 deletion tests/integration/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func createTestNamespace(ctx context.Context) string {
PorterVersion: agentVersion,
ServiceAccount: svc.Name,
InstallationServiceAccount: "installation-agent",
Plugins: porterv1.PluginList{porterv1.Plugin{Name: "kubernetes", FeedURL: "https://cdn.porter.sh/plugins/atom.xml", Version: "v1.0.0-beta.1"}},
Plugins: porterv1.PluginList{porterv1.Plugin{Name: "kubernetes", FeedURL: "https://cdn.porter.sh/plugins/atom.xml", Version: "v1.0.0-rc.1"}},
},
}
Expect(k8sClient.Create(ctx, agentCfg)).To(Succeed())
Expand Down
3 changes: 0 additions & 3 deletions tests/integration/testdata/Dockerfile.k8s-plugin-agent

This file was deleted.

0 comments on commit 0b6a224

Please sign in to comment.