Skip to content

Commit

Permalink
fix(dashboard): putGroupEnvDeployment should auto diff overwrites whe…
Browse files Browse the repository at this point in the history
…n reversion exists
  • Loading branch information
morlay committed May 23, 2023
1 parent 48fce68 commit 3712ecc
Show file tree
Hide file tree
Showing 28 changed files with 449 additions and 229 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ k.k8s: gen.kubepkg
k.dashboard:
$(KUBEPKG) serve dashboard --log-level=debug -c \
--addr=0.0.0.0:8081 \
--db-enable-migrate \
--auth-provider-oidc-endpoint=${OIDC_PROVIDER}

k.operator:
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubepkg/serve_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func init() {
s := cli.AddTo(Serve, &Dashboard{})

s.ApplyHandler(func(h http.Handler) http.Handler {
s.ApplyGlobalHandlers(func(h http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
if strings.HasPrefix(req.URL.Path, "/api/") {
h.ServeHTTP(rw, req)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/go-logr/logr v1.2.4
github.com/go-rod/rod v0.112.2
github.com/google/uuid v1.3.0
github.com/innoai-tech/infra v0.0.0-20230523055408-b60d97c09cfb
github.com/innoai-tech/infra v0.0.0-20230523100858-148131f5b258
github.com/lestrrat-go/jwx/v2 v2.0.9
github.com/mattn/go-colorable v0.1.13
github.com/mattn/go-isatty v0.0.19
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/innoai-tech/infra v0.0.0-20230523055408-b60d97c09cfb h1:+fUOYL8RvkEYBLprr6sd+8kmNjkBg/dnD2ELtJBkZog=
github.com/innoai-tech/infra v0.0.0-20230523055408-b60d97c09cfb/go.mod h1:hs2mAP8sl2k2LIWcEMu4Ngp6F143W7sShtwysHbN3NQ=
github.com/innoai-tech/infra v0.0.0-20230523100858-148131f5b258 h1:DdMGF0YzvNe/EkTps0y2EzT74ThOq8Qu8VKLTLtUQI0=
github.com/innoai-tech/infra v0.0.0-20230523100858-148131f5b258/go.mod h1:T1FvIoJsLeonZ1KjV1aqtWmjcTG7/RiE0/AxuuqR2pQ=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
Expand Down
2 changes: 1 addition & 1 deletion internal/agent/apis/blob/zz_generated.operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func init() {
}

func (*StatBlob) ResponseContent() any {
return &github_com_distribution_distribution_v3.Descriptor{}
return new(github_com_distribution_distribution_v3.Descriptor)
}

func (*StatBlob) ResponseErrors() []error {
Expand Down
4 changes: 2 additions & 2 deletions internal/agent/apis/kubepkg/zz_generated.operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func init() {
}

func (*GetKubePkg) ResponseContent() any {
return &github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkg{}
return new(github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkg)
}

func (*GetKubePkg) ResponseErrors() []error {
Expand All @@ -73,7 +73,7 @@ func init() {
}

func (*ListKubePkg) ResponseContent() any {
return &[]github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkg{}
return new([]github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkg)
}

func (*ListKubePkg) ResponseErrors() []error {
Expand Down
6 changes: 3 additions & 3 deletions internal/dashboard/apis/admin/zz_generated.operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ func init() {
}

func (*ListAccount) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_account.UserDataList{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_account.UserDataList)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&ListAdminAccount{}))
}

func (*ListAdminAccount) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_group.UserDataList{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_group.UserDataList)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&PutAdminAccount{}))
}

func (*PutAdminAccount) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_group.Account{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_group.Account)
}
4 changes: 2 additions & 2 deletions internal/dashboard/apis/auth/zz_generated.operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func init() {
}

func (*ExchangeToken) ResponseContent() any {
return &github_com_octohelm_kubepkg_pkg_auth.Token{}
return new(github_com_octohelm_kubepkg_pkg_auth.Token)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&ListAuthProvider{}))
}

func (*ListAuthProvider) ResponseContent() any {
return &[]*github_com_octohelm_kubepkg_pkg_auth.ProviderInfo{}
return new([]*github_com_octohelm_kubepkg_pkg_auth.ProviderInfo)
}
8 changes: 4 additions & 4 deletions internal/dashboard/apis/cluster/zz_generated.operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ func init() {
}

func (*GetClusterStatus) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_cluster.InstanceStatus{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_cluster.InstanceStatus)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&ListCluster{}))
}

func (*ListCluster) ResponseContent() any {
return &[]*github_com_octohelm_kubepkg_internal_dashboard_domain_cluster.Cluster{}
return new([]*github_com_octohelm_kubepkg_internal_dashboard_domain_cluster.Cluster)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&PutCluster{}))
}

func (*PutCluster) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_cluster.Cluster{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_cluster.Cluster)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&RenameCluster{}))
}

func (*RenameCluster) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_cluster.Cluster{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_cluster.Cluster)
}
32 changes: 16 additions & 16 deletions internal/dashboard/apis/group/zz_generated.operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ func init() {
}

func (*BindGroupEnvCluster) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_group.EnvWithCluster{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_group.EnvWithCluster)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&CreateGroupRobot{}))
}

func (*CreateGroupRobot) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_account.Robot{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_account.Robot)
}

func init() {
Expand Down Expand Up @@ -66,39 +66,39 @@ func init() {
}

func (*GetGroup) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_group.Group{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_group.Group)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&ListGroup{}))
}

func (*ListGroup) ResponseContent() any {
return &[]*github_com_octohelm_kubepkg_internal_dashboard_domain_group.Group{}
return new([]*github_com_octohelm_kubepkg_internal_dashboard_domain_group.Group)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&ListGroupAccount{}))
}

func (*ListGroupAccount) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_group.UserDataList{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_group.UserDataList)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&ListGroupEnv{}))
}

func (*ListGroupEnv) ResponseContent() any {
return &[]*github_com_octohelm_kubepkg_internal_dashboard_domain_group.EnvWithCluster{}
return new([]*github_com_octohelm_kubepkg_internal_dashboard_domain_group.EnvWithCluster)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&ListGroupEnvClusterDeployments{}))
}

func (*ListGroupEnvClusterDeployments) ResponseContent() any {
return &[]github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkg{}
return new([]github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkg)
}

func (*ListGroupEnvClusterDeployments) ResponseErrors() []error {
Expand All @@ -116,69 +116,69 @@ func init() {
}

func (*ListGroupEnvDeployment) ResponseContent() any {
return &github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkgList{}
return new(github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkgList)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&ListGroupEnvDeploymentHistory{}))
}

func (*ListGroupEnvDeploymentHistory) ResponseContent() any {
return &[]*github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkg{}
return new([]*github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkg)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&ListGroupRobot{}))
}

func (*ListGroupRobot) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_group.RobotDataList{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_group.RobotDataList)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&PutGroup{}))
}

func (*PutGroup) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_group.Group{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_group.Group)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&PutGroupAccount{}))
}

func (*PutGroupAccount) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_group.Account{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_group.Account)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&PutGroupEnv{}))
}

func (*PutGroupEnv) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_group.EnvWithCluster{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_group.EnvWithCluster)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&PutGroupEnvDeployment{}))
}

func (*PutGroupEnvDeployment) ResponseContent() any {
return &github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkg{}
return new(github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkg)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&RefreshGroupRobotToken{}))
}

func (*RefreshGroupRobotToken) ResponseContent() any {
return &github_com_octohelm_kubepkg_pkg_auth.Token{}
return new(github_com_octohelm_kubepkg_pkg_auth.Token)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&UnbindGroupEnvCluster{}))
}

func (*UnbindGroupEnvCluster) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_domain_group.EnvWithCluster{}
return new(github_com_octohelm_kubepkg_internal_dashboard_domain_group.EnvWithCluster)
}
8 changes: 4 additions & 4 deletions internal/dashboard/apis/kubepkg/zz_generated.operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,31 @@ func init() {
}

func (*GetKubepkgRevision) ResponseContent() any {
return &github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkg{}
return new(github_com_octohelm_kubepkg_pkg_apis_kubepkg_v1alpha1.KubePkg)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&LatestKubepkgs{}))
}

func (*LatestKubepkgs) ResponseContent() any {
return &map[string]*github_com_octohelm_kubepkg_internal_dashboard_domain_kubepkg.VersionInfo{}
return new(map[string]*github_com_octohelm_kubepkg_internal_dashboard_domain_kubepkg.VersionInfo)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&ListKubepkg{}))
}

func (*ListKubepkg) ResponseContent() any {
return &[]*github_com_octohelm_kubepkg_internal_dashboard_domain_kubepkg.Kubepkg{}
return new([]*github_com_octohelm_kubepkg_internal_dashboard_domain_kubepkg.Kubepkg)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&ListKubepkgVersion{}))
}

func (*ListKubepkgVersion) ResponseContent() any {
return &[]*github_com_octohelm_kubepkg_internal_dashboard_domain_kubepkg.VersionInfo{}
return new([]*github_com_octohelm_kubepkg_internal_dashboard_domain_kubepkg.VersionInfo)
}

func init() {
Expand Down
4 changes: 2 additions & 2 deletions internal/dashboard/apis/user/zz_generated.operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ func init() {
}

func (*CurrentPermissions) ResponseContent() any {
return &github_com_octohelm_kubepkg_pkg_rbac.Permissions{}
return new(github_com_octohelm_kubepkg_pkg_rbac.Permissions)
}

func init() {
R.Register(github_com_octohelm_courier_pkg_courier.NewRouter(&CurrentUser{}))
}

func (*CurrentUser) ResponseContent() any {
return &github_com_octohelm_kubepkg_internal_dashboard_apis_auth_operator.Account{}
return new(github_com_octohelm_kubepkg_internal_dashboard_apis_auth_operator.Account)
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ func (s *GroupEnvDeploymentService) PutKubePkg(ctx context.Context, pkg *v1alpha
namespace := pkg.Namespace

pkg.Namespace = s.group.Name

kpkg, kpkgRef, err := s.kubepkgRepo.Put(ctx, pkg)
if err != nil {
return nil, statuserror.Wrap(err, http.StatusBadRequest, "InvalidKubePkg")
}

pkg.Namespace = namespace
kpkg.Namespace = namespace

deployment, err := s.groupEnvDeploymentRepo.BindKubepkg(ctx, kpkg.Name, group.KubepkgRel{
KubepkgID: kpkgRef.KubepkgID,
Expand Down
Loading

0 comments on commit 3712ecc

Please sign in to comment.