Skip to content

Commit

Permalink
STONEBLD-1735 default to private repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Sep 14, 2023
1 parent 351c65d commit 618011a
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 17 deletions.
4 changes: 4 additions & 0 deletions deploy/crds/base/jvmbuildservice.io_jbsconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ spec:
type: string
prependTag:
type: string
public:
description: if this is true and we are automatically creating
registries then we will make it public
type: boolean
repository:
type: string
secretName:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ spec:
type: string
prependTag:
type: string
public:
description: if this is true and we are automatically creating
registries then we will make it public
type: boolean
repository:
type: string
secretName:
Expand Down
28 changes: 16 additions & 12 deletions openshift-with-appstudio-test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,13 @@ func setupConfig(t *testing.T, namespace string, hermetic bool) *testArgs {
WorkerThreads: "100",
RequestCPU: "10m",
},
Registry: v1alpha1.ImageRegistry{
Host: "quay.io",
Owner: owner,
Repository: "test-images",
PrependTag: strconv.FormatInt(time.Now().UnixMilli(), 10),
Registry: v1alpha1.ImageRegistrySpec{
ImageRegistry: v1alpha1.ImageRegistry{
Host: "quay.io",
Owner: owner,
Repository: "test-images",
PrependTag: strconv.FormatInt(time.Now().UnixMilli(), 10),
},
},
RelocationPatterns: []v1alpha1.RelocationPatternElement{
{
Expand Down Expand Up @@ -878,13 +880,15 @@ func setupMinikube(t *testing.T, namespace string) *testArgs {
DisableTLS: true,
Storage: "756Mi",
},
Registry: v1alpha1.ImageRegistry{
Host: devIp,
Owner: owner,
Repository: "test-images",
Port: "5000",
Insecure: true,
PrependTag: strconv.FormatInt(time.Now().UnixMilli(), 10),
Registry: v1alpha1.ImageRegistrySpec{
ImageRegistry: v1alpha1.ImageRegistry{
Host: devIp,
Owner: owner,
Repository: "test-images",
Port: "5000",
Insecure: true,
PrependTag: strconv.FormatInt(time.Now().UnixMilli(), 10),
},
},
},
Status: v1alpha1.JBSConfigStatus{},
Expand Down
14 changes: 11 additions & 3 deletions pkg/apis/jvmbuildservice/v1alpha1/jbsconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,23 @@ type JBSConfigSpec struct {

MavenBaseLocations map[string]string `json:"mavenBaseLocations,omitempty"`

SharedRegistries []ImageRegistry `json:"sharedRegistries,omitempty"`
Registry ImageRegistry `json:"registry,omitempty"`
SharedRegistries []ImageRegistry `json:"sharedRegistries,omitempty"`
Registry ImageRegistrySpec `json:"registry,omitempty"`

// Deprecated: Replaced by explicit declaration of Registry above.
ImageRegistry `json:",inline,omitempty"`
CacheSettings CacheSettings `json:"cacheSettings,omitempty"`
BuildSettings BuildSettings `json:"buildSettings,omitempty"`
RelocationPatterns []RelocationPatternElement `json:"relocationPatterns,omitempty"`
}

type ImageRegistrySpec struct {
ImageRegistry `json:",inline,omitempty"`

//if this is true and we are automatically creating registries then we will make it public
Public *bool `json:"public,omitempty"`
}

type JBSConfigStatus struct {
Message string `json:"message,omitempty"`
ImageRegistry *ImageRegistry `json:"imageRegistry,omitempty"`
Expand Down Expand Up @@ -122,7 +130,7 @@ type JBSConfig struct {
}

func (in *JBSConfig) ImageRegistry() ImageRegistry {
ret := in.Spec.Registry
ret := in.Spec.Registry.ImageRegistry
if ret.Host == "" {
ret.Host = "quay.io"
}
Expand Down
24 changes: 23 additions & 1 deletion pkg/apis/jvmbuildservice/v1alpha1/zz_generated.deepcopy.go

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

6 changes: 5 additions & 1 deletion pkg/reconciler/jbsconfig/jbsconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,13 +595,17 @@ func (r *ReconcilerJBSConfig) cacheDeployment(ctx context.Context, log logr.Logg

func (r *ReconcilerJBSConfig) handleNoOwnerSpecified(ctx context.Context, log logr.Logger, config *v1alpha1.JBSConfig) error {

vis := imagecontroller.ImageVisibilityPrivate
if config.Spec.Registry.Public != nil && *config.Spec.Registry.Public {
vis = imagecontroller.ImageVisibilityPublic
}
repo := imagecontroller.ImageRepository{}
err := r.client.Get(ctx, types.NamespacedName{Namespace: config.Namespace, Name: v1alpha1.DefaultImageSecretName}, &repo)
if err != nil {
if errors.IsNotFound(err) {
repo.Name = v1alpha1.DefaultImageSecretName
repo.Namespace = config.Namespace
repo.Spec.Image.Visibility = imagecontroller.ImageVisibilityPublic
repo.Spec.Image.Visibility = vis
err := controllerutil.SetOwnerReference(config, &repo, r.scheme)
if err != nil {
return err
Expand Down

0 comments on commit 618011a

Please sign in to comment.