Skip to content

Commit

Permalink
Merge branch 'main' into maven/access2
Browse files Browse the repository at this point in the history
  • Loading branch information
hilmarf authored Apr 23, 2024
2 parents 25ac35b + 0da1765 commit 8b2c2c4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
19 changes: 11 additions & 8 deletions cmds/ocm/commands/controllercmds/install/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Command struct {
DryRun bool
SkipPreFlightCheck bool
InstallPrerequisites bool
SM *ssa.ResourceManager
}

var _ utils.OCMCommand = (*Command)(nil)
Expand Down Expand Up @@ -86,6 +87,14 @@ func (o *Command) Complete(args []string) error {
}

func (o *Command) Run() error {
kubeconfigArgs := genericclioptions.NewConfigFlags(false)
sm, err := NewResourceManager(kubeconfigArgs)
if err != nil {
return fmt.Errorf("✗ failed to create resource manager: %w", err)
}

o.SM = sm

ctx := context.Background()
if !o.SkipPreFlightCheck {
out.Outf(o.Context, "► running pre-install check\n")
Expand Down Expand Up @@ -163,23 +172,17 @@ func (o *Command) installManifest(ctx context.Context, releaseURL, baseURL, mani
}
out.Outf(o.Context, "► applying to cluster...\n")

kubeconfigArgs := genericclioptions.NewConfigFlags(false)
sm, err := NewResourceManager(kubeconfigArgs)
if err != nil {
return fmt.Errorf("✗ failed to create resource manager: %w", err)
}

objects, err := readObjects(path)
if err != nil {
return fmt.Errorf("✗ failed to construct objects to apply: %w", err)
}

if _, err := sm.ApplyAllStaged(context.Background(), objects, ssa.DefaultApplyOptions()); err != nil {
if _, err := o.SM.ApplyAllStaged(context.Background(), objects, ssa.DefaultApplyOptions()); err != nil {
return fmt.Errorf("✗ failed to apply manifests: %w", err)
}

out.Outf(o.Context, "► waiting for ocm deployment to be ready\n")
if err = sm.Wait(objects, ssa.DefaultWaitOptions()); err != nil {
if err = o.SM.Wait(objects, ssa.DefaultWaitOptions()); err != nil {
return fmt.Errorf("✗ failed to wait for objects to be ready: %w", err)
}

Expand Down
13 changes: 2 additions & 11 deletions cmds/ocm/commands/controllercmds/install/install_cert_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ package install

import (
"context"
_ "embed"
"fmt"
"os"

_ "embed"

"github.com/fluxcd/pkg/ssa"
"github.com/mandelsoft/filepath/pkg/filepath"
"k8s.io/cli-runtime/pkg/genericclioptions"

"github.com/open-component-model/ocm/pkg/out"
)

Expand Down Expand Up @@ -54,18 +51,12 @@ func (o *Command) createRegistryCertificate() error {
return fmt.Errorf("failed to write issuer.yaml file at location: %w", err)
}

kubeconfigArgs := genericclioptions.NewConfigFlags(false)
sm, err := NewResourceManager(kubeconfigArgs)
if err != nil {
return fmt.Errorf("failed to create resource manager: %w", err)
}

objects, err := readObjects(path)
if err != nil {
return fmt.Errorf("failed to construct objects to apply: %w", err)
}

if _, err := sm.ApplyAllStaged(context.Background(), objects, ssa.DefaultApplyOptions()); err != nil {
if _, err := o.SM.ApplyAllStaged(context.Background(), objects, ssa.DefaultApplyOptions()); err != nil {
return fmt.Errorf("failed to apply manifests: %w", err)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/env/builder/ocm_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (

const ARCH = "/tmp/ctf"
const ARCH2 = "/tmp/ctf2"
const PROVIDER = "mandelsoft"
const PROVIDER = "open-component-model"
const VERSION = "v1"
const COMPONENT = "github.com/mandelsoft/test"
const COMPONENT = "github.com/open-component-model/test"
const OUT = "/tmp/res"

var _ = Describe("Transfer handler", func() {
Expand Down
16 changes: 8 additions & 8 deletions pkg/toi/install/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ import (
)

var _ = Describe("credential mapping", func() {
consumerid := credentials.NewConsumerIdentity("CT", identity.ID_HOSTNAME, "github.com", identity.ID_PATHPREFIX, "mandelsoft")
consumerid := credentials.NewConsumerIdentity("CT", identity.ID_HOSTNAME, "github.com", identity.ID_PATHPREFIX, "open-component-model")
ccreds := common.Properties{
"user": "mandelsoft",
"user": "open-component-model",
"pass": "mypass",
}
memspec := memory.NewRepositorySpec("default")
memcred := credentials.DirectCredentials{
"username": "mandelsoft",
"username": "open-component-model",
"password": "secret",
}
cfgdata := `
configurations:
- credentials:
- credentials:
password: secret
username: mandelsoft
username: open-component-model
credentialsName: other
- credentials:
token: XXX
Expand All @@ -55,11 +55,11 @@ configurations:
- credentialsName: Credentials
properties:
pass: mypass
user: mandelsoft
user: open-component-model
type: Credentials
identity:
hostname: github.com
pathprefix: mandelsoft/testrepo
pathprefix: open-component-model/testrepo
type: CT
type: credentials.config.ocm.software
type: generic.config.ocm.software
Expand Down Expand Up @@ -99,7 +99,7 @@ forwardedConsumers:
- consumerId:
type: CT
hostname: github.com
pathprefix: mandelsoft/testrepo
pathprefix: open-component-model/testrepo
consumerType: hostpath
`
spec, err := install.ParseCredentialSpecification([]byte(input), "settings")
Expand All @@ -126,7 +126,7 @@ forwardedConsumers:
Expect(mem.LookupCredentials("other")).To(Equal(memcred))

creq := consumerid.Copy()
creq[identity.ID_PATHPREFIX] = "mandelsoft/testrepo/bla"
creq[identity.ID_PATHPREFIX] = "open-component-model/testrepo/bla"
props := Must(credentials.CredentialsForConsumer(ctx, creq, hostpath.Matcher))
Expect(props.Properties()).To(Equal(ccreds))
})
Expand Down

0 comments on commit 8b2c2c4

Please sign in to comment.