Skip to content
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 app/cli/cmd/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func newOrganizationCmd() *cobra.Command {

cmd.AddCommand(
newOrganizationList(),
newOrganizationUpdateCmd(),
newOrganizationSet(),
newOrganizationDescribeCmd(),
newOrganizationInvitationCmd(),
Expand Down
53 changes: 53 additions & 0 deletions app/cli/cmd/organization_update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// Copyright 2023 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
"context"

"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/spf13/cobra"
)

func newOrganizationUpdateCmd() *cobra.Command {
var orgID, name string

cmd := &cobra.Command{
Use: "update",
Short: "Update an existing organization",
RunE: func(cmd *cobra.Command, args []string) error {
opts := &action.NewOrgUpdateOpts{}
if cmd.Flags().Changed("name") {
opts.Name = &name
}

_, err := action.NewOrgUpdate(actionOpts).Run(context.Background(), orgID, opts)
if err != nil {
return err
}

logger.Info().Msg("Organization updated!")
return nil
},
}

cmd.Flags().StringVar(&orgID, "id", "", "organization ID")
err := cmd.MarkFlagRequired("id")
cobra.CheckErr(err)

cmd.Flags().StringVar(&name, "name", "", "workflow name")
return cmd
}
2 changes: 1 addition & 1 deletion app/cli/internal/action/membership_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (action *MembershipList) Run() ([]*MembershipItem, error) {
return result, nil
}

func pbOrgItemToAction(in *pb.Org) *OrgItem {
func pbOrgItemToAction(in *pb.OrgItem) *OrgItem {
return &OrgItem{
ID: in.Id,
Name: in.Name,
Expand Down
47 changes: 47 additions & 0 deletions app/cli/internal/action/org_update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// Copyright 2023 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package action

import (
"context"

pb "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1"
)

type OrgUpdate struct {
cfg *ActionsOpts
}

func NewOrgUpdate(cfg *ActionsOpts) *OrgUpdate {
return &OrgUpdate{cfg}
}

type NewOrgUpdateOpts struct {
Name *string
}

func (action *OrgUpdate) Run(ctx context.Context, id string, opts *NewOrgUpdateOpts) (*OrgItem, error) {
client := pb.NewOrganizationServiceClient(action.cfg.CPConnection)
resp, err := client.Update(ctx, &pb.OrganizationServiceUpdateRequest{
Id: id, Name: opts.Name,
})

if err != nil {
return nil, err
}

return pbOrgItemToAction(resp.Result), nil
}
56 changes: 28 additions & 28 deletions app/controlplane/api/controlplane/v1/context.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/controlplane/api/controlplane/v1/context.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ message ContextServiceCurrentResponse {

message Result {
User current_user = 1;
Org current_org = 2;
OrgItem current_org = 2;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change it just to be consistent with the name of other resources in the proto defs

CASBackendItem current_cas_backend = 3;
}
}
Loading