Skip to content

Commit

Permalink
Merge pull request #2 from corelayer/0.1.0-dev.20230314
Browse files Browse the repository at this point in the history
0.1.0 dev.20240314
  • Loading branch information
jantytgat authored Mar 18, 2024
2 parents 65a8603 + 2e00d7e commit c2d7922
Show file tree
Hide file tree
Showing 18 changed files with 240 additions and 27 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@ func (r Registry) GetProviderByName(name string) (Provider, error) {
}

func (r Registry) GetProviderNames() []string {
var (
output []string
)
output = make([]string, len(r.Providers))
names := make([]string, len(r.Providers))
for i := 0; i < len(r.Providers); i++ {
output[i] = r.Providers[i].Name
names[i] = r.Providers[i].Name
}

return output
return names
}

func (r Registry) GetServiceByName(name string) (Service, error) {
Expand All @@ -59,15 +56,12 @@ func (r Registry) GetServiceByName(name string) (Service, error) {
}

func (r Registry) GetServiceNames() []string {
var (
output []string
)
output = make([]string, len(r.Services))
names := make([]string, len(r.Services))
for i := 0; i < len(r.Services); i++ {
output[i] = r.Services[i].Name
names[i] = r.Services[i].Name
}

return output
return names
}

func (r Registry) GetTransformConfig() cryptostruct.TransformConfig {
Expand All @@ -87,15 +81,12 @@ func (r Registry) GetUserByName(name string) (User, error) {
}

func (r Registry) GetUserNames() []string {
var (
output []string
)
output = make([]string, len(r.Users))
names := make([]string, len(r.Users))
for i := 0; i < len(r.Users); i++ {
output[i] = r.Users[i].Name
names[i] = r.Users[i].Name
}

return output
return names
}

type SecureRegistry struct {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions pkg/registry/certificates/passphrase.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2024 CoreLayer BV
*
* 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 certificates

import (
"github.com/corelayer/go-cryptostruct/pkg/cryptostruct"
)

type Passphrase struct {
Name string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty" secure:"false"`
Value string `json:"value,omitempty" yaml:"value,omitempty" mapstructure:"value,omitempty" secure:"true"`
}

func (c Passphrase) GetTransformConfig() cryptostruct.TransformConfig {
return cryptostruct.TransformConfig{
Decrypted: Passphrase{},
Encrypted: SecurePassphrase{},
}
}

type SecurePassphrase struct {
Name string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty" secure:"false"`
Value string `json:"value,omitempty" yaml:"value,omitempty" mapstructure:"value,omitempty" secure:"true"`
CryptoParams cryptostruct.CryptoParams `json:"cryptoParams" yaml:"cryptoParams" mapstructure:"cryptoParams"`
}

func (s SecurePassphrase) GetTransformConfig() cryptostruct.TransformConfig {
return cryptostruct.TransformConfig{
Decrypted: Passphrase{},
Encrypted: SecurePassphrase{},
}
}

func (s SecurePassphrase) GetCryptoParams() cryptostruct.CryptoParams {
return s.CryptoParams
}
71 changes: 71 additions & 0 deletions pkg/registry/certificates/registry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2024 CoreLayer BV
*
* 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 certificates

import (
"fmt"

"github.com/corelayer/go-cryptostruct/pkg/cryptostruct"

"github.com/corelayer/go-registry/pkg/registry/certificates/acme"
)

type Registry struct {
Acme acme.Registry `json:"acme,omitempty" yaml:"acme,omitempty" mapstructure:"acme,omitempty" secure:"true"`
Passphrases []Passphrase `json:"passphrases,omitempty" yaml:"passphrases,omitempty" mapstructure:"passphrases,omitempty" secure:"true"`
}

func (r Registry) GetPassphraseByName(name string) (Passphrase, error) {
for _, p := range r.Passphrases {
if p.Name == name {
return p, nil
}
}
return Passphrase{}, fmt.Errorf("could not find passphrase %s", name)
}

func (r Registry) GetPassphraseNames() []string {
names := make([]string, len(r.Passphrases))
for _, p := range r.Passphrases {
names = append(names, p.Name)
}
return names
}

func (r Registry) GetTransformConfig() cryptostruct.TransformConfig {
return cryptostruct.TransformConfig{
Decrypted: Registry{},
Encrypted: SecureRegistry{},
}
}

type SecureRegistry struct {
Acme acme.SecureRegistry `json:"acme,omitempty" yaml:"acme,omitempty" mapstructure:"acme,omitempty" secure:"true"`
Passphrases []SecurePassphrase `json:"passphrases,omitempty" yaml:"passphrases,omitempty" mapstructure:"passphrases,omitempty" secure:"true"`
CryptoParams cryptostruct.CryptoParams `json:"cryptoParams" yaml:"cryptoParams" mapstructure:"cryptoParams"`
}

func (s SecureRegistry) GetTransformConfig() cryptostruct.TransformConfig {
return cryptostruct.TransformConfig{
Decrypted: Registry{},
Encrypted: SecureRegistry{},
}
}

func (s SecureRegistry) GetCryptoParams() cryptostruct.CryptoParams {
return s.CryptoParams
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package adc

// Settings TODO - Remove UserAgent, AutoLogin, Timeout??
type Settings struct {
UseSsl bool `json:"useSsl,omitempty" yaml:"useSsl,omitempty" mapstructure:"useSsl,omitempty"`
Timeout int `json:"timeout,omitempty" yaml:"timeout,omitempty" mapstructure:"timeout,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package netscaler
import (
"github.com/corelayer/go-cryptostruct/pkg/cryptostruct"

"github.com/corelayer/go-registry/pkg/registry/netscaler/adc"
"github.com/corelayer/go-registry/pkg/registry/netscaler/sdx"
"github.com/corelayer/go-registry/pkg/registry/machines/netscaler/adc"
"github.com/corelayer/go-registry/pkg/registry/machines/netscaler/sdx"
)

type Registry struct {
Expand Down
File renamed without changes.
50 changes: 50 additions & 0 deletions pkg/registry/machines/registry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2024 CoreLayer BV
*
* 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 machines

import (
"github.com/corelayer/go-cryptostruct/pkg/cryptostruct"

"github.com/corelayer/go-registry/pkg/registry/machines/netscaler"
)

type Registry struct {
NetScaler netscaler.Registry `json:"netscaler,omitempty" yaml:"netscaler,omitempty" mapstructure:"netscaler,omitempty" secure:"true"`
}

func (r Registry) GetTransformConfig() cryptostruct.TransformConfig {
return cryptostruct.TransformConfig{
Decrypted: Registry{},
Encrypted: SecureRegistry{},
}
}

type SecureRegistry struct {
NetScaler netscaler.SecureRegistry `json:"netscaler,omitempty" yaml:"netscaler,omitempty" mapstructure:"netscaler,omitempty" secure:"true"`
CryptoParams cryptostruct.CryptoParams `json:"cryptoParams" yaml:"cryptoParams" mapstructure:"cryptoParams"`
}

func (s SecureRegistry) GetTransformConfig() cryptostruct.TransformConfig {
return cryptostruct.TransformConfig{
Decrypted: Registry{},
Encrypted: SecureRegistry{},
}
}

func (s SecureRegistry) GetCryptoParams() cryptostruct.CryptoParams {
return s.CryptoParams
}
50 changes: 50 additions & 0 deletions pkg/registry/organization.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2024 CoreLayer BV
*
* 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 registry

import (
"github.com/corelayer/go-cryptostruct/pkg/cryptostruct"
)

type Organization struct {
Name string `json:"name" yaml:"name" mapstructure:"name" secure:"false"`
Registry Registry `json:"registry,omitempty" yaml:"registry,omitempty" mapstructure:"registry,omitempty" secure:"true"`
}

func (o Organization) GetTransformConfig() cryptostruct.TransformConfig {
return cryptostruct.TransformConfig{
Decrypted: Organization{},
Encrypted: SecureOrganization{},
}
}

type SecureOrganization struct {
Name string `json:"name" yaml:"name" mapstructure:"name" secure:"false"`
Registry SecureRegistry `json:"registry,omitempty" yaml:"registry,omitempty" mapstructure:"registry,omitempty" secure:"true"`
CryptoParams cryptostruct.CryptoParams `json:"cryptoParams" yaml:"cryptoParams" mapstructure:"cryptoParams"`
}

func (s SecureOrganization) GetTransformConfig() cryptostruct.TransformConfig {
return cryptostruct.TransformConfig{
Decrypted: Organization{},
Encrypted: SecureOrganization{},
}
}

func (s SecureOrganization) GetCryptoParams() cryptostruct.CryptoParams {
return s.CryptoParams
}
14 changes: 7 additions & 7 deletions pkg/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ package registry
import (
"github.com/corelayer/go-cryptostruct/pkg/cryptostruct"

"github.com/corelayer/go-registry/pkg/registry/acme"
"github.com/corelayer/go-registry/pkg/registry/netscaler"
"github.com/corelayer/go-registry/pkg/registry/certificates"
"github.com/corelayer/go-registry/pkg/registry/machines"
)

type Registry struct {
NetScaler netscaler.Registry `json:"netscaler,omitempty" yaml:"netscaler,omitempty" mapstructure:"netscaler,omitempty" secure:"true"`
Acme acme.Registry `json:"acme,omitempty" yaml:"acme,omitempty" mapstructure:"acme,omitempty" secure:"true"`
Machines machines.Registry `json:"machines,omitempty" yaml:"machines,omitempty" mapstructure:"machines,omitempty" secure:"true"`
Certificates certificates.Registry `json:"certificates,omitempty" yaml:"certificates,omitempty" mapstructure:"certificates,omitempty" secure:"true"`
}

func (c Registry) GetTransformConfig() cryptostruct.TransformConfig {
Expand All @@ -36,9 +36,9 @@ func (c Registry) GetTransformConfig() cryptostruct.TransformConfig {
}

type SecureRegistry struct {
NetScaler netscaler.SecureRegistry `json:"netscaler,omitempty" yaml:"netscaler,omitempty" mapstructure:"netscaler,omitempty" secure:"true"`
Acme acme.SecureRegistry `json:"acme,omitempty" yaml:"acme,omitempty" mapstructure:"acme,omitempty" secure:"true"`
CryptoParams cryptostruct.CryptoParams `json:"cryptoParams" yaml:"cryptoParams" mapstructure:"cryptoParams"`
Machines machines.SecureRegistry `json:"machines,omitempty" yaml:"machines,omitempty" mapstructure:"machines,omitempty" secure:"true"`
Certificates certificates.SecureRegistry `json:"certificates,omitempty" yaml:"certificates,omitempty" mapstructure:"certificates,omitempty" secure:"true"`
CryptoParams cryptostruct.CryptoParams `json:"cryptoParams" yaml:"cryptoParams" mapstructure:"cryptoParams"`
}

func (s SecureRegistry) GetTransformConfig() cryptostruct.TransformConfig {
Expand Down

0 comments on commit c2d7922

Please sign in to comment.