Skip to content

Commit

Permalink
remove duplicated appoffer tag (#1374)
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 authored Sep 20, 2024
1 parent 7dfac5a commit dc065a3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 66 deletions.
3 changes: 1 addition & 2 deletions internal/discharger/discharger.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/canonical/jimm/v3/internal/errors"
"github.com/canonical/jimm/v3/internal/openfga"
ofganames "github.com/canonical/jimm/v3/internal/openfga/names"
jimmnames "github.com/canonical/jimm/v3/pkg/names"
)

var defaultDischargeExpiry = 15 * time.Minute
Expand Down Expand Up @@ -120,7 +119,7 @@ func (md *MacaroonDischarger) CheckThirdPartyCaveat(ctx context.Context, req *ht
return nil, checkers.ErrCaveatNotRecognized
}

offerTag := jimmnames.NewApplicationOfferTag(offerUUID)
offerTag := names.NewApplicationOfferTag(offerUUID)

i, err := dbmodel.NewIdentity(userTag.Id())
if err != nil {
Expand Down
9 changes: 4 additions & 5 deletions internal/jimm/applicationoffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/canonical/jimm/v3/internal/errors"
"github.com/canonical/jimm/v3/internal/openfga"
ofganames "github.com/canonical/jimm/v3/internal/openfga/names"
jimmnames "github.com/canonical/jimm/v3/pkg/names"
)

// AddApplicationOfferParams holds parameters for the Offer method.
Expand Down Expand Up @@ -214,7 +213,7 @@ func (j *JIMM) GetApplicationOfferConsumeDetails(ctx context.Context, user *open
&offer.Model.Controller,
names.ModelTag{},
permission{
resource: jimmnames.NewApplicationOfferTag(offer.UUID).String(),
resource: names.NewApplicationOfferTag(offer.UUID).String(),
relation: accessLevel,
},
)
Expand Down Expand Up @@ -332,7 +331,7 @@ func (j *JIMM) GetApplicationOffer(ctx context.Context, user *openfga.User, offe
&offer.Model.Controller,
names.ModelTag{},
permission{
resource: jimmnames.NewApplicationOfferTag(offer.UUID).String(),
resource: names.NewApplicationOfferTag(offer.UUID).String(),
relation: accessLevel,
},
)
Expand Down Expand Up @@ -535,7 +534,7 @@ func (j *JIMM) UpdateApplicationOffer(ctx context.Context, controller *dbmodel.C
&offer.Model.Controller,
names.ModelTag{},
permission{
resource: jimmnames.NewApplicationOfferTag(offer.UUID).String(),
resource: names.NewApplicationOfferTag(offer.UUID).String(),
relation: string(jujuparams.OfferAdminAccess),
},
)
Expand Down Expand Up @@ -817,7 +816,7 @@ func (j *JIMM) doApplicationOfferAdmin(ctx context.Context, user *openfga.User,
&offer.Model.Controller,
names.ModelTag{},
permission{
resource: jimmnames.NewApplicationOfferTag(offer.UUID).String(),
resource: names.NewApplicationOfferTag(offer.UUID).String(),
relation: string(jujuparams.OfferAdminAccess),
},
)
Expand Down
2 changes: 1 addition & 1 deletion internal/openfga/openfga.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var (
// ModelType represents a model object.
ModelType Kind = names.ModelTagKind
// ApplicationOfferType represents an application offer object.
ApplicationOfferType Kind = jimmnames.ApplicationOfferTagKind
ApplicationOfferType Kind = names.ApplicationOfferTagKind
// CloudType represents a cloud object.
CloudType Kind = names.CloudTagKind
// ControllerType represents a controller object.
Expand Down
53 changes: 0 additions & 53 deletions pkg/names/applicationoffer.go

This file was deleted.

5 changes: 0 additions & 5 deletions pkg/names/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ func ParseTag(tag string) (names.Tag, error) {
return nil, invalidTagError(tag, kind)
}
return NewGroupTag(id), nil
case ApplicationOfferTagKind:
if !IsValidApplicationOfferTag(id) {
return nil, invalidTagError(tag, kind)
}
return NewApplicationOfferTag(id), nil
case ServiceAccountTagKind:
if !IsValidServiceAccountId(id) {
return nil, invalidTagError(tag, kind)
Expand Down

0 comments on commit dc065a3

Please sign in to comment.