Skip to content

Commit

Permalink
feat: support http request via cue (#2)
Browse files Browse the repository at this point in the history
Signed-off-by: kaku <[email protected]>
  • Loading branch information
likakuli authored Jul 26, 2022
1 parent 9a0b21e commit 94c5c8b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ go 1.17

require (
github.com/golang/mock v1.5.0
github.com/k-cloud-labs/pkg v0.2.0
github.com/k-cloud-labs/pkg v0.3.0
k8s.io/api v0.23.6
k8s.io/apiextensions-apiserver v0.23.0
k8s.io/apimachinery v0.23.6
k8s.io/client-go v0.23.6
Expand Down Expand Up @@ -52,7 +53,6 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/api v0.23.6 // indirect
k8s.io/component-base v0.23.0 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
Expand Down Expand Up @@ -304,8 +306,8 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/k-cloud-labs/pkg v0.2.0 h1:kO1O3h7mhHKXdXh8ERMein8um/wSVk46qzoqvqUZdtk=
github.com/k-cloud-labs/pkg v0.2.0/go.mod h1:+5RsSMC7VOdDXdRLwTBZzcY8W931ETI4r4DBqUSBnCk=
github.com/k-cloud-labs/pkg v0.3.0 h1:yM3SFCnM4tr+QJfNoUtbg1lKIQsA/GLppGWBD0OYSvY=
github.com/k-cloud-labs/pkg v0.3.0/go.mod h1:EjvI8cW+qngQ4mT6QaMPbFE0BT1CmG8o27Foj4p22lg=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
Expand Down
8 changes: 4 additions & 4 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/k-cloud-labs/pkg/client/clientset/versioned"
"github.com/k-cloud-labs/pkg/client/informers/externalversions"
"github.com/k-cloud-labs/pkg/util"
"github.com/k-cloud-labs/pkg/util/overridemanager"
"github.com/k-cloud-labs/pkg/utils"
"github.com/k-cloud-labs/pkg/utils/overridemanager"
admissionv1 "k8s.io/api/admission/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -121,7 +121,7 @@ func recordAppliedOverrides(cops *overridemanager.AppliedOverrides, ops *overrid
return nil, err
}
if appliedBytes != nil {
annotations[util.AppliedClusterOverrides] = string(appliedBytes)
annotations[utils.AppliedClusterOverrides] = string(appliedBytes)
}
}

Expand All @@ -131,7 +131,7 @@ func recordAppliedOverrides(cops *overridemanager.AppliedOverrides, ops *overrid
return nil, err
}
if appliedBytes != nil {
annotations[util.AppliedOverrides] = string(appliedBytes)
annotations[utils.AppliedOverrides] = string(appliedBytes)
}
}

Expand Down
14 changes: 7 additions & 7 deletions transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/k-cloud-labs/pkg/util/overridemanager"
"github.com/k-cloud-labs/pkg/utils"
"github.com/k-cloud-labs/pkg/utils/overridemanager"
"github.com/k-cloud-labs/pkg/utils/util"
admissionv1 "k8s.io/api/admission/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -16,13 +18,11 @@ import (
v1alpha10 "github.com/k-cloud-labs/pkg/client/listers/policy/v1alpha1"
"github.com/k-cloud-labs/pkg/test/helper"
"github.com/k-cloud-labs/pkg/test/mock"
"github.com/k-cloud-labs/pkg/util"
"github.com/k-cloud-labs/pkg/util/converter"
)

func TestPolicyTransport_RoundTrip(t *testing.T) {
deployment := helper.NewDeployment(metav1.NamespaceDefault, "test")
deploymentObj, _ := converter.ToUnstructured(deployment)
deploymentObj, _ := util.ToUnstructured(deployment)

overriders1 := policyv1alpha1.Overriders{
Plaintext: []policyv1alpha1.PlaintextOverrider{
Expand Down Expand Up @@ -111,9 +111,9 @@ func TestPolicyTransport_RoundTrip(t *testing.T) {
operation: admissionv1.Create,
wantedErr: nil,
wantedAnnotations: map[string]string{
"foo": "bar",
util.AppliedOverrides: `[{"policyName":"overridePolicy1","overriders":{"plaintext":[{"path":"/metadata/annotations","op":"add","value":{"foo":"bar"}}]}}]`,
util.AppliedClusterOverrides: `[{"policyName":"overridePolicy2","overriders":{"plaintext":[{"path":"/metadata/annotations","op":"add","value":{"hello":"world"}}]}}]`,
"foo": "bar",
utils.AppliedOverrides: `[{"policyName":"overridePolicy1","overriders":{"plaintext":[{"path":"/metadata/annotations","op":"add","value":{"foo":"bar"}}]}}]`,
utils.AppliedClusterOverrides: `[{"policyName":"overridePolicy2","overriders":{"plaintext":[{"path":"/metadata/annotations","op":"add","value":{"hello":"world"}}]}}]`,
},
},
}
Expand Down

0 comments on commit 94c5c8b

Please sign in to comment.