Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS-6973 Create juju jaas snap #1149

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
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ jimmctl-snap:
cp -R ./snaps/jimmctl/* ./snap/
snapcraft

jaas-snap:
mkdir -p ./snap
cp -R ./snaps/jaas/* ./snap/
snapcraft

push-microk8s: jimm-image
docker tag jimm:latest localhost:32000/jimm:latest
docker push localhost:32000/jimm:latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/juju/names/v4"
gc "gopkg.in/check.v1"

"github.com/canonical/jimm/cmd/serviceaccounts/cmd"
"github.com/canonical/jimm/cmd/jaas/cmd"
"github.com/canonical/jimm/internal/cmdtest"
"github.com/canonical/jimm/internal/openfga"
ofganames "github.com/canonical/jimm/internal/openfga/names"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/juju/names/v4"
gc "gopkg.in/check.v1"

"github.com/canonical/jimm/cmd/serviceaccounts/cmd"
"github.com/canonical/jimm/cmd/jaas/cmd"
"github.com/canonical/jimm/internal/cmdtest"
"github.com/canonical/jimm/internal/dbmodel"
"github.com/canonical/jimm/internal/openfga"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/juju/names/v4"
gc "gopkg.in/check.v1"

"github.com/canonical/jimm/cmd/serviceaccounts/cmd"
"github.com/canonical/jimm/cmd/jaas/cmd"
"github.com/canonical/jimm/internal/cmdtest"
"github.com/canonical/jimm/internal/dbmodel"
"github.com/canonical/jimm/internal/jimm"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/juju/names/v4"
gc "gopkg.in/check.v1"

"github.com/canonical/jimm/cmd/serviceaccounts/cmd"
"github.com/canonical/jimm/cmd/jaas/cmd"
"github.com/canonical/jimm/internal/cmdtest"
"github.com/canonical/jimm/internal/dbmodel"
"github.com/canonical/jimm/internal/openfga"
Expand Down
14 changes: 9 additions & 5 deletions cmd/serviceaccounts/main.go → cmd/jaas/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ import (
"fmt"
"os"

"github.com/canonical/jimm/cmd/serviceaccounts/cmd"
"github.com/canonical/jimm/cmd/jaas/cmd"
jujucmd "github.com/juju/cmd/v3"
)

var serviceAccountDoc = `
juju service-accounts enables users to manage service accounts.
var jaasDoc = `
juju jaas enables users to use JAAS commands from within Juju.

JAAS enables enterprise functionality on top of Juju to provide
functionality like OIDC login, control over many controllers,
and fine-grained authorisation.
`

func NewSuperCommand() *jujucmd.SuperCommand {
serviceAccountCmd := jujucmd.NewSuperCommand(jujucmd.SuperCommandParams{
Name: "service-accounts",
Doc: serviceAccountDoc,
Name: "jaas",
Doc: jaasDoc,
})
// Register commands here:
serviceAccountCmd.Register(cmd.NewAddServiceAccountCommand())
Expand Down
33 changes: 33 additions & 0 deletions snaps/jaas/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: juju-jaas
summary: JAAS plugin
description: Juju plugin for providing JAAS functionality to the Juju CLI.
version: git
grade: stable
base: bare
Copy link
Contributor

Choose a reason for hiding this comment

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

<3

build-base: core20
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not core22?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Juju snap is on core20 and my machine cannot (for some strange reason) build core22 snaps. But more the former reason, though we don't need to be on the same core anyway.

confinement: strict

slots:
jaas-plugin:
interface: content
content: jaas-plugin
read:
- $SNAP/bin

# The app has no plugs as it is intended to be invoked by the Juju CLI Snap.
apps:
jaas:
command: bin/juju-jaas

parts:
jaas:
plugin: go
source: ./
source-type: git
prime:
- bin/juju-jaas
override-build: |
set -e
CGO_ENABLED=0 go build -o juju-jaas github.com/canonical/jimm/cmd/jaas
mkdir -p $GOBIN
cp ./juju-jaas $GOBIN/juju-jaas
Copy link
Member

Choose a reason for hiding this comment

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

Why not just copy to $SNAP/bin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure $SNAP/bin is the right location. Our other snapcraft.yaml does go install which installs the file to $GOBIN but that does not let you rename the binary, so I instead do it like this.

Loading